Public report of owkin/GrAIdient, published 17 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 report Measured 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, 17 November 2026, 10:18 UTC · Survey ID cd_6975b911a2d44995af3934a133389846

owkin/GrAIdient

Measured 17 November 2026, 10:18 UTC, at code version a6ca885

Dependency hygiene is not measured: SwiftPM pinning read, dependency currency NOT established (SwiftPM has no central registry to ask).

Supply-chain provenance & signing is not measured: Supply-chain provenance is not scored (this pipeline releases no artifact), but its build steps or GitHub Actions workflows have integrity defects, or nothing watches its dependency set for published advisories.

CAI score 66.8out of 100 Adequate
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: 54,026 lines of product code in 4 projects, tests not counted · Estimated rebuild effort: about 0.7 person-years · Weakest lens: Maturity, 56.4

Findings by how serious they are

3 critical 1233 serious 194 minor

29 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

Assert small markCanine Code Analyzer
Producer
Canine Development
Analyzer
Canine Code Analyzer engine 1.0.0
Measured
17 November 2026, 10:18 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 ▸

33of 33 dimensions measured by tools.
1424of 1430 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.
33dimensions across 5 lenses, read from 54,026 lines of product code in 4 projects.
Chapters

Executive summary

owkin/GrAIdient falls short of our standard for a preview release because its Code quality dimensions are rated Weak, and 98 files are no longer known to anyone active in the project. It scores 66.8 out of 100, which alone would earn Strong, but it is rated Adequate: a rating can't sit more than one step above its weakest group.

Maturity, at 56.4, is the weakest lens and counts most in the score. The best first step is having someone learn and document the 98 files no active contributor knows, worth about 10.4 points. Recording design decisions comes next, worth about 7.7 points. Raising Maturity to 62 would lift the score to about 69.4.

Three pipeline tools are referenced by a changeable name, so the build pipeline can be tampered with. Pinning each tool to an exact version would close this risk.

The product code is 54,026 lines, about €110,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 for The 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.
Maturity 56.4 · counts for 47%Production Readiness 68.3 · counts for 26%Code Health 75.2 · counts for 14%Security and Compliance 92.8 · counts for 8%Architecture 95.7 · counts for 4%

If Maturity rose from 56.4 to 62, the lowest score rated Strong, the score would rise from 66.8 to about 69.4.

Code composition: what the lines of code are
Product code 61%Tests 39%
Rebuild cost: about €110,000 · Estimate
Cost to rebuild€36,000 to €180,000, for 596 to 1,890 hours of work, about 0.7 person-years for 1 to 2 engineers
Difficulty of the problemStandard, 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.9 at a score of 67. 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.
SizeMedium: 54,026 lines of product code
What it is notNot 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
Resolve the 98 Orphaned file finding(s) in Knowledge Freshness — start with Convolution2D.swift, FullyConnectedPatch.swift, VQ2D.swift.
Raises the score by about 10.4 points · Medium effort · Knowledge Freshness
2
Record your significant design decisions.
Write one short document per decision, giving its date, the situation, the decision and its consequences, and keep them together with your other design documents. A docs/adr folder with each file named by number and title is the easiest place to find them.
Raises the score by about 7.7 points · Medium effort · Architecture documentation
3
Add a SAST step to CI running what this repository's stack ships: CodeQL's Swift pack (Swift/Xcode) — or `semgrep --config=auto`, which runs on any language — so a security regression fails the build instead of landing.
Raises the score by about 4.7 points · Medium effort · Security & performance tooling

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.

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 4.0 out of 10. Code at that level is slower to change than clean code, and we estimate the extra work at 10% to 23% on every change. The history of the code shows how much it changes: about 20,672 lines over the last 90 days, which is about 83,836 lines a year. At that pace, the extra work comes to an estimated 21.1 to 126.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.
Where the investment is most exposed · Value at risk
This code would cost about €110,000 to build again, about 0.7 person-years of work. Its weakest lens is Maturity, at 56.4 (Adequate). Maturity is about how well the project explains and looks after itself, which decides whether a new developer, or a new supplier, can take over. Because the weakest lens counts most in the score, work on Maturity also moves the score most.
Based on: the rebuild estimate · the Maturity grade · how much each lens counts
What to do: Start with the Maturity actions in Top priorities.
If you do one thing first · First action
Resolve the 98 Orphaned file finding(s) in Knowledge Freshness. Of all the actions in this report, it raises the score most for the work it takes: about 10.4 points for medium effort, because it clears the 98 Knowledge Freshness findings. The next survey will show the change in the score.
Based on: the ranked actions in Top priorities, by score gain and effort

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.

arch GrAITestsUtils GrAITestsUtils GrAIdient GrAIdient GrAITestsUtils->GrAIdient python_lib (Tests/GrAIExamples/Base) Base) python_lib (Tests/GrAITorchTests/Base) Base)

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.

2 modules, with 1 dependency between them. Every module uses only modules listed above it, so there are no loops.

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.
uses →1 GrAIdient2 GrAITestsUtils
1 GrAIdient
2 GrAITestsUtils1
Uses a module listed above itPart of a loopThe module itself
1 GrAIdient2 GrAITestsUtilsGrAIdient1GrAITestsUtils21

At a glance — Code Health · 75.2 · Adequate · gated by D2, D4 ·

At a glance — Architecture · 95.7 · Exemplary ·

At a glance — Maturity · 56.4 · Adequate · gated by D34, M2 ·

At a glance — Readiness · 68.3 · Adequate · gated by P3 ·

At a glance — Security · 92.8 · Checked 3 of 8 ·

Security & Compliance — OWASP Top-10 mapping

Findings mapped to OWASP categories; the specific CVEs/secrets are in the Security dimension cards below and findings.md (redacted only on the public version of this report).

OWASP categoryFindingsSeverity
A05:2025 — Injection6High / Critical

Roadmap

Top priorities: Resolve the 98 Orphaned file finding(s) in Knowledge Freshness — start with Convolution2D.swift, FullyConnectedPatch.swift, VQ2D.swift; Record your significant design decisions. Write one short document per decision, giving its date, the situation, the decision and its consequences, and keep them together with your other design documents. A docs/adr folder with each file named by number and title is the easiest place to find them; Add a SAST step to CI running what this repository's stack ships: CodeQL's Swift pack (Swift/Xcode) — or `semgrep --config=auto`, which runs on any language — so a security regression fails the build instead of landing.

Ranked by impact ÷ effort. "Helps" is the estimated gain on the 0–100 health score.

Do thisHelpsEffortDimension
Resolve the 98 Orphaned file finding(s) in Knowledge Freshness — start with Convolution2D.swift, FullyConnectedPatch.swift, VQ2D.swift.+10.4 ptsMediumKnowledge Freshness
Record your significant design decisions. Write one short document per decision, giving its date, the situation, the decision and its consequences, and keep them together with your other design documents. A docs/adr folder with each file named by number and title is the easiest place to find them.+7.7 ptsMediumArchitecture documentation
Add a SAST step to CI running what this repository's stack ships: CodeQL's Swift pack (Swift/Xcode) — or `semgrep --config=auto`, which runs on any language — so a security regression fails the build instead of landing.+4.7 ptsMediumSecurity & performance tooling
Resolve the 3 Most significant orphaned file finding(s) in Knowledge Freshness — start with LayerNormalization.swift, QuerySeq.swift, ValueSeq.swift.+0.7 ptsLowKnowledge Freshness
Bring the 218 bodies over 15 down to 15 or less in Cognitive Complexity — start with Deconvolution2D._forwardGCGPU (cognitive 431), Deconvolution2D._forwardGCCPU (cognitive 422), Convolution2D._forwardGCGPU (cognitive 374).+2.7 ptsHighCognitive Complexity
Add a build/run (quick start) section to the root README — the first thing a newcomer needs.+2.4 ptsMediumDocumentation (README)
Resolve the 77 No direct assertions finding(s) in Test Quality — start with ImageTests.swift (22), ReduceTests.swift (16), NLPTests.swift (14).+1.4 ptsMediumTest Quality
Resolve the 2 Hotspot finding(s) in Churn × Complexity Hotspots — start with QuerySeq.swift, ValueSeq.swift.+0.3 ptsMediumChurn × Complexity Hotspots

File quality

Per-file score 0–10 — a quality signature. Of 111 files carrying findings, judged against the Preview bar: 0% slop · 25% mixed · 75% near-clean.

FileScoreBandWorst signal
REDACTED4.1MixedStatic Analysis (SAST): High: REDACTED
REDACTED5.1MixedStatic Analysis (SAST): High: REDACTED
REDACTED5.1MixedStatic Analysis (SAST): High: REDACTED
Sources/GrAIdient/Layer2D/Deconvolution2D.swift5.5MixedCyclomatic Complexity: Deconvolution2D._forwardGCGPU (cyclomatic 72)
Sources/GrAIdient/Layer2D/Base/LayerOutput2D.swift5.5MixedCyclomatic Complexity: LayerOutput2D.checkGroundTruthGPU (cyclomatic 19)
Sources/GrAIdient/Layer2D/Normalize2D.swift5.5MixedCognitive Complexity: Normalize122D.backwardCPU (cognitive 66)
Sources/GrAIdient/Layer2D/VQ2D.swift5.5MixedCognitive Complexity: VQGrad2D.forwardCPU (cognitive 58)
Sources/GrAIdient/Layer2D/BN2D.swift5.5MixedCognitive Complexity: BN2D._forwardGCCPU (cognitive 43)
Sources/GrAIdient/Layer2D/Transform/Flip2D.swift5.5MixedCognitive Complexity: FlipHorizontal2D.forwardGCCPU (cognitive 38)
Sources/GrAIdient/LayerSeq/LayerNormSeq.swift5.5MixedCognitive Complexity: LayerNormSeq._forwardGCCPU (cognitive 34)
Sources/GrAIdient/Layer2D/AdaIN.swift5.5MixedCognitive Complexity: AdaIN.forwardGCCPU (cognitive 29)
Sources/GrAIdient/Layer1D/Base/LayerOutput1D.swift5.5MixedCode Duplication: Edited copy of a member (23 corresponding lines)
Sources/GrAIdient/Layer2D/Input2D.swift5.5MixedCognitive Complexity: Input2D.backwardCPU (cognitive 23)
Sources/GrAIdient/Core/Function/Activation.swift5.5MixedCode Duplication: Edited copy of a member (15 corresponding lines)
Sources/GrAIdient/Layer1D/Input1D.swift5.5MixedCode Duplication: Edited copy of a member (11 corresponding lines)
Sources/GrAIdient/Layer2D/LayerCAM2D.swift5.6MixedCognitive Complexity: LayerCAM2D.forwardCPU (cognitive 27)
Sources/GrAIdient/LayerSeq/SoftmaxSeq.swift5.6MixedCognitive Complexity: SoftmaxSeq.forwardGCCPU (cognitive 45)
Sources/GrAIdient/LayerSeq/RMSNormSeq.swift5.6MixedCognitive Complexity: RMSNormSeq._forwardGCCPU (cognitive 34)
Sources/GrAIdient/Layer2D/Base/LayerInput2D.swift5.6MixedCognitive Complexity: LayerInput2D.checkInputCPU (cognitive 33)
Sources/GrAIdient/Core/Optimizer/OptimizerAlgorithm.swift5.6MixedCognitive Complexity: OptimizerAlgorithm.clipGradientCPU (cognitive 20)

How the grades work

Every finding carries one of four grades. Three say how serious it is. The fourth says this survey could not settle it — and it is a grade, not a gap.

Critical — 3

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 — 1233

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 — 194

Recorded, with no effect on how the codebase functions. Present so the survey is complete, not because it needs doing.

Could not be resolved — 29

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 33 evaluated dimensions are computed by tools and static analysis; no language model sets or judges any of them. Overall confidence is 0.8, 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 — 33 dimensions across the health lenses
D1D2D3D4D5D6D10D13D14D15D17D19D28D29D30D34D35D43AX10AX3AX4AX6AX8AX9M1M2M3M4P1P10P3P6X3

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
  1. 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, 1424 of 1430 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.)
  2. Is there a tool behind the number? Every score below names the method that produced it: Roslyn, git or a scanner, not a narrative.
  3. 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.

MethodBacksVersionEvaluator
Roslyn static analysisComplexity, cohesion, coupling, dead code, API surface, layering5.3.0✓ deterministic
Native secret scannerHardcoded secrets / credentials1.0.0✓ deterministic
Canine Code Analyzer duplication detector (in-process)Code duplication1.0.0✓ deterministic
Coverage (coverlet / dotnet-coverage)Line & branch coverage10.0.400✓ deterministic
NuGet / dotnetOutdated, vulnerable & deprecated dependencies10.0.400✓ deterministic
git / LibGit2SharpChurn hotspots, knowledge concentration, history2.43.0 · 0.31.0✓ deterministic
gitleaks · semgrep · trivySecrets in history, SAST, CVEs, IaC & container, PII / GDPR1.86.0 · 0.69.3✓ deterministic

Every finding is locatable in findings.md. Run 01a1e903-a87c-76bc-8881-2c318bc0b067.

The exact command behind every deep-scan dimension — tool, version, invocation and retained raw output — is in Appendix B — Reproduction & audit trail.

Run transparency — what happened this run

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.
  • D10 Test Quality — 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. The 145 test(s) behind this row are the ones the code-model census could read, and this repository also carries at least 26 test source file(s) (.py) that it cannot: it reads the test types the .swift frontend declared, so a suite in any other language is invisible to it. Skipped tests, zero-assertion tests and the other quality signals on this row are UNMEASURED in that suite — their absence from the counts above is a gap in this analyzer's language coverage, not a finding that those tests are sound.
  • 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, .py) and this repository declares a SwiftPM test suite (GrAIdient), 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 — 1 SwiftPM declaration(s) across 1 `Package.swift` and 1 committed pin(s) were read for PINNING discipline (1 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 — 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 132 commit(s) sampled, automation and bot accounts excluded). One of them holds 98% of the history; the other 1 hold 2% 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 — 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. 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)` (54026 LoC, 235 module-visible types across 16 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.
  • 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, Java and Rust source only, and no C# was loaded and no JavaScript/TypeScript, Python, Dart, Ruby, Scala, Kotlin, Java 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, Java, Python, Dart, Ruby, Scala, Kotlin and Rust source only, and no C# was loaded and no JavaScript/TypeScript, Java, 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, Rust and Elixir source only, and no C# was loaded and no JavaScript/TypeScript, Java, Kotlin, Dart, Ruby, Scala, PHP, Rust 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.
  • 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#, Rust 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, Kotlin and PHP 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.
  • 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.
  • D19 Documentation Quality: Documentation quality publishes two things only: a runnable or packaged unit with no example, and a multi-project root README that maps none of its parts. It does not judge clarity, and its other checks (overview, licence, boilerplate, structure, empty sections, XML-doc coverage) are withheld after adjudication: their candidates are counted in the card's gaps, not shown as rows. A false statement in a document is M4's; units are .NET projects only.
  • D28 Secrets (history): Secret-history scanning sweeps the git log for known patterns — a secret that predates the available history, or never matched a signature, is not found (clean means "nothing matched in the history we can see").
  • D29 Static Analysis (SAST): SAST findings are pattern-based (semgrep) — it finds classes of bug it has rules for; logic flaws, auth/authorization gaps and issues needing runtime context are out of reach (and clean means "no rule matched").
  • D30 Dependency Vulnerabilities: CVE matching depends on accurate package/version metadata and on the advisory databases — a vulnerability with no published advisory, or in code not declared as a dependency, is not seen. Coverage needs a RESOLVED graph: an unpinned requirements.txt, or a pom without a resolved build, yields partial coverage rather than a clean verdict. An ecosystem the analyzer cannot scan is reported as unmeasured, never as clean.
  • D34 Knowledge Freshness: Freshness is decayed commit RECENCY, not comprehension — code read often but rarely committed reads as orphaned, and stable code that genuinely needs no changes is penalised the same as forgotten code; bot/squash commits distort it like the bus factor.
  • D35 Change Coupling: Change coupling is co-change in COMMITS — files split across separate commits, or coupled only through a shared config/build step, read as uncoupled, and a sweeping commit (rename/format) is excluded so it doesn't couple everything. It shows that files change together, not WHY: a high coupling can be a healthy cohesive pair as readily as a hidden leak.
  • D43 Malicious Dependencies: Only packages some vulnerability database has already NAMED as malicious are seen — a compromise published in the last hours, or never reported at all, is invisible here, and this dimension reading 10 is not evidence that a dependency is trustworthy. There is no typosquat or dependency-confusion analysis: a package nobody has reported is simply absent from the feeds. Coverage is the dependency scan's: an ecosystem that could not be scanned is disclosed as unmeasured, never as clean.
  • 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.

Dimensions

D1 · Cyclomatic Complexity6.2 / 10Adequate✓ Tool-verified

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.

Maturity: Documented → Verified → Prevented · effective 6.2 / 10 · rule-coverage 100% · ceiling Prevented

55 method(s) exceeded the cyclomatic complexity threshold of 15; the worst was Deconvolution2D._forwardGCGPU at 72.

Deconvolution2D._forwardGCGPU (cyclomatic 72)Sources/GrAIdient/Layer2D/Deconvolution2D.swift:473
Convolution2D._forwardGCGPU (cyclomatic 64)Sources/GrAIdient/Layer2D/Convolution2D.swift:1038
Deconvolution2D._forwardGCCPU (cyclomatic 63)Sources/GrAIdient/Layer2D/Deconvolution2D.swift:268
Convolution2D._forwardGCCPU (cyclomatic 55)Sources/GrAIdient/Layer2D/Convolution2D.swift:842
FullyConnectedPatch._forwardGCCPU (cyclomatic 34)Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:527

+ 50 more group(s) — more in Appendix A; the complete list is findings.md.

What to do

  1. Bring the 6 bodies over 30 down to 30 or less in Cyclomatic Complexity — start with Deconvolution2D._forwardGCGPU (cyclomatic 72), Convolution2D._forwardGCGPU (cyclomatic 64), Deconvolution2D._forwardGCCPU (cyclomatic 63). — 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.2 to about 7.2/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.

D2 · Cognitive Complexity2.0 / 10Critical✓ Tool-verified

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.

Maturity: Documented → Verified → Prevented · effective 2.0 / 10 · rule-coverage 100% · ceiling Prevented

218 method(s) exceeded the cognitive complexity threshold of 15; the worst was Deconvolution2D._forwardGCGPU at 431.

Deconvolution2D._forwardGCGPU (cognitive 431)Sources/GrAIdient/Layer2D/Deconvolution2D.swift:473
Deconvolution2D._forwardGCCPU (cognitive 422)Sources/GrAIdient/Layer2D/Deconvolution2D.swift:268
Convolution2D._forwardGCGPU (cognitive 374)Sources/GrAIdient/Layer2D/Convolution2D.swift:1038
Convolution2D._forwardGCCPU (cognitive 365)Sources/GrAIdient/Layer2D/Convolution2D.swift:842
FullyConnectedPatch._forwardGCCPU (cognitive 192)Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:527

+ 213 more group(s) — more in Appendix A; the complete list is findings.md.

What to do

  1. Bring the 218 bodies over 15 down to 15 or less in Cognitive Complexity — start with Deconvolution2D._forwardGCGPU (cognitive 431), Deconvolution2D._forwardGCCPU (cognitive 422), Convolution2D._forwardGCGPU (cognitive 374). — 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 218 together lifts Cognitive Complexity from 2.0 to about 10.0/10, projected with the scoring formula itself and assuming each lands exactly at 15.

Detailed fixes: d2_recommendation.md · top locations in Appendix A, every location in findings.md.

D3 · God Classes8.9 / 10Strong✓ Tool-verified

What it measures: Over-large classes that try to do too much ("god classes").

Method: God-class detection by line and method-count thresholds per logical type (partial classes unified), filtered for generated code and registration/contract false positives. Deterministic.

Maturity: Documented → Verified → Prevented · effective 8.9 / 10 · rule-coverage 100% · ceiling Prevented

26 god class(es) detected.

FileTooLong: Layer/LayerNormalization.swift · ×10Sources/GrAIdient/Core/Layer/LayerNormalization.swift
ClassTooLong: Convolution2D · ×9Sources/GrAIdient/Layer2D/Convolution2D.swift:26
MethodTooLong: Deconvolution2D._forwardGCGPU · ×6Sources/GrAIdient/Layer2D/Deconvolution2D.swift:473
TooManyMethods: Convolution2DSources/GrAIdient/Layer2D/Convolution2D.swift:26

What to do

  1. Resolve the 10 FileTooLong finding(s) in God Classes — start with LayerNormalization.swift, ValueSeq.swift, QuerySeq.swift. — One of this dimension's main actionable groups (10 warning-level).
  2. Resolve the 9 ClassTooLong finding(s) in God Classes — start with Convolution2D.swift, FullyConnectedPatch.swift, FullyConnectedSeq.swift. — One of this dimension's main actionable groups (9 warning-level).
  3. Resolve the 6 MethodTooLong finding(s) in God Classes — start with Convolution2D.swift (3), Deconvolution2D.swift (2), FullyConnectedPatch.swift. — One of this dimension's main actionable groups (6 warning-level).

Detailed fixes: d3_recommendation.md · top locations in Appendix A, every location in findings.md.

D4 · Code Duplication0.0 / 10Critical✓ 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.

Maturity: Documented → Verified → Prevented · effective 0.0 / 10 · rule-coverage 100% · ceiling Verified

645 duplicated block group(s) detected. 46.6 % of the production lines (25,158 of 54,026) are in a reported copy. A further 249 rows report members as variants of one another; the share counts each copied line once, however many rows cite it.

Duplicated block (9 lines × 2) · ×27Sources/GrAITestsUtils/Trainer.swift:331
Duplicated block (12 lines × 2) · ×25Sources/GrAIdient/Core/Function/Activation.swift:132
Duplicated block (10 lines × 2) · ×22Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1332
Duplicated block (13 lines × 2) · ×19Sources/GrAIdient/Core/Layer/LayerNormalization.swift:2228
Duplicated block (11 lines × 2) · ×18Sources/GrAITestsUtils/Trainer.swift:848

+ 345 more group(s) — more in Appendix A; the complete list is findings.md.

What to do

  1. Resolve the 27 Duplicated block (9 lines × 2) finding(s) in Code Duplication — start with LayerNormSeq.swift (4), Constant2D.swift (3), ResizeBilinearCrop.swift (3). — One of this dimension's main actionable groups (27 warning-level).
  2. Resolve the 25 Duplicated block (12 lines × 2) finding(s) in Code Duplication — start with ConcatSeq.swift (3), QuerySeq.swift (3), Constant1D.swift (2). — One of this dimension's main actionable groups (25 warning-level).
  3. Resolve the 22 Duplicated block (10 lines × 2) finding(s) in Code Duplication — start with Convolution2D.swift (3), QuerySeq.swift (3), LayerNormalization.swift (2). — One of this dimension's main actionable groups (22 warning-level).

Detailed fixes: d4_recommendation.md · top locations in Appendix A, every location in findings.md.

D5 · Coupling8.0 / 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.

Maturity: Documented → Verified → Prevented · effective 8.0 / 10 · rule-coverage 100% · ceiling Prevented

4 production modules (Python+SwiftPM), 0 dependency cycle(s), 0 unstable depended-on module(s). Read from the build's own module declarations; 1 module(s) off the main sequence, with abstractness counted on 2 of the 4 (the rest declare no modelled class or interface, export only macros, declare types in source no model reads, or have no source directory of their own).

Off the main sequence: GrAIdient

What to do

  1. Resolve the 1 Off the main sequence finding(s) in Coupling. — One of this dimension's main actionable groups (1 warning-level).

Detailed fixes: d5_recommendation.md · top locations in Appendix A, every location in findings.md.

D6 · Cohesion (LCOM4)7.7 / 10Strong✓ Tool-verified

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.

Maturity: Documented → Verified → Prevented · effective 7.7 / 10 · rule-coverage 100% · ceiling Verified

22 of 117 classes have LCOM4 above 3.

Low cohesion: Model (LCOM4 10) · ×22Sources/GrAIdient/Core/Model/Model.swift:232

What to do

  1. Resolve the 22 Low cohesion finding(s) in Cohesion (LCOM4) — start with Model.swift, LayerOutput1D.swift, LayerOutput2D.swift. — One of this dimension's main actionable groups (22 warning-level).

Detailed fixes: d6_recommendation.md · top locations in Appendix A, every location in findings.md.

D10 · Test Quality9.4 / 10Stronggated by 4 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.

Maturity: Documented → Verified → Prevented · effective 9.4 / 10 · rule-coverage 100% · ceiling Prevented

4 skipped, 77 zero-assertion, no mocking-framework packages referenced (hand-written doubles or no mocking) across 145 tests (2 harness-style project(s) excluded from the assertion penalty). Measured on the .swift suite only — at least 26 test source file(s) (.py) went unread, so its test quality is unmeasured and is not in these counts.

Skipped test: testPrecision · ×4Tests/GrAITests/Layer2DTests.swift:6864
No direct assertions: test1_TrainSimpleModel · ×77Tests/GrAIExamples/AutoEncoderExample.swift:334

What to do

  1. Resolve the 77 No direct assertions finding(s) in Test Quality — start with ImageTests.swift (22), ReduceTests.swift (16), NLPTests.swift (14). — One of this dimension's main actionable groups (77 recommendation-level).
  2. Resolve the 4 Skipped test finding(s) in Test Quality — start with Layer2DTests.swift (2), NLPTests.swift (2). — One of this dimension's main actionable groups (4 warning-level).

Detailed fixes: d10_recommendation.md · top locations in Appendix A, every location in findings.md.

D13 · Secret Scanning10.0 / 10Exemplary○ Nothing flagged

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.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Prevented

Secret scan ran and found no leaked secrets.

✓ On the Gold path — maintain.

Detailed fixes: d13_recommendation.md.

D14 · License Compliance10.0 / 10Exemplary○ Nothing flagged

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.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Verified

0 of 1 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 1 — 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.

✓ On the Gold path — maintain.

Detailed fixes: d14_recommendation.md.

D15 · Churn × Complexity Hotspots9.9 / 10Stronggated by 2 serious findings✓ Tool-verified

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.

Maturity: Documented → Verified → Prevented · effective 9.9 / 10 · rule-coverage 100% · ceiling Documented

Top hotspots: Sources/GrAIdient/LayerSeq/QuerySeq.swift (4×20=80); Sources/GrAIdient/LayerSeq/ValueSeq.swift (3×18=54)

Hotspot: Sources/GrAIdient/LayerSeq/QuerySeq.swift · ×2Sources/GrAIdient/LayerSeq/QuerySeq.swift:1350

What to do

  1. Resolve the 2 Hotspot finding(s) in Churn × Complexity Hotspots — start with QuerySeq.swift, ValueSeq.swift. — One of this dimension's main actionable groups (2 warning-level).

Detailed fixes: d15_recommendation.md · top locations in Appendix A, every location in findings.md.

D17 · Explicit Debt10.0 / 10Stronggated by 4 serious findings✓ Tool-verified

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.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Prevented

4 deducted task-comment markers across 54026 LoC (0.0/KLoC) → score 10.0. Task comments only: this repository's language is read without a compiler, so D17's suppression, dead-code and commented-out-code arms did not run and this score counts fewer marker kinds than a .NET repository's would.

TodoComment · ×4Tests/GrAIExamples/Base/python_lib/nlp/model.py:137

What to do

  1. Resolve the 4 TodoComment finding(s) in Explicit Debt — start with model.py (2), QuerySeq.swift, ValueSeq.swift. — One of this dimension's main actionable groups (4 warning-level).

Detailed fixes: d17_recommendation.md · top locations in Appendix A, every location in findings.md.

D19 · Documentation Quality10.0 / 10Exemplary○ Nothing flagged

What it measures: Whether the project's documentation is clear, complete, and useful.

Method: Every README, docs/ document and root guide parsed by its markup and measured in Unicode letters. Published: a runnable or packaged .NET project whose README (or a document it links, or a root guide) shows no example, and a root README naming none of three or more projects. Overview, licence, boilerplate, wall-of-text, empty-section and XML-doc rows are measured and withheld (counted in gaps) after adjudication. Deterministic, exhaustive, advisory.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Documented

1 of 1 documentation facets pass in full. 16 document(s) read across 1 unit(s).

✓ On the Gold path — maintain.

Detailed fixes: d19_recommendation.md.

D28 · Secrets (history)10.0 / 10Exemplary○ Nothing flagged

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.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Documented

gitleaks scanned the full history AND the current working tree and found no secrets.

✓ On the Gold path — maintain.

Detailed fixes: d28_recommendation.md.

D29 · Static Analysis (SAST)8.6 / 10Adequategated by 3 critical findings✓ Tool-verified

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).

Maturity: Documented → Verified → Prevented · effective 8.6 / 10 · rule-coverage 100% · ceiling Documented

6 finding(s): 0 critical, 3 high, 3 medium, 0 low. 3 unpinned-GitHub-Actions row(s) are reported here but scored by D36 (supply-chain provenance), which measures that posture as `pinned_actions` — one pinning decision is charged once, not once per lens.

REDACTED
REDACTED
REDACTED

What to do

  1. Resolve the 2 REDACTED finding(s) in Static Analysis (SAST) — start with REDACTED (2). — One of this dimension's main actionable groups (2 warning-level).
  2. Resolve the 1 REDACTED finding(s) in Static Analysis (SAST) — start with REDACTED. — One of this dimension's main actionable groups (1 warning-level).
  3. No action in Static Analysis (SAST) — all 3 REDACTED finding(s) are reported here at file:line but scored by D36 (supply-chain provenance), so none is charged to this dimension. — One of this dimension's main actionable groups (3 issue-level, 0 of them charged here).

Detailed fixes: d29_recommendation.md · top locations in Appendix A, every location in findings.md.

D30 · Dependency Vulnerabilities10.0 / 10Exemplary○ Nothing flagged

What it measures: Whether any dependency has a known published vulnerability (CVE), direct or transitive, in ANY ecosystem the repository declares — Dart pub, Elixir and Erlang via Hex, Go modules, Java and Kotlin via Maven/Gradle, JavaScript/npm, .NET/NuGet, PHP/Composer, Python/PyPI, RubyGems, Rust/Cargo and Swift.

Method: Dependency-CVE scan across every ecosystem the repository declares, scored ONCE. Three sources are unioned and deduplicated by advisory identity (rule id + alias closure, CVE<->GHSA) scoped to package+version, keeping the worst severity: `osv-scanner --recursive` over osv.dev for Dart pub, Elixir/Hex (and Erlang, whose `rebar.lock` syft first converts to a CycloneDX SBOM the scanner reads, with rows attributed back to the lock), Go, Java and Kotlin via Maven/Gradle (and Scala, whose sbt build's pinned direct declarations are written into a CycloneDX SBOM the scanner reads, with rows attributed back to the build file), npm, PHP/Composer, Python/PyPI, RubyGems, Rust/Cargo and Swift; `trivy fs --scanners vuln` for npm lockfiles; and `dotnet list package --vulnerable --include-transitive` for NuGet (with per-advisory collapse of the project x target-framework fan-out), plus a DECLARED-dependency arm that resolves a published gem's gemspec against rubygems.org where no Gemfile.lock is committed. `SeverityScore(c,h,m,l, normalizer 8.0)`. NotApplicable only when NO ecosystem is readable; if any applicable ecosystem could not be scanned the findings are REPORTED and the score is withheld. Supersedes the npm and OSV arms, retired 2026-09-05. Advisory since rubric-2026.11.2 (CAI decision 0006): every row is a match against a vulnerability database that changes daily, so the reading is shown and never moves a scored dimension, lens or the headline.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Documented

No known-vulnerable dependencies in any ecosystem this repository declares.

✓ On the Gold path — maintain.

Detailed fixes: d30_recommendation.md.

D34 · Knowledge Freshness0.0 / 10Critical✓ Tool-verified

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.

Maturity: Documented → Verified → Prevented · effective 0.0 / 10 · rule-coverage 100% · ceiling Documented

101 of 101 significant source file(s) are orphaned — their living knowledge has decayed to nothing, so no one currently understands them. The largest is Sources/GrAIdient/Core/Layer/LayerNormalization.swift. Counted over 101 of the 105 production source files in this repository: the rest are under the ~2,400-byte size floor this dimension measures over.

Orphaned file · ×98Sources/GrAIdient/Layer2D/Convolution2D.swift:1
Most significant orphaned file · ×3Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1
Dormant codebase

What to do

  1. Resolve the 98 Orphaned file finding(s) in Knowledge Freshness — start with Convolution2D.swift, FullyConnectedPatch.swift, VQ2D.swift. — One of this dimension's main actionable groups (98 recommendation-level).
  2. Resolve the 3 Most significant orphaned file finding(s) in Knowledge Freshness — start with LayerNormalization.swift, QuerySeq.swift, ValueSeq.swift. — One of this dimension's main actionable groups (3 recommendation-level).
  3. Resolve the 1 Dormant codebase finding(s) in Knowledge Freshness. — One of this dimension's main actionable groups (1 recommendation-level).

Detailed fixes: d34_recommendation.md · top locations in Appendix A, every location in findings.md.

D35 · Change Coupling10.0 / 10Exemplary✓ Tool-verified

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.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Documented

No strong hidden change-coupling between production files.

✓ On the Gold path — maintain.

Detailed fixes: d35_recommendation.md.

D43 · Malicious Dependencies10.0 / 10Exemplary✓ Tool-verified

What it measures: Whether any dependency the repository declares is published as MALICIOUS rather than merely vulnerable — a package that is an attacker's work, in any ecosystem osv-scanner reads. Reported apart from D30 because the answer is binary: there is no safe version to upgrade to, and the fix is to remove the package and rotate every credential it could have read.

Method: The same dependency scan D30 reads, partitioned on the scanner's own classification rather than rescanned: a row is MALICIOUS when its id is in the `MAL-` space (the ossf/malicious-packages feed) OR its `database_specific.cwe_ids` carries `CWE-506` ("Embedded Malicious Code"). Both channels are structural; the summary text is deliberately NOT read, because a malicious-package record whose summary says only "Critical severity vulnerability" is a real shape ([GHSA redacted]) and a text matcher misses it. Scored BINARY: any surviving row is 0, whatever its severity and however many CVEs sit beside it — a hostile dependency is not a quantity. Applicability and degradation are D30's: NotApplicable only when no ecosystem is readable, and an unscannable ecosystem degrades rather than reading clean. Advisory since rubric-2026.11.2 (CAI decision 0006): the malicious-package feed is a database that changes daily, so the reading is shown and never moves a scored dimension, lens or the headline.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Documented

No dependency in any ecosystem this repository declares is published as malicious.

✓ On the Gold path — maintain.

Detailed fixes: d43_recommendation.md.

Frontend & cross-cutting dimensions

R = React/JS · M = Maturity · P = Readiness.

AX10 · Code composition10.0 / 10Exemplary✓ Tool-verified

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.

AX3 · Project dependency cycles10.0 / 10Exemplary✓ Tool-verified

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.

AX4 · Dependency direction10.0 / 10Exemplary✓ Tool-verified

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.

AX6 · Interface segregation10.0 / 10Exemplary✓ Tool-verified

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.

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.

AX9 · CQS / query purity10.0 / 10Exemplary✓ Tool-verified

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.

M1 · Documentation (README)7.3 / 10Strong✓ Tool-verified

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.

What to do

  • Add a build/run (quick start) section to the root README — the first thing a newcomer needs.
M2 · Architecture documentation2.0 / 10Weak✓ Tool-verified

Maturity · Maturity — Whether key decisions (ADRs) and the high-level shape (C4/diagrams) are written down.

Method: Filesystem scan: ADR folder/naming conventions or content, plus Mermaid/PlantUML/C4/architecture.md discovery. Exhaustive, deterministic.

  • No Architecture Decision Records found — no conventional ADR directory, no numbered `NNNN-title` documents in any markup this check reads, and nothing ADR-shaped by content. Design rationale recorded elsewhere (a design-notes tree, a mailing list, pull-request discussion) is not visible to this check and is not re-findable per decision, so a future maintainer cannot ask why one choice was made and get an answer.

What to do

  • Record your significant design decisions. Write one short document per decision, giving its date, the situation, the decision and its consequences, and keep them together with your other design documents. A docs/adr folder with each file named by number and title is the easiest place to find them.
M3 · Folder & project structure10.0 / 10Exemplary✓ Tool-verified

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.

M4 · Documentation accuracy10.0 / 10Exemplary○ Nothing flagged

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.

P1 · CI/CD gates10.0 / 10Exemplary○ Nothing flagged

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.

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.

P3 · Security & performance tooling0.0 / 10Critical✓ Tool-verified

Readiness · Readiness — Whether SAST, secret/dependency scanning and performance benchmarking are wired in (presence, not runtime).

Method: Filesystem scan: SAST configuration, dependency-update automation, secret scanning, and a benchmark harness or benchmark step — in this repository's own ecosystem. Exhaustive, deterministic.

  • No static application security testing detected. For this repository's stack, add CodeQL's Swift pack (Swift/Xcode) (or `semgrep --config=auto`, which runs on any language) as a CI step. What was searched, so you can tell an absence from a miss: the 3 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. — REDACTED:4

What to do

  • Add a SAST step to CI running what this repository's stack ships: CodeQL's Swift pack (Swift/Xcode) — or `semgrep --config=auto`, which runs on any language — so a security regression fails the build instead of landing.
  • Enable Dependabot/Renovate or a dependency-review gate.
  • Add gitleaks/trufflehog in CI to block PRs that introduce committed secrets.
P6 · Release Hygiene10.0 / 10Exemplary✓ Tool-verified

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.

X3 · Exception handling10.0 / 10Exemplary○ Nothing flagged

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.

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.

LensScoreRatingImpact
Code Health75.2Adequate — gated by D2, D4Capped at Fair by a Critical contributor — resolve it before relying on this lens.
Architecture95.7ExemplaryStrongest area.
Maturity56.4Adequate — gated by D34, M2Capped at Fair by a Critical contributor — resolve it before relying on this lens.
Readiness68.3Adequate — gated by P3Capped at Fair by a Critical contributor — resolve it before relying on this lens.
Security92.8Checked 3 of 8Solid.
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.

  • D36 Supply-chain Provenance & Signing — 3 observation(s) recorded · The CI pipeline publishes no artifact — no package publish, container push or release with files to download. Supply-chain provenance, signing and an SBOM describe a PUBLISHED artifact for the people who obtain it, so there is nothing to attest here; a deployment of the service itself publishes nothing for anyone else to verify. Add them to the release pipeline when this repo starts publishing artifacts (a package, a container image, or a release with downloadable files). Build integrity and workflow-token hygiene are reported below: they describe what the CI runs and the token it runs with, neither of which is affected by whether the pipeline ships an artifact.
  • X10 Duplicated predicate — 11 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 — 78 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 — 1 SwiftPM declaration(s) across 1 `Package.swift` and 1 committed pin(s) were read for PINNING discipline (1 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.
  • D20 ADR Quality — N/A — ADRs are expected on deployable products with a user-facing host, not consumed libraries; no ADR log is required here.
  • D21 Naming Consistency — D21 withholds its sibling role token rows: 1 candidate(s) found and not reported.
  • 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 .swift, which was left unread. Not scored: this is a gap in the analyzer, not a verdict about this repository.
  • D25 ADR Conformance — no ADRs to check
  • 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.
  • D27 Navigability — symbol resolution incomplete — navigability not assessed
  • 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) — 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.
  • 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.
  • D44 Platform End-of-Life — Platform end-of-life not assessed — this repository declares no platform this pass reads
  • D7 Architectural Integrity — no checkable ADRs, and no project-reference graph for the cycle pass to read — so this dimension makes no claim about dependency cycles in either direction (where this repository's language has an import-cycle lens, cycles are reported there). Architectural integrity not assessed
  • D8 Code Coverage — Coverage not measured — Swift suite
  • DM1 Domain Modelling — not scored — this repository shows only 1 of the 3 signals this lens looks for (2 value object(s))
  • ED2 Event/command shape — not scored — deciding whether a command has more than one competing handler requires resolving the call graph, and this analysis resolves a call's owner only where the receiver's type is written down in the source. Reported as guidance rather than measured
  • ED5 Idempotency — 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 — Reported, not scored — and nothing was matched here. The coverage check applies to any stack, and the automatic-re-run check to any GitHub-Actions workflow, but the checks for excluded tests, skipped tests and sleep-based synchronisation currently recognise only some ecosystems' test-runner idioms, so on a repository built with another stack the zeros below mean 'not checked', not 'clean'.
  • P2 Observability — This repository's Swift source (1 module(s), 106 file(s) read) declares no entry point and bootstraps no server, and nothing here deploys a service — it is a library, run inside whatever hosts it, so production observability (structured logging, tracing/metrics, health checks) is N/A. If it grows a binary or a service, the dimension reactivates.
  • P7 Outbound HTTP resilience — not applicable — no HTTP server, API framework or worker entry point was found in the 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.
  • PF3 Async & latency hygiene — Not applicable: this repository declares no async functions, so there is no asynchronous code for a blocking call to stall.
  • 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
  • X19 Unrestored process-global state — not applicable — the code was read and holds no site of this kind, so there is nothing for this check to judge
  • 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.
  • X28 Index access outside its own emptiness guard — not applicable — the code was read and holds no site of this kind, so there is nothing for this check to judge
  • 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.
  • X7 Silent fallback defaults — Advisory — this card reports evidence and never carries a score, so there is nothing missing here.
  • X9 Subsumed condition operand — Advisory — this card reports evidence and never carries a score, so there is nothing missing here.

Appendix A — Findings (grouped)

The findings behind the scores, grouped by severity, then by dimension and kind. The high-severity issues are enumerated in full below; items per group are capped at 25 with any overflow stated explicitly per group, never silently truncated. The complete machine-readable list of every finding (all severities) is the companion findings.md in this report's bundle.

Critical — 3 finding(s)
D29 · Static Analysis (SAST) · REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
Serious — 1233 finding(s)
D4 · Code Duplication · Duplicated block (9 lines × 2) · ×27
  • Duplicated block (9 lines × 2) Sources/GrAITestsUtils/Trainer.swift:331 — Sources/GrAITestsUtils/Trainer.swift:331-339 | Sources/GrAITestsUtils/Trainer.swift:621-629 — both copies are in the same file, so extract the 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/GrAIdient/Core/Layer/LayerNormalization.swift:2584 — Sources/GrAIdient/Core/Layer/LayerNormalization.swift:2584-2592 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:3159-3167 — both copies are in the same file, so extract the 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/GrAIdient/Layer1D/BCE1D.swift:116 — Sources/GrAIdient/Layer1D/BCE1D.swift:116-124 | Sources/GrAIdient/Layer1D/BCE1D.swift:160-168 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/Layer1D/BCE1D.swift:116` 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 (9 lines × 2) Sources/GrAIdient/Layer1D/FullyConnected.swift:1043 — Sources/GrAIdient/Layer1D/FullyConnected.swift:1043-1051 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:1102-1110 — before extracting anything, compare `Sources/GrAIdient/Layer1D/FullyConnected.swift` and `Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift` as WHOLE FILES: this scan already matched 32 separate duplicated blocks between them, totalling at least 473 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (9 lines × 2) Sources/GrAIdient/Layer2D/AdaIN.swift:588 — Sources/GrAIdient/Layer2D/AdaIN.swift:588-596 | Sources/GrAIdient/Layer2D/InstanceNorm2D.swift:663-671 — before extracting anything, compare `Sources/GrAIdient/Layer2D/AdaIN.swift` and `Sources/GrAIdient/Layer2D/InstanceNorm2D.swift` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 92 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (9 lines × 2) Sources/GrAIdient/Layer2D/AdaIN.swift:644 — Sources/GrAIdient/Layer2D/AdaIN.swift:644-652 | Sources/GrAIdient/Layer2D/InstanceNorm2D.swift:701-709 — before extracting anything, compare `Sources/GrAIdient/Layer2D/AdaIN.swift` and `Sources/GrAIdient/Layer2D/InstanceNorm2D.swift` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 92 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (9 lines × 2) Sources/GrAIdient/Layer2D/Constant2D.swift:167 — Sources/GrAIdient/Layer2D/Constant2D.swift:167-175 | Sources/GrAIdient/Layer2D/Constant2D.swift:216-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/GrAIdient/Layer2D/Constant2D.swift:167` 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/GrAIdient/Layer2D/Constant2D.swift:213 — Sources/GrAIdient/Layer2D/Constant2D.swift:213-221 | Sources/GrAIdient/Layer2D/Input2D.swift:238-246 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/Layer2D/Constant2D.swift:213` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 2) Sources/GrAIdient/Layer2D/Constant2D.swift:353 — Sources/GrAIdient/Layer2D/Constant2D.swift:353-361 | Sources/GrAIdient/Layer2D/Constant2D.swift:397-405 — both copies are in the same file, so extract the 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/GrAIdient/Layer2D/Constant2D.swift:407` calls `download` and `Sources/GrAIdient/Layer2D/Constant2D.swift:363` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (9 lines × 2) Sources/GrAIdient/Layer2D/Convolution2D.swift:1667 — Sources/GrAIdient/Layer2D/Convolution2D.swift:1667-1675 | Sources/GrAIdient/Layer2D/Convolution2D.swift:1746-1754 — both copies are in the same file, so extract the 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/GrAIdient/Layer2D/Convolution2D.swift:1667` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Sources/GrAIdient/Layer2D/Convolution2D.swift:1666` calls `setBytes` and `Sources/GrAIdient/Layer2D/Convolution2D.swift:1745` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (9 lines × 2) Sources/GrAIdient/Layer2D/Multiply2D.swift:238 — Sources/GrAIdient/Layer2D/Multiply2D.swift:238-246 | Sources/GrAIdient/Layer2D/Sum2D.swift:160-168 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Multiply2D.swift` and `Sources/GrAIdient/Layer2D/Sum2D.swift` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 100 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/GrAIdient/Layer2D/Multiply2D.swift:238` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 2) Sources/GrAIdient/Layer2D/Normalize2D.swift:287 — Sources/GrAIdient/Layer2D/Normalize2D.swift:287-295 | Sources/GrAIdient/Layer2D/SelfCorrelate2D.swift:270-278 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Normalize2D.swift` and `Sources/GrAIdient/Layer2D/SelfCorrelate2D.swift` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 74 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (9 lines × 2) Sources/GrAIdient/Layer2D/SimilarityError2D.swift:379 — Sources/GrAIdient/Layer2D/SimilarityError2D.swift:379-387 | Sources/GrAIdient/Layer2D/SimilarityError2D.swift:475-483 — both copies are in the same file, so extract the 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/GrAIdient/Layer2D/SimilarityError2D.swift:379` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 2) Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:361 — Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:361-369 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift:337-345 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift` and `Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 252 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/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:361` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 2) Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:487 — Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:487-495 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift:440-448 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift` and `Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 252 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/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:487` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 2) Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:573 — Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:573-581 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:696-704 — both copies are in the same file, so extract the 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/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift:290 — Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift:290-298 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift:395-403 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift:290` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 2) Sources/GrAIdient/LayerSeq/EmbeddingSeq.swift:686 — Sources/GrAIdient/LayerSeq/EmbeddingSeq.swift:686-694 | Sources/GrAIdient/LayerSeq/EmbeddingSeq.swift:719-727 — both copies are in the same file, so extract the 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/GrAIdient/LayerSeq/LayerNormSeq.swift:637 — Sources/GrAIdient/LayerSeq/LayerNormSeq.swift:637-645 | Sources/GrAIdient/LayerSeq/RMSNormSeq.swift:651-659 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/LayerNormSeq.swift` and `Sources/GrAIdient/LayerSeq/RMSNormSeq.swift` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 276 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (9 lines × 2) Sources/GrAIdient/LayerSeq/LayerNormSeq.swift:672 — Sources/GrAIdient/LayerSeq/LayerNormSeq.swift:672-680 | Sources/GrAIdient/LayerSeq/RMSNormSeq.swift:686-694 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/LayerNormSeq.swift` and `Sources/GrAIdient/LayerSeq/RMSNormSeq.swift` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 276 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (9 lines × 2) Sources/GrAIdient/LayerSeq/LayerNormSeq.swift:706 — Sources/GrAIdient/LayerSeq/LayerNormSeq.swift:706-714 | Sources/GrAIdient/LayerSeq/RMSNormSeq.swift:720-728 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/LayerNormSeq.swift` and `Sources/GrAIdient/LayerSeq/RMSNormSeq.swift` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 276 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (9 lines × 2) Sources/GrAIdient/LayerSeq/QuerySeq.swift:1301 — Sources/GrAIdient/LayerSeq/QuerySeq.swift:1301-1309 | Sources/GrAIdient/LayerSeq/RoPESeq.swift:213-221 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/QuerySeq.swift` and `Sources/GrAIdient/LayerSeq/RoPESeq.swift` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 52 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (9 lines × 2) Sources/GrAIdient/LayerSeq/ValueSeq.swift:499 — Sources/GrAIdient/LayerSeq/ValueSeq.swift:499-507 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1100-1108 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (9 lines × 2) Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:383 — Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:383-391 | Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:688-696 — both copies are in the same file, so extract the 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/GrAIdient/Core/Optimizer/OptimizerImpl.swift:383` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 2) Sources/GrAIdient/Layer2D/BN2D.swift:693 — Sources/GrAIdient/Layer2D/BN2D.swift:693-701 | Sources/GrAIdient/Layer2D/InstanceNorm2D.swift:617-625 — before extracting anything, compare `Sources/GrAIdient/Layer2D/BN2D.swift` and `Sources/GrAIdient/Layer2D/InstanceNorm2D.swift` as WHOLE FILES: this scan already matched 21 separate duplicated blocks between them, totalling at least 320 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.
  • + 2 more in this group — see findings.md.
D4 · Code Duplication · Duplicated block (12 lines × 2) · ×25
  • Duplicated block (12 lines × 2) Sources/GrAIdient/Core/Function/Activation.swift:132 — Sources/GrAIdient/Core/Function/Activation.swift:132-143 | Sources/GrAIdient/Core/Function/Activation.swift:177-188 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/Core/Function/Activation.swift:132` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 2) Sources/GrAIdient/Core/Layer/LayerNormalization.swift:2276 — Sources/GrAIdient/Core/Layer/LayerNormalization.swift:2276-2287 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:2915-2926 — both copies are in the same file, so extract the 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/GrAIdient/Core/Layer/LayerNormalization.swift:2276` 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/GrAIdient/Layer1D/Constant1D.swift:451 — Sources/GrAIdient/Layer1D/Constant1D.swift:451-462 | Sources/GrAIdient/Layer1D/FullyConnected.swift:1072-1083 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Constant1D.swift` and `Sources/GrAIdient/Layer1D/FullyConnected.swift` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 51 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. 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/GrAIdient/Layer1D/Constant1D.swift:451` 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/GrAIdient/Layer1D/DotProduct1D.swift:182 — Sources/GrAIdient/Layer1D/DotProduct1D.swift:182-193 | Sources/GrAIdient/Layer1D/DotProduct1D.swift:265-276 — both copies are in the same file, so extract the 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/GrAIdient/Layer1D/DotProduct1D.swift:182` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 2) Sources/GrAIdient/Layer2D/Deconvolution2D.swift:422 — Sources/GrAIdient/Layer2D/Deconvolution2D.swift:422-433 | Sources/GrAIdient/Layer2D/Deconvolution2D.swift:659-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. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/Layer2D/Deconvolution2D.swift:422` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 2) Sources/GrAIdient/Layer2D/LayerCAM2D.swift:189 — Sources/GrAIdient/Layer2D/LayerCAM2D.swift:189-200 | Sources/GrAIdient/Layer2D/Transform/ColorJitterHSV.swift:320-331 — 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/GrAIdient/Layer2D/LayerCAM2D.swift:189` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Sources/GrAIdient/Layer2D/LayerCAM2D.swift:187` calls `setBuffer`, `setBytes` and `Sources/GrAIdient/Layer2D/Transform/ColorJitterHSV.swift:319` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (12 lines × 2) Sources/GrAIdient/Layer2D/Normalize2D.swift:149 — Sources/GrAIdient/Layer2D/Normalize2D.swift:149-160 | Sources/GrAIdient/Layer2D/Normalize2D.swift:211-222 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/Layer2D/Normalize2D.swift:149` 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/GrAIdient/Layer2D/SimilarityBatchError2D.swift:187 — Sources/GrAIdient/Layer2D/SimilarityBatchError2D.swift:187-198 | Sources/GrAIdient/Layer2D/SimilarityBatchError2D.swift:215-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/GrAIdient/Layer2D/SimilarityBatchError2D.swift:187` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 2) Sources/GrAIdient/Layer2D/SimilarityError2D.swift:549 — Sources/GrAIdient/Layer2D/SimilarityError2D.swift:549-560 | Sources/GrAIdient/Layer2D/SimilarityError2D.swift:577-588 — both copies are in the same file, so extract the 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/GrAIdient/Layer2D/SimilarityError2D.swift:549` 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/GrAIdient/Layer2D/Transform/Flip2D.swift:161 — Sources/GrAIdient/Layer2D/Transform/Flip2D.swift:161-172 | Sources/GrAIdient/Layer2D/Transform/Flip2D.swift:418-429 — both copies are in the same file, so extract the 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/GrAIdient/Layer2D/Transform/Flip2D.swift:161` it begins part-way through the construct above it, so those exact lines 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/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:199 — Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:199-210 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift:170-181 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift` and `Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 252 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/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:199` 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/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:227 — Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:227-238 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift:199-210 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift` and `Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 252 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/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:227` 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/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:240` calls `encode` and `Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift:212` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (12 lines × 2) Sources/GrAIdient/Layer2D/VQ2D.swift:528 — Sources/GrAIdient/Layer2D/VQ2D.swift:528-539 | Sources/GrAIdient/Layer2D/VQ2D.swift:1352-1363 — both copies are in the same file, so extract the 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/GrAIdient/Layer2D/VQ2D.swift:528` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 2) Sources/GrAIdient/LayerSeq/ConcatSeq.swift:133 — Sources/GrAIdient/LayerSeq/ConcatSeq.swift:133-144 | Sources/GrAIdient/LayerSeq/ConcatSeq.swift:565-576 — both copies are in the same file, so extract the 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/GrAIdient/LayerSeq/ConcatSeq.swift:133` 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/GrAIdient/LayerSeq/ConcatSeq.swift:379 — Sources/GrAIdient/LayerSeq/ConcatSeq.swift:379-390 | Sources/GrAIdient/LayerSeq/ConcatSeq.swift:806-817 — both copies are in the same file, so extract the 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/GrAIdient/LayerSeq/ConcatSeq.swift:379` 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/GrAIdient/LayerSeq/ConcatSeq.swift:719 — Sources/GrAIdient/LayerSeq/ConcatSeq.swift:719-730 | Sources/GrAIdient/LayerSeq/ConcatSeq.swift:813-824 — both copies are in the same file, so extract the 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/GrAIdient/LayerSeq/ConcatSeq.swift:719` 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/GrAIdient/LayerSeq/FullyConnectedPatch.swift:761 — Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:761-772 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:826-837 — both copies are in the same file, so extract the 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/GrAIdient/LayerSeq/FullyConnectedPatch.swift:761` 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/GrAIdient/LayerSeq/MutiplySeq.swift:204 — Sources/GrAIdient/LayerSeq/MutiplySeq.swift:204-215 | Sources/GrAIdient/LayerSeq/SumSeq.swift:126-137 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/MutiplySeq.swift` and `Sources/GrAIdient/LayerSeq/SumSeq.swift` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 153 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/GrAIdient/LayerSeq/MutiplySeq.swift:204` it begins part-way through the construct above it, so those exact lines 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/GrAIdient/LayerSeq/QuerySeq.swift:338 — Sources/GrAIdient/LayerSeq/QuerySeq.swift:338-349 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:1632-1643 — both copies are in the same file, so extract the 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/GrAIdient/LayerSeq/QuerySeq.swift:338` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 2) Sources/GrAIdient/LayerSeq/QuerySeq.swift:539 — Sources/GrAIdient/LayerSeq/QuerySeq.swift:539-550 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:2062-2073 — both copies are in the same file, so extract the 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/GrAIdient/LayerSeq/QuerySeq.swift:539` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 2) Sources/GrAIdient/LayerSeq/QuerySeq.swift:805 — Sources/GrAIdient/LayerSeq/QuerySeq.swift:805-816 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:930-941 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (12 lines × 2) Sources/GrAIdient/LayerSeq/VQSeq.swift:456 — Sources/GrAIdient/LayerSeq/VQSeq.swift:456-467 | Sources/GrAIdient/LayerSeq/VQSeq.swift:1269-1280 — both copies are in the same file, so extract the 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/GrAIdient/LayerSeq/VQSeq.swift:456` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 2) Sources/GrAIdient/Layer2D/Convolution2D.swift:308 — Sources/GrAIdient/Layer2D/Convolution2D.swift:308-319 | Sources/GrAIdient/Layer2D/MaxPool2D.swift:29-40 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Convolution2D.swift` and `Sources/GrAIdient/Layer2D/MaxPool2D.swift` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 45 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (12 lines × 2) Sources/GrAIdient/Layer1D/Constant1D.swift:275 — Sources/GrAIdient/Layer1D/Constant1D.swift:275-286 | Sources/GrAIdient/Layer2D/Constant2D.swift:333-344 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Constant1D.swift` and `Sources/GrAIdient/Layer2D/Constant2D.swift` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 131 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (12 lines × 2) Sources/GrAIdient/LayerSeq/ConstantSeq.swift:762 — Sources/GrAIdient/LayerSeq/ConstantSeq.swift:762-773 | Sources/GrAIdient/LayerSeq/EmbeddingSeq.swift:447-458 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/ConstantSeq.swift` and `Sources/GrAIdient/LayerSeq/EmbeddingSeq.swift` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 90 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (10 lines × 2) · ×22
  • Duplicated block (10 lines × 2) Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1332 — Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1332-1341 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:2248-2257 — both copies are in the same file, so extract the 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/GrAIdient/Core/Layer/LayerNormalization.swift:1332` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 2) Sources/GrAIdient/Core/Layer/LayerNormalization.swift:2529 — Sources/GrAIdient/Core/Layer/LayerNormalization.swift:2529-2538 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:2561-2570 — both copies are in the same file, so extract the 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/GrAIdient/Core/Layer/LayerNormalization.swift:2529` 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/GrAIdient/Core/Layer/LayerNormalization.swift:2571` calls `setBuffer` and `Sources/GrAIdient/Core/Layer/LayerNormalization.swift:2539` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (10 lines × 2) Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:338 — Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:338-347 | Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:412-421 — both copies are in the same file, so extract the 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/GrAIdient/Core/Optimizer/OptimizerImpl.swift:338` 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/GrAIdient/Core/Optimizer/OptimizerImpl.swift:348` calls `max` and `Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:423` 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/GrAIdient/Layer1D/Concat1D.swift:281 — Sources/GrAIdient/Layer1D/Concat1D.swift:281-290 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:1699-1708 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (10 lines × 2) Sources/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:555 — Sources/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:555-564 | Sources/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:751-760 — both copies are in the same file, so extract the 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/GrAIdient/Layer2D/Concat2D.swift:298 — Sources/GrAIdient/Layer2D/Concat2D.swift:298-307 | Sources/GrAIdient/Layer2D/Concat2D.swift:394-403 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/Layer2D/Concat2D.swift:298` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 2) Sources/GrAIdient/Layer2D/Convolution2D.swift:1357 — Sources/GrAIdient/Layer2D/Convolution2D.swift:1357-1366 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:832-841 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Convolution2D.swift` and `Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift` as WHOLE FILES: this scan already matched 23 separate duplicated blocks between them, totalling at least 193 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/GrAIdient/Layer2D/Convolution2D.swift:1357` 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 (10 lines × 2) Sources/GrAIdient/Layer2D/Convolution2D.swift:1553 — Sources/GrAIdient/Layer2D/Convolution2D.swift:1553-1562 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:993-1002 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Convolution2D.swift` and `Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift` as WHOLE FILES: this scan already matched 23 separate duplicated blocks between them, totalling at least 193 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/GrAIdient/Layer2D/Convolution2D.swift:1553` 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 (10 lines × 2) Sources/GrAIdient/Layer2D/Convolution2D.swift:1648 — Sources/GrAIdient/Layer2D/Convolution2D.swift:1648-1657 | Sources/GrAIdient/Layer2D/Convolution2D.swift:1729-1738 — both copies are in the same file, so extract the 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/GrAIdient/Layer2D/LayerCAM2D.swift:183 — Sources/GrAIdient/Layer2D/LayerCAM2D.swift:183-192 | Sources/GrAIdient/LayerSeq/LayerCAMSeq.swift:179-188 — before extracting anything, compare `Sources/GrAIdient/Layer2D/LayerCAM2D.swift` and `Sources/GrAIdient/LayerSeq/LayerCAMSeq.swift` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 39 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. 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/GrAIdient/Layer2D/Multiply2D.swift:146 — Sources/GrAIdient/Layer2D/Multiply2D.swift:146-155 | Sources/GrAIdient/LayerSeq/MutiplySeq.swift:145-154 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Multiply2D.swift` and `Sources/GrAIdient/LayerSeq/MutiplySeq.swift` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 103 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/GrAIdient/Layer2D/Multiply2D.swift:146` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 2) Sources/GrAIdient/Layer2D/Normalize2D.swift:226 — Sources/GrAIdient/Layer2D/Normalize2D.swift:226-235 | Sources/GrAIdient/Layer2D/Normalize2D.swift:644-653 — both copies are in the same file, so extract the 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/GrAIdient/Layer2D/Normalize2D.swift:226` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 2) Sources/GrAIdient/Layer2D/SelectNeurons2D.swift:134 — Sources/GrAIdient/Layer2D/SelectNeurons2D.swift:134-143 | Sources/GrAIdient/Layer2D/SelectNeurons2D.swift:169-178 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/Layer2D/SelectNeurons2D.swift:134` 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 (10 lines × 2) Sources/GrAIdient/Layer2D/Transform/IRDFT2RGB.swift:112 — Sources/GrAIdient/Layer2D/Transform/IRDFT2RGB.swift:112-121 | Sources/GrAIdient/Layer2D/Transform/IRDFT2RGB.swift:161-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/GrAIdient/Layer2D/Transform/IRDFT2RGB.swift:112` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (10 lines × 2) Sources/GrAIdient/LayerSeq/ConstantSeq.swift:963 — Sources/GrAIdient/LayerSeq/ConstantSeq.swift:963-972 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:1169-1178 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/ConstantSeq.swift` and `Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 51 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (10 lines × 2) Sources/GrAIdient/LayerSeq/EmbeddingSeq.swift:692 — Sources/GrAIdient/LayerSeq/EmbeddingSeq.swift:692-701 | Sources/GrAIdient/LayerSeq/EmbeddingSeq.swift:744-753 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/LayerSeq/EmbeddingSeq.swift:692` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Sources/GrAIdient/LayerSeq/EmbeddingSeq.swift:689` calls `setBuffer` and `Sources/GrAIdient/LayerSeq/EmbeddingSeq.swift:741` 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/GrAIdient/LayerSeq/FullyConnectedSeq.swift:522 — Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:522-531 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:775-784 — both copies are in the same file, so extract the 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/GrAIdient/LayerSeq/FullyConnectedSeq.swift:522` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 2) Sources/GrAIdient/LayerSeq/QuerySeq.swift:34 — Sources/GrAIdient/LayerSeq/QuerySeq.swift:34-43 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:32-41 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/QuerySeq.swift` and `Sources/GrAIdient/LayerSeq/ValueSeq.swift` as WHOLE FILES: this scan already matched 39 separate duplicated blocks between them, totalling at least 427 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/GrAIdient/LayerSeq/QuerySeq.swift:34` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 2) Sources/GrAIdient/LayerSeq/QuerySeq.swift:884 — Sources/GrAIdient/LayerSeq/QuerySeq.swift:884-894 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:997-1006 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/QuerySeq.swift` and `Sources/GrAIdient/LayerSeq/ValueSeq.swift` as WHOLE FILES: this scan already matched 39 separate duplicated blocks between them, totalling at least 427 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/GrAIdient/LayerSeq/QuerySeq.swift:884` 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 after the matched lines, `Sources/GrAIdient/LayerSeq/ValueSeq.swift:1007` calls `get` and `Sources/GrAIdient/LayerSeq/QuerySeq.swift:894` 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/GrAIdient/LayerSeq/QuerySeq.swift:1368 — Sources/GrAIdient/LayerSeq/QuerySeq.swift:1368-1377 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:1616-1625 — both copies are in the same file, so extract the 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/GrAIdient/LayerSeq/QuerySeq.swift:1368` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 2) Sources/GrAIdient/LayerSeq/ValueSeq.swift:332 — Sources/GrAIdient/LayerSeq/ValueSeq.swift:332-341 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:905-915 — both copies are in the same file, so extract the 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/GrAIdient/LayerSeq/ValueSeq.swift:332` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (10 lines × 2) Sources/GrAIdient/Layer2D/MaxPool2D.swift:361 — Sources/GrAIdient/Layer2D/MaxPool2D.swift:361-370 | Sources/GrAIdient/Layer2D/MaxPool2D.swift:451-460 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/Layer2D/MaxPool2D.swift:361` 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.
D6 · Cohesion (LCOM4) · Low cohesion · ×22
  • Low cohesion: Model (LCOM4 10) Sources/GrAIdient/Core/Model/Model.swift:232 — Model's methods fall into 10 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 10 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: LayerOutput1D (LCOM4 9) Sources/GrAIdient/Layer1D/Base/LayerOutput1D.swift:9 — LayerOutput1D's methods fall into 9 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 9 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: LayerOutput2D (LCOM4 9) Sources/GrAIdient/Layer2D/Base/LayerOutput2D.swift:9 — LayerOutput2D's methods fall into 9 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 9 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: BN2D (LCOM4 8) Sources/GrAIdient/Layer2D/BN2D.swift:9 — BN2D's methods fall into 8 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 8 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: Deconvolution2D (LCOM4 8) Sources/GrAIdient/Layer2D/Deconvolution2D.swift:22 — Deconvolution2D's methods fall into 8 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 8 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: Input2D (LCOM4 8) Sources/GrAIdient/Layer2D/Input2D.swift:102 — Input2D's methods fall into 8 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 8 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: InstanceNorm2D (LCOM4 8) Sources/GrAIdient/Layer2D/InstanceNorm2D.swift:9 — InstanceNorm2D's methods fall into 8 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 8 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: LayerNormSeq (LCOM4 8) Sources/GrAIdient/LayerSeq/LayerNormSeq.swift:9 — LayerNormSeq's methods fall into 8 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 8 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: RMSNormSeq (LCOM4 8) Sources/GrAIdient/LayerSeq/RMSNormSeq.swift:9 — RMSNormSeq's methods fall into 8 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 8 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: Input1D (LCOM4 7) Sources/GrAIdient/Layer1D/Input1D.swift:83 — Input1D's methods fall into 7 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 7 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: AdaIN (LCOM4 7) Sources/GrAIdient/Layer2D/AdaIN.swift:13 — AdaIN's methods fall into 7 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 7 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: VQ2D (LCOM4 6) Sources/GrAIdient/Layer2D/VQ2D.swift:35 — VQ2D's methods fall into 6 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 6 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: LayerCAM2D (LCOM4 5) Sources/GrAIdient/Layer2D/LayerCAM2D.swift:13 — LayerCAM2D'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: Normalize122D (LCOM4 5) Sources/GrAIdient/Layer2D/Normalize2D.swift:315 — Normalize122D'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: LayerCAMSeq (LCOM4 5) Sources/GrAIdient/LayerSeq/LayerCAMSeq.swift:13 — LayerCAMSeq'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: SoftmaxCausalSeq (LCOM4 5) Sources/GrAIdient/LayerSeq/SoftmaxSeq.swift:364 — SoftmaxCausalSeq'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: ActivationFunction (LCOM4 5) Sources/GrAIdient/Core/Function/Activation.swift:23 — ActivationFunction'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: OptimizerAlgorithm (LCOM4 5) Sources/GrAIdient/Core/Optimizer/OptimizerAlgorithm.swift:37 — OptimizerAlgorithm'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: LayerInput1D (LCOM4 4) Sources/GrAIdient/Layer1D/Base/LayerInput1D.swift:9 — LayerInput1D'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: LayerInput2D (LCOM4 4) Sources/GrAIdient/Layer2D/Base/LayerInput2D.swift:9 — LayerInput2D'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: ColorJitterHSV (LCOM4 4) Sources/GrAIdient/Layer2D/Transform/ColorJitterHSV.swift:60 — ColorJitterHSV'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: FlipVertical2D (LCOM4 4) Sources/GrAIdient/Layer2D/Transform/Flip2D.swift:337 — FlipVertical2D'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.
D4 · Code Duplication · Duplicated block (13 lines × 2) · ×19
  • Duplicated block (13 lines × 2) Sources/GrAIdient/Core/Layer/LayerNormalization.swift:2228 — Sources/GrAIdient/Core/Layer/LayerNormalization.swift:2228-2240 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:2870-2882 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (13 lines × 2) Sources/GrAIdient/Core/Layer/LayerNormalization.swift:2551 — Sources/GrAIdient/Core/Layer/LayerNormalization.swift:2551-2563 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:3129-3141 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (13 lines × 2) Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:546 — Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:546-558 | Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:628-640 — both copies are in the same file, so extract the 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/GrAIdient/Core/Optimizer/OptimizerImpl.swift:546` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:641` calls `max` and `Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:560` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (13 lines × 2) Sources/GrAIdient/Layer1D/Concat1D.swift:113 — Sources/GrAIdient/Layer1D/Concat1D.swift:113-125 | Sources/GrAIdient/Layer1D/Concat1D.swift:195-207 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/Layer1D/Concat1D.swift:113` 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/GrAIdient/Layer2D/AvgPool2D.swift:73 — Sources/GrAIdient/Layer2D/AvgPool2D.swift:73-85 | Sources/GrAIdient/Layer2D/SelectNeurons2D.swift:191-203 — before extracting anything, compare `Sources/GrAIdient/Layer2D/AvgPool2D.swift` and `Sources/GrAIdient/Layer2D/SelectNeurons2D.swift` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 100 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/GrAIdient/Layer2D/AvgPool2D.swift:73` 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/GrAIdient/Layer2D/Base/Layer2D.swift:283 — Sources/GrAIdient/Layer2D/Base/Layer2D.swift:283-295 | Sources/GrAIdient/Layer2D/Base/Layer2D.swift:338-350 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/Layer2D/Base/Layer2D.swift:283` 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 (13 lines × 2) Sources/GrAIdient/Layer2D/Concat2D.swift:310 — Sources/GrAIdient/Layer2D/Concat2D.swift:310-322 | Sources/GrAIdient/Layer2D/SimilarityError2D.swift:389-401 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Concat2D.swift` and `Sources/GrAIdient/Layer2D/SimilarityError2D.swift` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 90 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Sources/GrAIdient/Layer2D/Concat2D.swift:323` calls `setBytes` and `Sources/GrAIdient/Layer2D/SimilarityError2D.swift:402` 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/GrAIdient/Layer2D/Convolution2D.swift:1098 — Sources/GrAIdient/Layer2D/Convolution2D.swift:1098-1110 | Sources/GrAIdient/Layer2D/Deconvolution2D.swift:538-550 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Convolution2D.swift` and `Sources/GrAIdient/Layer2D/Deconvolution2D.swift` as WHOLE FILES: this scan already matched 26 separate duplicated blocks between them, totalling at least 499 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/GrAIdient/Layer2D/Convolution2D.swift:1098` it begins part-way through the construct above it, so those exact lines 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/GrAIdient/Layer2D/Transform/FTFrequences2D.swift:153 — Sources/GrAIdient/Layer2D/Transform/FTFrequences2D.swift:153-165 | Sources/GrAIdient/Layer2D/Transform/FTFrequences2D.swift:191-203 — both copies are in the same file, so extract the 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/GrAIdient/Layer2D/Transform/FTFrequences2D.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 (13 lines × 2) Sources/GrAIdient/Layer2D/VQ2D.swift:652 — Sources/GrAIdient/Layer2D/VQ2D.swift:652-664 | Sources/GrAIdient/LayerSeq/VQSeq.swift:575-587 — before extracting anything, compare `Sources/GrAIdient/Layer2D/VQ2D.swift` and `Sources/GrAIdient/LayerSeq/VQSeq.swift` as WHOLE FILES: this scan already matched 30 separate duplicated blocks between them, totalling at least 378 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/GrAIdient/Layer2D/VQ2D.swift:651` calls `UInt32` and `Sources/GrAIdient/LayerSeq/VQSeq.swift:574` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (13 lines × 2) Sources/GrAIdient/Layer2D/VQ2D.swift:1339 — Sources/GrAIdient/Layer2D/VQ2D.swift:1339-1351 | Sources/GrAIdient/LayerSeq/VQSeq.swift:1256-1268 — before extracting anything, compare `Sources/GrAIdient/Layer2D/VQ2D.swift` and `Sources/GrAIdient/LayerSeq/VQSeq.swift` as WHOLE FILES: this scan already matched 30 separate duplicated blocks between them, totalling at least 378 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/GrAIdient/Layer2D/VQ2D.swift:1338` calls `UInt32` and `Sources/GrAIdient/LayerSeq/VQSeq.swift:1255` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (13 lines × 2) Sources/GrAIdient/LayerSeq/AvgPoolSeq.swift:73 — Sources/GrAIdient/LayerSeq/AvgPoolSeq.swift:73-85 | Sources/GrAIdient/LayerSeq/SelectSeq.swift:109-121 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/AvgPoolSeq.swift` and `Sources/GrAIdient/LayerSeq/SelectSeq.swift` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 75 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/GrAIdient/LayerSeq/AvgPoolSeq.swift:73` 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/GrAIdient/LayerSeq/FullyConnectedPatch.swift:693 — Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:693-705 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:633-645 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift` and `Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift` as WHOLE FILES: this scan already matched 54 separate duplicated blocks between them, totalling at least 760 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/GrAIdient/LayerSeq/MutiplySeq.swift:281 — Sources/GrAIdient/LayerSeq/MutiplySeq.swift:281-293 | Sources/GrAIdient/LayerSeq/SumSeq.swift:203-215 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/MutiplySeq.swift` and `Sources/GrAIdient/LayerSeq/SumSeq.swift` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 153 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/GrAIdient/LayerSeq/MutiplySeq.swift:281` 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/GrAIdient/LayerSeq/ValueSeq.swift:243 — Sources/GrAIdient/LayerSeq/ValueSeq.swift:243-255 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:813-825 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/LayerSeq/ValueSeq.swift:243` 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/GrAIdient/Layer1D/Constant1D.swift:41 — Sources/GrAIdient/Layer1D/Constant1D.swift:41-53 | Sources/GrAIdient/LayerSeq/ConstantSeq.swift:525-537 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Constant1D.swift` and `Sources/GrAIdient/LayerSeq/ConstantSeq.swift` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 267 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (13 lines × 2) Sources/GrAIdient/Layer2D/Base/LayerOutput2D.swift:251 — Sources/GrAIdient/Layer2D/Base/LayerOutput2D.swift:251-263 | Sources/GrAIdient/LayerSeq/VQSeq.swift:367-379 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (13 lines × 2) Sources/GrAIdient/Layer2D/VQ2D.swift:1152 — Sources/GrAIdient/Layer2D/VQ2D.swift:1152-1164 | Sources/GrAIdient/LayerSeq/VQSeq.swift:1072-1084 — before extracting anything, compare `Sources/GrAIdient/Layer2D/VQ2D.swift` and `Sources/GrAIdient/LayerSeq/VQSeq.swift` as WHOLE FILES: this scan already matched 30 separate duplicated blocks between them, totalling at least 378 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (13 lines × 2) Sources/GrAIdient/Layer2D/Convolution2D.swift:325 — Sources/GrAIdient/Layer2D/Convolution2D.swift:325-337 | Sources/GrAIdient/Layer2D/MaxPool2D.swift:46-58 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Convolution2D.swift` and `Sources/GrAIdient/Layer2D/MaxPool2D.swift` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 45 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (11 lines × 2) · ×18
  • Duplicated block (11 lines × 2) Sources/GrAITestsUtils/Trainer.swift:848 — Sources/GrAITestsUtils/Trainer.swift:848-858 | Sources/GrAITestsUtils/Trainer.swift:861-871 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (11 lines × 2) Sources/GrAIdient/Core/Function/Activation.swift:933 — Sources/GrAIdient/Core/Function/Activation.swift:933-943 | Sources/GrAIdient/Core/Function/Activation.swift:955-965 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (11 lines × 2) Sources/GrAIdient/Layer1D/Activation1D.swift:219 — Sources/GrAIdient/Layer1D/Activation1D.swift:219-229 | Sources/GrAIdient/Layer1D/SelectNeurons1D.swift:214-224 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Activation1D.swift` and `Sources/GrAIdient/Layer1D/SelectNeurons1D.swift` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 72 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/GrAIdient/Layer1D/Activation1D.swift:219` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 2) Sources/GrAIdient/Layer1D/FullyConnected.swift:636 — Sources/GrAIdient/Layer1D/FullyConnected.swift:636-646 | Sources/GrAIdient/Layer1D/FullyConnected.swift:747-757 — both copies are in the same file, so extract the 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/GrAIdient/Layer1D/FullyConnected.swift:636` 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/GrAIdient/Layer1D/FullyConnected.swift:759` calls `download` and `Sources/GrAIdient/Layer1D/FullyConnected.swift:648` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (11 lines × 2) Sources/GrAIdient/Layer1D/LinearError1D.swift:296 — Sources/GrAIdient/Layer1D/LinearError1D.swift:296-306 | Sources/GrAIdient/Layer2D/SimilarityBatchError2D.swift:333-343 — before extracting anything, compare `Sources/GrAIdient/Layer1D/LinearError1D.swift` and `Sources/GrAIdient/Layer2D/SimilarityBatchError2D.swift` as WHOLE FILES: this scan already matched 4 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. 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 (11 lines × 2) Sources/GrAIdient/Layer1D/SelectNeurons1D.swift:173 — Sources/GrAIdient/Layer1D/SelectNeurons1D.swift:173-183 | Sources/GrAIdient/Layer1D/Softmax1D.swift:119-129 — before extracting anything, compare `Sources/GrAIdient/Layer1D/SelectNeurons1D.swift` and `Sources/GrAIdient/Layer1D/Softmax1D.swift` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 37 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/Layer1D/SelectNeurons1D.swift:173` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 2) Sources/GrAIdient/Layer2D/AdaIN.swift:711 — Sources/GrAIdient/Layer2D/AdaIN.swift:711-721 | Sources/GrAIdient/Layer2D/InstanceNorm2D.swift:719-729 — before extracting anything, compare `Sources/GrAIdient/Layer2D/AdaIN.swift` and `Sources/GrAIdient/Layer2D/InstanceNorm2D.swift` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 92 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (11 lines × 2) Sources/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:783 — Sources/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:783-793 | Sources/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:802-812 — both copies are in the same file, so extract the 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/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:783` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Sources/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:799` calls `setBuffer` and `Sources/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:780` 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/GrAIdient/Layer2D/BCE2D.swift:146 — Sources/GrAIdient/Layer2D/BCE2D.swift:146-156 | Sources/GrAIdient/Layer2D/BCE2D.swift:216-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/GrAIdient/Layer2D/BCE2D.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 matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (11 lines × 2) Sources/GrAIdient/Layer2D/Convolution2D.swift:981 — Sources/GrAIdient/Layer2D/Convolution2D.swift:981-991 | Sources/GrAIdient/Layer2D/Convolution2D.swift:1208-1218 — both copies are in the same file, so extract the 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/GrAIdient/Layer2D/Convolution2D.swift:981` 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 (11 lines × 2) Sources/GrAIdient/Layer2D/Multiply2D.swift:124 — Sources/GrAIdient/Layer2D/Multiply2D.swift:124-134 | Sources/GrAIdient/LayerSeq/MutiplySeq.swift:123-133 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Multiply2D.swift` and `Sources/GrAIdient/LayerSeq/MutiplySeq.swift` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 103 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/GrAIdient/Layer2D/Multiply2D.swift:124` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 2) Sources/GrAIdient/Layer2D/Normalize2D.swift:506 — Sources/GrAIdient/Layer2D/Normalize2D.swift:506-516 | Sources/GrAIdient/Layer2D/Normalize2D.swift:628-638 — both copies are in the same file, so extract the 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/GrAIdient/Layer2D/Normalize2D.swift:506` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 2) Sources/GrAIdient/Layer2D/Transform/Flip2D.swift:208 — Sources/GrAIdient/Layer2D/Transform/Flip2D.swift:208-218 | Sources/GrAIdient/Layer2D/Transform/Flip2D.swift:455-465 — both copies are in the same file, so extract the 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/GrAIdient/Layer2D/Transform/Flip2D.swift:208` it begins part-way through the construct above it, so those exact lines 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/GrAIdient/Layer2D/VQ2D.swift:519 — Sources/GrAIdient/Layer2D/VQ2D.swift:519-529 | Sources/GrAIdient/LayerSeq/VQSeq.swift:447-457 — before extracting anything, compare `Sources/GrAIdient/Layer2D/VQ2D.swift` and `Sources/GrAIdient/LayerSeq/VQSeq.swift` as WHOLE FILES: this scan already matched 30 separate duplicated blocks between them, totalling at least 378 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/GrAIdient/Layer2D/VQ2D.swift:518` calls `UInt32` and `Sources/GrAIdient/LayerSeq/VQSeq.swift:446` 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/GrAIdient/LayerSeq/EmbeddingSeq.swift:596 — Sources/GrAIdient/LayerSeq/EmbeddingSeq.swift:596-606 | Sources/GrAIdient/LayerSeq/LayerCAMSeq.swift:185-195 — 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/GrAIdient/LayerSeq/EmbeddingSeq.swift:596` 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 (11 lines × 2) Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:654 — Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:654-664 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:888-898 — both copies are in the same file, so extract the 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/GrAIdient/LayerSeq/FullyConnectedPatch.swift:654` it begins part-way through the construct above it, so those exact lines 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/GrAIdient/LayerSeq/ValueSeq.swift:425 — Sources/GrAIdient/LayerSeq/ValueSeq.swift:425-435 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1931-1941 — both copies are in the same file, so extract the 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/GrAIdient/LayerSeq/ValueSeq.swift:425` 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/GrAIdient/LayerSeq/QuerySeq.swift:1858 — Sources/GrAIdient/LayerSeq/QuerySeq.swift:1858-1868 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:1996-2006 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (8 lines × 2) · ×17
  • Duplicated block (8 lines × 2) Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1246 — Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1246-1253 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1270-1277 — both copies are in the same file, so extract the 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/GrAIdient/Core/Layer/LayerNormalization.swift:1246` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 2) Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1661 — Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1661-1668 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1869-1876 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (8 lines × 2) Sources/GrAIdient/Core/Layer/LayerNormalization.swift:2572 — Sources/GrAIdient/Core/Layer/LayerNormalization.swift:2572-2579 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:3147-3154 — both copies are in the same file, so extract the 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/GrAIdient/Core/Layer/LayerNormalization.swift:2572` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Sources/GrAIdient/Core/Layer/LayerNormalization.swift:2571` calls `setBuffer` and `Sources/GrAIdient/Core/Layer/LayerNormalization.swift:3146` 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/GrAIdient/Core/Layer/LayerNormalization.swift:2671 — Sources/GrAIdient/Core/Layer/LayerNormalization.swift:2671-2678 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:3237-3244 — both copies are in the same file, so extract the 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/GrAIdient/Core/Layer/LayerNormalization.swift:2671` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 2) Sources/GrAIdient/Layer1D/FullyConnected.swift:1081 — Sources/GrAIdient/Layer1D/FullyConnected.swift:1081-1088 | Sources/GrAIdient/Layer1D/FullyConnected.swift:1118-1125 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (8 lines × 2) Sources/GrAIdient/Layer1D/SelectNeurons1D.swift:246 — Sources/GrAIdient/Layer1D/SelectNeurons1D.swift:246-253 | Sources/GrAIdient/Layer1D/Softmax1D.swift:238-245 — before extracting anything, compare `Sources/GrAIdient/Layer1D/SelectNeurons1D.swift` and `Sources/GrAIdient/Layer1D/Softmax1D.swift` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 37 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Sources/GrAIdient/Layer1D/SelectNeurons1D.swift:254` calls `setBuffer` and `Sources/GrAIdient/Layer1D/Softmax1D.swift:246` 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/GrAIdient/Layer2D/Constant2D.swift:536 — Sources/GrAIdient/Layer2D/Constant2D.swift:536-543 | Sources/GrAIdient/Layer2D/Constant2D.swift:571-578 — both copies are in the same file, so extract the 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/GrAIdient/Layer2D/Constant2D.swift:536` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Sources/GrAIdient/Layer2D/Constant2D.swift:535` calls `setBytes` and `Sources/GrAIdient/Layer2D/Constant2D.swift:570` 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 lines × 2) Sources/GrAIdient/Layer2D/Deconvolution2D.swift:316 — Sources/GrAIdient/Layer2D/Deconvolution2D.swift:316-324 | Sources/GrAIdient/Layer2D/Deconvolution2D.swift:461-468 — both copies are in the same file, so extract the 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/GrAIdient/Layer2D/Deconvolution2D.swift:316` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (8 lines × 2) Sources/GrAIdient/Layer2D/Input2D.swift:25 — Sources/GrAIdient/Layer2D/Input2D.swift:25-32 | Sources/GrAIdient/Layer2D/Input2D.swift:54-61 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/Layer2D/Input2D.swift:25` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 2) Sources/GrAIdient/Layer2D/SelfCorrelate2D.swift:179 — Sources/GrAIdient/Layer2D/SelfCorrelate2D.swift:179-186 | Sources/GrAIdient/Layer2D/SelfCorrelate2D.swift:260-267 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (8 lines × 2) Sources/GrAIdient/Layer2D/VQ2D.swift:721 — Sources/GrAIdient/Layer2D/VQ2D.swift:721-728 | Sources/GrAIdient/Layer2D/VQ2D.swift:773-780 — both copies are in the same file, so extract the 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/GrAIdient/Layer2D/VQ2D.swift:721` 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 (8 lines × 2) Sources/GrAIdient/LayerSeq/AvgPoolSeq.swift:152 — Sources/GrAIdient/LayerSeq/AvgPoolSeq.swift:152-159 | Sources/GrAIdient/LayerSeq/VQSeq.swift:438-445 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/AvgPoolSeq.swift` and `Sources/GrAIdient/LayerSeq/VQSeq.swift` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 38 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/GrAIdient/LayerSeq/AvgPoolSeq.swift:152` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 2) Sources/GrAIdient/LayerSeq/ConstantSeq.swift:445 — Sources/GrAIdient/LayerSeq/ConstantSeq.swift:445-452 | Sources/GrAIdient/LayerSeq/ConstantSeq.swift:948-955 — both copies are in the same file, so extract the 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/GrAIdient/LayerSeq/ConstantSeq.swift:445` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 2) Sources/GrAIdient/LayerSeq/EmbeddingSeq.swift:724 — Sources/GrAIdient/LayerSeq/EmbeddingSeq.swift:724-731 | Sources/GrAIdient/LayerSeq/VQSeq.swift:676-683 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/EmbeddingSeq.swift` and `Sources/GrAIdient/LayerSeq/VQSeq.swift` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 112 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/GrAIdient/LayerSeq/EmbeddingSeq.swift:724` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 2) Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:1100 — Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:1100-1107 | Sources/GrAIdient/LayerSeq/RoPESeq.swift:448-455 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (8 lines × 2) Sources/GrAIdient/LayerSeq/VQSeq.swift:644 — Sources/GrAIdient/LayerSeq/VQSeq.swift:644-651 | Sources/GrAIdient/LayerSeq/VQSeq.swift:696-703 — both copies are in the same file, so extract the 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/GrAIdient/LayerSeq/VQSeq.swift:644` 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 (8 lines × 2) Sources/GrAIdient/Layer2D/SimilarityBatchError2D.swift:107 — Sources/GrAIdient/Layer2D/SimilarityBatchError2D.swift:107-114 | Sources/GrAIdient/Layer2D/VQ2D.swift:403-410 — before extracting anything, compare `Sources/GrAIdient/Layer2D/SimilarityBatchError2D.swift` and `Sources/GrAIdient/Layer2D/VQ2D.swift` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 44 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (14 lines × 2) · ×16
  • Duplicated block (14 lines × 2) Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:563 — Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:563-576 | Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:647-660 — both copies are in the same file, so extract the 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/GrAIdient/Core/Optimizer/OptimizerImpl.swift:563` 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/GrAIdient/Layer1D/Base/LayerOutput1D.swift:102 — Sources/GrAIdient/Layer1D/Base/LayerOutput1D.swift:102-115 | Sources/GrAIdient/Layer1D/Base/LayerOutput1D.swift:133-146 — both copies are in the same file, so extract the 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/GrAIdient/Layer1D/Base/LayerOutput1D.swift:102` 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 (14 lines × 2) Sources/GrAIdient/Layer1D/DotProduct1D.swift:411 — Sources/GrAIdient/Layer1D/DotProduct1D.swift:411-424 | Sources/GrAIdient/Layer1D/DotProduct1D.swift:438-451 — both copies are in the same file, so extract the 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/GrAIdient/Layer1D/DotProduct1D.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 lines × 2) Sources/GrAIdient/Layer1D/Softmax1D.swift:33 — Sources/GrAIdient/Layer1D/Softmax1D.swift:33-46 | Sources/GrAIdient/LayerSeq/SoftmaxSeq.swift:34-47 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Softmax1D.swift` and `Sources/GrAIdient/LayerSeq/SoftmaxSeq.swift` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 38 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/GrAIdient/Layer1D/Softmax1D.swift:33` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note first that the copies are not typed on the same thing: the declarations holding them bind `layerPrev` to `Layer1D` in one and `LayerSeq` 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 (14 lines × 2) Sources/GrAIdient/Layer2D/AvgPool2D.swift:249 — Sources/GrAIdient/Layer2D/AvgPool2D.swift:249-262 | Sources/GrAIdient/Layer2D/SelectNeurons2D.swift:352-365 — before extracting anything, compare `Sources/GrAIdient/Layer2D/AvgPool2D.swift` and `Sources/GrAIdient/Layer2D/SelectNeurons2D.swift` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 100 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/GrAIdient/Layer2D/AvgPool2D.swift:249` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Sources/GrAIdient/Layer2D/SelectNeurons2D.swift:350` calls `setBytes` and `Sources/GrAIdient/Layer2D/AvgPool2D.swift:247` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (14 lines × 2) Sources/GrAIdient/Layer2D/Convolution2D.swift:1427 — Sources/GrAIdient/Layer2D/Convolution2D.swift:1427-1440 | Sources/GrAIdient/Layer2D/Deconvolution2D.swift:795-808 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Convolution2D.swift` and `Sources/GrAIdient/Layer2D/Deconvolution2D.swift` as WHOLE FILES: this scan already matched 26 separate duplicated blocks between them, totalling at least 499 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/GrAIdient/Layer2D/Convolution2D.swift:1427` it begins part-way through the construct above it, so those exact lines 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/GrAIdient/Layer2D/Convolution2D.swift:1454 — Sources/GrAIdient/Layer2D/Convolution2D.swift:1454-1467 | Sources/GrAIdient/Layer2D/Deconvolution2D.swift:822-835 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Convolution2D.swift` and `Sources/GrAIdient/Layer2D/Deconvolution2D.swift` as WHOLE FILES: this scan already matched 26 separate duplicated blocks between them, totalling at least 499 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/GrAIdient/Layer2D/Convolution2D.swift:1454` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (14 lines × 2) Sources/GrAIdient/Layer2D/SimilarityBatchError2D.swift:164 — Sources/GrAIdient/Layer2D/SimilarityBatchError2D.swift:164-177 | Sources/GrAIdient/Layer2D/SimilarityError2D.swift:526-539 — before extracting anything, compare `Sources/GrAIdient/Layer2D/SimilarityBatchError2D.swift` and `Sources/GrAIdient/Layer2D/SimilarityError2D.swift` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 66 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (14 lines × 2) Sources/GrAIdient/Layer2D/SimilarityBatchError2D.swift:219 — Sources/GrAIdient/Layer2D/SimilarityBatchError2D.swift:219-232 | Sources/GrAIdient/Layer2D/SimilarityError2D.swift:581-594 — before extracting anything, compare `Sources/GrAIdient/Layer2D/SimilarityBatchError2D.swift` and `Sources/GrAIdient/Layer2D/SimilarityError2D.swift` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 66 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/GrAIdient/Layer2D/SimilarityBatchError2D.swift:219` 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/GrAIdient/Layer2D/Transform/Crop2D.swift:388 — Sources/GrAIdient/Layer2D/Transform/Crop2D.swift:388-401 | Sources/GrAIdient/Layer2D/Transform/Pad2D.swift:309-322 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Transform/Crop2D.swift` and `Sources/GrAIdient/Layer2D/Transform/Pad2D.swift` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 178 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/GrAIdient/Layer2D/Transform/Crop2D.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. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Sources/GrAIdient/Layer2D/Transform/Crop2D.swift:385` calls `setBytes` and `Sources/GrAIdient/Layer2D/Transform/Pad2D.swift:306` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (14 lines × 2) Sources/GrAIdient/Layer2D/Transform/Flip2D.swift:257 — Sources/GrAIdient/Layer2D/Transform/Flip2D.swift:257-270 | Sources/GrAIdient/Layer2D/Transform/Flip2D.swift:468-481 — both copies are in the same file, so extract the 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/GrAIdient/Layer2D/Transform/Flip2D.swift:257` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (14 lines × 2) Sources/GrAIdient/LayerSeq/ConcatSeq.swift:287 — Sources/GrAIdient/LayerSeq/ConcatSeq.swift:287-300 | Sources/GrAIdient/LayerSeq/ConcatSeq.swift:386-399 — both copies are in the same file, so extract the 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/GrAIdient/LayerSeq/ConcatSeq.swift:287` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (14 lines × 2) Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:529 — Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:529-542 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:689-702 — both copies are in the same file, so extract the 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/GrAIdient/LayerSeq/FullyConnectedPatch.swift:529` 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/GrAIdient/LayerSeq/FullyConnectedPatch.swift:704` calls `download` and `Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:544` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (14 lines × 2) Sources/GrAIdient/LayerSeq/QuerySeq.swift:199 — Sources/GrAIdient/LayerSeq/QuerySeq.swift:199-212 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:302-315 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/LayerSeq/QuerySeq.swift:199` it begins part-way through the construct above it, so those exact lines 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/GrAIdient/Layer2D/SimilarityBatchError2D.swift:191 — Sources/GrAIdient/Layer2D/SimilarityBatchError2D.swift:191-204 | Sources/GrAIdient/Layer2D/SimilarityError2D.swift:553-566 — before extracting anything, compare `Sources/GrAIdient/Layer2D/SimilarityBatchError2D.swift` and `Sources/GrAIdient/Layer2D/SimilarityError2D.swift` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 66 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/GrAIdient/Layer2D/SimilarityBatchError2D.swift:191` 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/GrAIdient/Layer1D/Constant1D.swift:560 — Sources/GrAIdient/Layer1D/Constant1D.swift:560-573 | Sources/GrAIdient/LayerSeq/ConstantSeq.swift:1068-1081 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Constant1D.swift` and `Sources/GrAIdient/LayerSeq/ConstantSeq.swift` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 267 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.
D4 · Code Duplication · Duplicated block (15 lines × 2) · ×15
  • Duplicated block (15 lines × 2) Sources/GrAITestsUtils/Trainer.swift:314 — Sources/GrAITestsUtils/Trainer.swift:314-328 | Sources/GrAITestsUtils/Trainer.swift:457-471 — both copies are in the same file, so extract the 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/GrAITestsUtils/Trainer.swift:314` 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/GrAIdient/Core/Layer/LayerNormalization.swift:1914 — Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1914-1928 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1956-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 (15 lines × 2) Sources/GrAIdient/Layer1D/Constant1D.swift:452 — Sources/GrAIdient/Layer1D/Constant1D.swift:452-466 | Sources/GrAIdient/Layer2D/Constant2D.swift:523-537 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Constant1D.swift` and `Sources/GrAIdient/Layer2D/Constant2D.swift` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 131 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/GrAIdient/Layer1D/Constant1D.swift:452` 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/GrAIdient/Layer2D/Base/LayerInput2D.swift:56 — Sources/GrAIdient/Layer2D/Base/LayerInput2D.swift:56-70 | Sources/GrAIdient/Layer2D/Base/LayerInput2D.swift:122-136 — both copies are in the same file, so extract the 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/GrAIdient/Layer2D/Base/LayerInput2D.swift:56` 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 (15 lines × 2) Sources/GrAIdient/Layer2D/Concat2D.swift:132 — Sources/GrAIdient/Layer2D/Concat2D.swift:132-146 | Sources/GrAIdient/Layer2D/Concat2D.swift:226-240 — both copies are in the same file, so extract the 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/GrAIdient/Layer2D/Concat2D.swift:132` 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/GrAIdient/Layer2D/Convolution2D.swift:1401 — Sources/GrAIdient/Layer2D/Convolution2D.swift:1401-1415 | Sources/GrAIdient/Layer2D/Deconvolution2D.swift:773-787 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Convolution2D.swift` and `Sources/GrAIdient/Layer2D/Deconvolution2D.swift` as WHOLE FILES: this scan already matched 26 separate duplicated blocks between them, totalling at least 499 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/GrAIdient/Layer2D/Convolution2D.swift:1401` 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/GrAIdient/Layer2D/VQ2D.swift:184 — Sources/GrAIdient/Layer2D/VQ2D.swift:184-198 | Sources/GrAIdient/LayerSeq/VQSeq.swift:174-188 — before extracting anything, compare `Sources/GrAIdient/Layer2D/VQ2D.swift` and `Sources/GrAIdient/LayerSeq/VQSeq.swift` as WHOLE FILES: this scan already matched 30 separate duplicated blocks between them, totalling at least 378 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/GrAIdient/Layer2D/VQ2D.swift:184` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Sources/GrAIdient/LayerSeq/VQSeq.swift:173` calls `encode`, `Float` and `Sources/GrAIdient/Layer2D/VQ2D.swift:183` 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 (15 lines × 2) Sources/GrAIdient/LayerSeq/ConcatSeq.swift:358 — Sources/GrAIdient/LayerSeq/ConcatSeq.swift:358-372 | Sources/GrAIdient/LayerSeq/ConcatSeq.swift:785-799 — both copies are in the same file, so extract the 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/GrAIdient/LayerSeq/ConcatSeq.swift:358` 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/GrAIdient/LayerSeq/ConstantSeq.swift:275 — Sources/GrAIdient/LayerSeq/ConstantSeq.swift:275-289 | Sources/GrAIdient/LayerSeq/ConstantSeq.swift:780-794 — both copies are in the same file, so extract the 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/GrAIdient/LayerSeq/ConstantSeq.swift:275` 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/GrAIdient/LayerSeq/ConstantSeq.swift:322 — Sources/GrAIdient/LayerSeq/ConstantSeq.swift:322-336 | Sources/GrAIdient/LayerSeq/ConstantSeq.swift:826-840 — both copies are in the same file, so extract the 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/GrAIdient/LayerSeq/ConstantSeq.swift:322` 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/GrAIdient/LayerSeq/FullyConnectedPatch.swift:577 — Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:577-591 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:745-759 — both copies are in the same file, so extract the 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/GrAIdient/LayerSeq/FullyConnectedPatch.swift:577` 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/GrAIdient/LayerSeq/FullyConnectedPatch.swift:743` calls `download` and `Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:575` 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 (15 lines × 2) Sources/GrAIdient/LayerSeq/QuerySeq.swift:493 — Sources/GrAIdient/LayerSeq/QuerySeq.swift:493-507 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:521-535 — both copies are in the same file, so extract the 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/GrAIdient/LayerSeq/QuerySeq.swift:493` 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/GrAIdient/Utils/Buffer.swift:125 — Sources/GrAIdient/Utils/Buffer.swift:125-139 | Sources/GrAIdient/Utils/Buffer.swift:153-167 — both copies are in the same file, so extract the 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/GrAIdient/Utils/Buffer.swift:125` it begins part-way through the construct above it, so those exact lines 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/GrAIdient/Utils/Image.swift:189 — Sources/GrAIdient/Utils/Image.swift:189-203 | Sources/GrAIdient/Utils/Image.swift:230-244 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/Utils/Image.swift:189` 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 (15 lines × 2) Sources/GrAIdient/Layer1D/Base/LayerMerge1D.swift:98 — Sources/GrAIdient/Layer1D/Base/LayerMerge1D.swift:98-112 | Sources/GrAIdient/Layer2D/Base/LayerMerge2D.swift:156-170 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Base/LayerMerge1D.swift` and `Sources/GrAIdient/Layer2D/Base/LayerMerge2D.swift` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 129 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.
D4 · Code Duplication · Duplicated block (7 lines × 2) · ×14
  • Duplicated block (7 lines × 2) Sources/GrAIdient/Layer2D/AvgPool2D.swift:164 — Sources/GrAIdient/Layer2D/AvgPool2D.swift:164-170 | Sources/GrAIdient/Layer2D/AvgPool2D.swift:235-241 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (7 lines × 2) Sources/GrAIdient/Layer2D/Input2D.swift:38 — Sources/GrAIdient/Layer2D/Input2D.swift:38-44 | Sources/GrAIdient/Layer2D/Input2D.swift:67-73 — both copies are in the same file, so extract the 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/GrAIdient/Layer2D/Input2D.swift:38` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 2) Sources/GrAIdient/Layer2D/SimilarityBatchError2D.swift:247 — Sources/GrAIdient/Layer2D/SimilarityBatchError2D.swift:247-253 | Sources/GrAIdient/Layer2D/VQ2D.swift:832-838 — before extracting anything, compare `Sources/GrAIdient/Layer2D/SimilarityBatchError2D.swift` and `Sources/GrAIdient/Layer2D/VQ2D.swift` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 44 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Sources/GrAIdient/Layer2D/VQ2D.swift:839` calls `setBuffer` and `Sources/GrAIdient/Layer2D/SimilarityBatchError2D.swift:254` 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 (7 lines × 2) Sources/GrAIdient/Layer2D/Transform/IRDFT2RGB.swift:125 — Sources/GrAIdient/Layer2D/Transform/IRDFT2RGB.swift:125-131 | Sources/GrAIdient/Layer2D/Transform/IRDFT2RGB.swift:174-180 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/Layer2D/Transform/IRDFT2RGB.swift:125` 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 (7 lines × 2) Sources/GrAIdient/Layer2D/VQ2D.swift:1054 — Sources/GrAIdient/Layer2D/VQ2D.swift:1054-1060 | Sources/GrAIdient/LayerSeq/VQSeq.swift:974-980 — before extracting anything, compare `Sources/GrAIdient/Layer2D/VQ2D.swift` and `Sources/GrAIdient/LayerSeq/VQSeq.swift` as WHOLE FILES: this scan already matched 30 separate duplicated blocks between them, totalling at least 378 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (7 lines × 2) Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:569 — Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:569-575 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:735-741 — both copies are in the same file, so extract the 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/GrAIdient/LayerSeq/FullyConnectedPatch.swift:569` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:743` calls `download` and `Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:577` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (7 lines × 2) Sources/GrAIdient/LayerSeq/QuerySeq.swift:951 — Sources/GrAIdient/LayerSeq/QuerySeq.swift:951-957 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:974-980 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (7 lines × 2) Sources/GrAIdient/LayerSeq/QuerySeq.swift:1299 — Sources/GrAIdient/LayerSeq/QuerySeq.swift:1299-1305 | Sources/GrAIdient/LayerSeq/RoPESeq.swift:361-367 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/QuerySeq.swift` and `Sources/GrAIdient/LayerSeq/RoPESeq.swift` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 52 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Sources/GrAIdient/LayerSeq/RoPESeq.swift:368` calls `setBuffer` and `Sources/GrAIdient/LayerSeq/QuerySeq.swift:1306` 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 (7 lines × 2) Sources/GrAIdient/LayerSeq/RoPESeq.swift:357 — Sources/GrAIdient/LayerSeq/RoPESeq.swift:357-363 | Sources/GrAIdient/LayerSeq/RoPESeq.swift:443-449 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (7 lines × 2) Sources/GrAIdient/Layer2D/SimilarityBatchError2D.swift:86 — Sources/GrAIdient/Layer2D/SimilarityBatchError2D.swift:86-92 | Sources/GrAIdient/Layer2D/VQ2D.swift:382-388 — before extracting anything, compare `Sources/GrAIdient/Layer2D/SimilarityBatchError2D.swift` and `Sources/GrAIdient/Layer2D/VQ2D.swift` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 44 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (7 lines × 2) Sources/GrAIdient/Layer2D/SimilarityBatchError2D.swift:128 — Sources/GrAIdient/Layer2D/SimilarityBatchError2D.swift:128-134 | Sources/GrAIdient/Layer2D/VQ2D.swift:424-430 — before extracting anything, compare `Sources/GrAIdient/Layer2D/SimilarityBatchError2D.swift` and `Sources/GrAIdient/Layer2D/VQ2D.swift` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 44 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (7 lines × 2) Sources/GrAIdient/LayerSeq/LayerNormSeq.swift:656 — Sources/GrAIdient/LayerSeq/LayerNormSeq.swift:656-662 | Sources/GrAIdient/LayerSeq/RMSNormSeq.swift:670-676 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/LayerNormSeq.swift` and `Sources/GrAIdient/LayerSeq/RMSNormSeq.swift` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 276 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (7 lines × 2) Sources/GrAIdient/LayerSeq/LayerNormSeq.swift:690 — Sources/GrAIdient/LayerSeq/LayerNormSeq.swift:690-696 | Sources/GrAIdient/LayerSeq/RMSNormSeq.swift:704-710 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/LayerNormSeq.swift` and `Sources/GrAIdient/LayerSeq/RMSNormSeq.swift` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 276 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (7 lines × 2) Sources/GrAIdient/LayerSeq/LayerNormSeq.swift:724 — Sources/GrAIdient/LayerSeq/LayerNormSeq.swift:724-730 | Sources/GrAIdient/LayerSeq/RMSNormSeq.swift:738-744 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/LayerNormSeq.swift` and `Sources/GrAIdient/LayerSeq/RMSNormSeq.swift` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 276 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (16 lines × 2) · ×13
  • Duplicated block (16 lines × 2) Sources/GrAIdient/Core/Function/Normalization.swift:96 — Sources/GrAIdient/Core/Function/Normalization.swift:96-111 | Sources/GrAIdient/Core/Function/Normalization.swift:128-143 — both copies are in the same file, so extract the 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/GrAIdient/Core/Function/Normalization.swift:96` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (16 lines × 2) Sources/GrAIdient/Core/Optimizer/OptimizerAlgorithm.swift:221 — Sources/GrAIdient/Core/Optimizer/OptimizerAlgorithm.swift:221-236 | Sources/GrAIdient/Core/Optimizer/OptimizerAlgorithm.swift:444-459 — both copies are in the same file, so extract the 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/GrAIdient/Core/Optimizer/OptimizerAlgorithm.swift:221` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 2) Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:174 — Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:174-189 | Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:228-243 — both copies are in the same file, so extract the 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/GrAIdient/Core/Optimizer/OptimizerImpl.swift:174` 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/GrAIdient/Core/Optimizer/OptimizerImpl.swift:244` calls `setBuffer` and `Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:191` 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 lines × 2) Sources/GrAIdient/Layer1D/BCE1D.swift:181 — Sources/GrAIdient/Layer1D/BCE1D.swift:181-196 | Sources/GrAIdient/Layer1D/BCESigmoid1D.swift:204-219 — before extracting anything, compare `Sources/GrAIdient/Layer1D/BCE1D.swift` and `Sources/GrAIdient/Layer1D/BCESigmoid1D.swift` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 218 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (16 lines × 2) Sources/GrAIdient/Layer2D/Convolution2D.swift:1068 — Sources/GrAIdient/Layer2D/Convolution2D.swift:1068-1083 | Sources/GrAIdient/Layer2D/Deconvolution2D.swift:503-518 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Convolution2D.swift` and `Sources/GrAIdient/Layer2D/Deconvolution2D.swift` as WHOLE FILES: this scan already matched 26 separate duplicated blocks between them, totalling at least 499 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/GrAIdient/Layer2D/Convolution2D.swift:1068` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 2) Sources/GrAIdient/Layer2D/MSE2D.swift:356 — Sources/GrAIdient/Layer2D/MSE2D.swift:356-371 | Sources/GrAIdient/Layer2D/MSE2D.swift:385-400 — both copies are in the same file, so extract the 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/GrAIdient/Layer2D/MSE2D.swift:356` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 2) Sources/GrAIdient/Layer2D/Normalize2D.swift:561 — Sources/GrAIdient/Layer2D/Normalize2D.swift:561-576 | Sources/GrAIdient/Layer2D/Normalize2D.swift:716-731 — both copies are in the same file, so extract the 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/GrAIdient/Layer2D/Normalize2D.swift:561` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 2) Sources/GrAIdient/Layer2D/Transform/ColorJitterHSV.swift:93 — Sources/GrAIdient/Layer2D/Transform/ColorJitterHSV.swift:93-109 | Sources/GrAIdient/Layer2D/Transform/DecorrelateRGB.swift:36-51 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Transform/ColorJitterHSV.swift` and `Sources/GrAIdient/Layer2D/Transform/DecorrelateRGB.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/GrAIdient/Layer2D/Transform/ColorJitterHSV.swift:93` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 2) Sources/GrAIdient/Layer2D/Transform/Rotate2D.swift:290 — Sources/GrAIdient/Layer2D/Transform/Rotate2D.swift:290-305 | Sources/GrAIdient/Layer2D/Transform/Rotate2D.swift:352-367 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (16 lines × 2) Sources/GrAIdient/Layer2D/VQ2D.swift:1281 — Sources/GrAIdient/Layer2D/VQ2D.swift:1281-1296 | Sources/GrAIdient/LayerSeq/VQSeq.swift:1198-1213 — before extracting anything, compare `Sources/GrAIdient/Layer2D/VQ2D.swift` and `Sources/GrAIdient/LayerSeq/VQSeq.swift` as WHOLE FILES: this scan already matched 30 separate duplicated blocks between them, totalling at least 378 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/GrAIdient/Layer2D/VQ2D.swift:1281` 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/GrAIdient/Layer2D/VQ2D.swift:1280` calls `UInt32` and `Sources/GrAIdient/LayerSeq/VQSeq.swift:1197` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (16 lines × 2) Sources/GrAIdient/LayerSeq/ValueSeq.swift:155 — Sources/GrAIdient/LayerSeq/ValueSeq.swift:155-170 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:246-261 — both copies are in the same file, so extract the 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/GrAIdient/LayerSeq/ValueSeq.swift:155` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 2) Sources/GrAIdient/LayerSeq/ValueSeq.swift:283 — Sources/GrAIdient/LayerSeq/ValueSeq.swift:283-298 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1565-1580 — both copies are in the same file, so extract the 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/GrAIdient/LayerSeq/ValueSeq.swift:283` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 2) Sources/GrAIdient/LayerSeq/ValueSeq.swift:408 — Sources/GrAIdient/LayerSeq/ValueSeq.swift:408-423 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:997-1012 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/LayerSeq/ValueSeq.swift:408` 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.
D4 · Code Duplication · Members sharing a duplicated core (4 members, 50+ identical tokens) · ×12
  • Members sharing a duplicated core (4 members, 50+ identical tokens) Sources/GrAIdient/Layer1D/BCE1D.swift:52 — Sources/GrAIdient/Layer1D/BCE1D.swift:52-78 | Sources/GrAIdient/Layer1D/BCESigmoid1D.swift:55-81 | Sources/GrAIdient/Layer1D/LinearError1D.swift:50-76 | Sources/GrAIdient/Layer1D/MSE1D.swift:50-76 — 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/GrAIdient/Layer1D/Constant1D.swift:129 — Sources/GrAIdient/Layer1D/Constant1D.swift:129-145 | Sources/GrAIdient/Layer2D/Constant2D.swift:136-152 | Sources/GrAIdient/LayerSeq/ConstantSeq.swift:130-146 | Sources/GrAIdient/LayerSeq/ConstantSeq.swift:615-631 — 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/GrAIdient/Layer1D/FullyConnected.swift:296 — Sources/GrAIdient/Layer1D/FullyConnected.swift:296-307 | Sources/GrAIdient/Layer2D/Convolution2D.swift:475-488 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:200-212 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:180-191 — 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/GrAIdient/Layer1D/FullyConnected.swift:564 — Sources/GrAIdient/Layer1D/FullyConnected.swift:564-595 | Sources/GrAIdient/Layer2D/Convolution2D.swift:768-801 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:455-487 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:430-461 — 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/GrAIdient/Layer1D/FullyConnected.swift:1295 — Sources/GrAIdient/Layer1D/FullyConnected.swift:1295-1319 | Sources/GrAIdient/Layer2D/Convolution2D.swift:1891-1914 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:1373-1397 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:1257-1281 — 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/GrAIdient/Layer2D/Activation2D.swift:281 — Sources/GrAIdient/Layer2D/Activation2D.swift:281-308 | Sources/GrAIdient/Layer2D/BN2D.swift:620-648 | Sources/GrAIdient/Layer2D/InstanceNorm2D.swift:544-572 | Sources/GrAIdient/Layer2D/Transform/LinearScale2D.swift:224-251 — 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/GrAIdient/Layer2D/AdaIN.swift:111 — Sources/GrAIdient/Layer2D/AdaIN.swift:111-123 | Sources/GrAIdient/Layer2D/BN2D.swift:213-225 | Sources/GrAIdient/Layer2D/InstanceNorm2D.swift:138-150 | Sources/GrAIdient/LayerSeq/LayerNormSeq.swift:137-149 — 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/GrAIdient/Layer2D/AdaIN.swift:711 — Sources/GrAIdient/Layer2D/AdaIN.swift:711-721 | Sources/GrAIdient/Layer2D/InstanceNorm2D.swift:642-652 | Sources/GrAIdient/Layer2D/InstanceNorm2D.swift:681-691 | Sources/GrAIdient/Layer2D/InstanceNorm2D.swift:719-729 — 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/GrAIdient/Layer2D/Constant2D.swift:166 — Sources/GrAIdient/Layer2D/Constant2D.swift:166-197 | Sources/GrAIdient/Layer2D/Constant2D.swift:213-246 | Sources/GrAIdient/Layer2D/Input2D.swift:198-222 | Sources/GrAIdient/Layer2D/Input2D.swift:238-263 — 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/GrAIdient/Layer2D/VQ2D.swift:457 — Sources/GrAIdient/Layer2D/VQ2D.swift:457-503 | Sources/GrAIdient/Layer2D/VQ2D.swift:1182-1256 | Sources/GrAIdient/LayerSeq/VQSeq.swift:386-431 | Sources/GrAIdient/LayerSeq/VQSeq.swift:1102-1173 — 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/GrAIdient/LayerSeq/ConstantSeq.swift:275 — Sources/GrAIdient/LayerSeq/ConstantSeq.swift:275-313 | Sources/GrAIdient/LayerSeq/ConstantSeq.swift:320-360 | Sources/GrAIdient/LayerSeq/EmbeddingSeq.swift:465-504 | Sources/GrAIdient/LayerSeq/EmbeddingSeq.swift:511-553 — 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/GrAIdient/LayerSeq/FullyConnectedPatch.swift:260 — Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:260-297 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:309-344 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:238-274 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:286-320 — 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.
D4 · Code Duplication · Duplicated block (18 lines × 2) · ×12
  • Duplicated block (18 lines × 2) Sources/GrAIdient/Layer1D/Constant1D.swift:345 — Sources/GrAIdient/Layer1D/Constant1D.swift:345-362 | Sources/GrAIdient/Layer1D/FullyConnected.swift:820-837 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Constant1D.swift` and `Sources/GrAIdient/Layer1D/FullyConnected.swift` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 51 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. 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/GrAIdient/Layer1D/Constant1D.swift:345` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (18 lines × 2) Sources/GrAIdient/Layer1D/DotProduct1D.swift:159 — Sources/GrAIdient/Layer1D/DotProduct1D.swift:159-176 | Sources/GrAIdient/Layer1D/DotProduct1D.swift:242-259 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/Layer1D/DotProduct1D.swift:159` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Sources/GrAIdient/Layer1D/DotProduct1D.swift:238` calls `download` and `Sources/GrAIdient/Layer1D/DotProduct1D.swift:156` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (18 lines × 2) Sources/GrAIdient/Layer2D/BCESigmoid2D.swift:130 — Sources/GrAIdient/Layer2D/BCESigmoid2D.swift:130-147 | Sources/GrAIdient/Layer2D/BCESigmoid2D.swift:220-237 — both copies are in the same file, so extract the 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/GrAIdient/Layer2D/BCESigmoid2D.swift:130` 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 (18 lines × 2) Sources/GrAIdient/Layer2D/Multiply2D.swift:401 — Sources/GrAIdient/Layer2D/Multiply2D.swift:401-418 | Sources/GrAIdient/LayerSeq/MutiplySeq.swift:366-383 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Multiply2D.swift` and `Sources/GrAIdient/LayerSeq/MutiplySeq.swift` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 103 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/GrAIdient/Layer2D/Multiply2D.swift:401` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (18 lines × 2) Sources/GrAIdient/Layer2D/Transform/Flip2D.swift:189 — Sources/GrAIdient/Layer2D/Transform/Flip2D.swift:189-206 | Sources/GrAIdient/Layer2D/Transform/Flip2D.swift:436-453 — both copies are in the same file, so extract the 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/GrAIdient/Layer2D/Transform/Flip2D.swift:189` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (18 lines × 2) Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift:488 — Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift:488-505 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift:620-637 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (18 lines × 2) Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:636 — Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:636-653 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:581-599 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift` and `Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift` as WHOLE FILES: this scan already matched 54 separate duplicated blocks between them, totalling at least 760 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/GrAIdient/LayerSeq/FullyConnectedPatch.swift:636` 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 (18 lines × 2) Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:641 — Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:641-658 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:814-831 — both copies are in the same file, so extract the 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/GrAIdient/LayerSeq/FullyConnectedPatch.swift:641` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (18 lines × 2) Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:809 — Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:809-826 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:717-735 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift` and `Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift` as WHOLE FILES: this scan already matched 54 separate duplicated blocks between them, totalling at least 760 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/GrAIdient/LayerSeq/FullyConnectedPatch.swift:809` 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 (18 lines × 2) Sources/GrAIdient/LayerSeq/RoPESeq.swift:312 — Sources/GrAIdient/LayerSeq/RoPESeq.swift:312-329 | Sources/GrAIdient/LayerSeq/RoPESeq.swift:389-406 — both copies are in the same file, so extract the 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/GrAIdient/LayerSeq/RoPESeq.swift:312` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (18 lines × 2) Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:588 — Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:588-605 | Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:672-689 — both copies are in the same file, so extract the 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/GrAIdient/Core/Optimizer/OptimizerImpl.swift:692` calls `setBuffer` and `Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:609` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (18 lines × 2) Sources/GrAIdient/Layer2D/AdaIN.swift:198 — Sources/GrAIdient/Layer2D/AdaIN.swift:198-215 | Sources/GrAIdient/Layer2D/InstanceNorm2D.swift:296-313 — before extracting anything, compare `Sources/GrAIdient/Layer2D/AdaIN.swift` and `Sources/GrAIdient/Layer2D/InstanceNorm2D.swift` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 92 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (19 lines × 2) · ×11
  • Duplicated block (19 lines × 2) Sources/GrAITestsUtils/Trainer.swift:254 — Sources/GrAITestsUtils/Trainer.swift:254-272 | Sources/GrAITestsUtils/Trainer.swift:397-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.
  • Duplicated block (19 lines × 2) Sources/GrAIdient/Layer1D/BCESigmoid1D.swift:119 — Sources/GrAIdient/Layer1D/BCESigmoid1D.swift:119-137 | Sources/GrAIdient/Layer1D/BCESigmoid1D.swift:173-191 — both copies are in the same file, so extract the 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/GrAIdient/Layer1D/BCESigmoid1D.swift:119` 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 (19 lines × 2) Sources/GrAIdient/Layer1D/Constant1D.swift:304 — Sources/GrAIdient/Layer1D/Constant1D.swift:304-322 | Sources/GrAIdient/LayerSeq/ConstantSeq.swift:795-813 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Constant1D.swift` and `Sources/GrAIdient/LayerSeq/ConstantSeq.swift` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 267 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/GrAIdient/Layer1D/Constant1D.swift:304` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (19 lines × 2) Sources/GrAIdient/Layer1D/Constant1D.swift:346 — Sources/GrAIdient/Layer1D/Constant1D.swift:346-364 | Sources/GrAIdient/LayerSeq/ConstantSeq.swift:841-859 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Constant1D.swift` and `Sources/GrAIdient/LayerSeq/ConstantSeq.swift` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 267 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/GrAIdient/Layer1D/Constant1D.swift:346` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (19 lines × 2) Sources/GrAIdient/Layer2D/AdaIN.swift:222 — Sources/GrAIdient/Layer2D/AdaIN.swift:222-240 | Sources/GrAIdient/Layer2D/InstanceNorm2D.swift:320-338 — before extracting anything, compare `Sources/GrAIdient/Layer2D/AdaIN.swift` and `Sources/GrAIdient/Layer2D/InstanceNorm2D.swift` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 92 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (19 lines × 2) Sources/GrAIdient/Layer2D/Multiply2D.swift:34 — Sources/GrAIdient/Layer2D/Multiply2D.swift:34-52 | Sources/GrAIdient/Layer2D/Sum2D.swift:23-41 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Multiply2D.swift` and `Sources/GrAIdient/Layer2D/Sum2D.swift` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 100 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (19 lines × 2) Sources/GrAIdient/LayerSeq/MutiplySeq.swift:33 — Sources/GrAIdient/LayerSeq/MutiplySeq.swift:33-51 | Sources/GrAIdient/LayerSeq/SumSeq.swift:22-40 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/MutiplySeq.swift` and `Sources/GrAIdient/LayerSeq/SumSeq.swift` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 153 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (19 lines × 2) Sources/GrAIdient/LayerSeq/QuerySeq.swift:405 — Sources/GrAIdient/LayerSeq/QuerySeq.swift:405-423 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:436-454 — both copies are in the same file, so extract the 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/GrAIdient/LayerSeq/QuerySeq.swift:405` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (19 lines × 2) Sources/GrAIdient/LayerSeq/QuerySeq.swift:1448 — Sources/GrAIdient/LayerSeq/QuerySeq.swift:1448-1466 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:1587-1605 — both copies are in the same file, so extract the 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/GrAIdient/LayerSeq/QuerySeq.swift:1448` 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 (19 lines × 2) Sources/GrAIdient/LayerSeq/ValueSeq.swift:189 — Sources/GrAIdient/LayerSeq/ValueSeq.swift:189-207 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1463-1481 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (19 lines × 2) Sources/GrAIdient/Layer1D/Constant1D.swift:249 — Sources/GrAIdient/Layer1D/Constant1D.swift:249-267 | Sources/GrAIdient/LayerSeq/ConstantSeq.swift:736-754 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Constant1D.swift` and `Sources/GrAIdient/LayerSeq/ConstantSeq.swift` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 267 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.
D4 · Code Duplication · Duplicated block (10 lines × 3) · ×11
  • Duplicated block (10 lines × 3) Sources/GrAIdient/Core/Layer/LayerNormalization.swift:949 — Sources/GrAIdient/Core/Layer/LayerNormalization.swift:949-958 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1643-1652 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1687-1696 — 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/GrAIdient/Layer2D/BN2D.swift:719 — Sources/GrAIdient/Layer2D/BN2D.swift:719-728 | Sources/GrAIdient/Layer2D/BN2D.swift:766-775 | Sources/GrAIdient/Layer2D/BN2D.swift:812-821 — 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/GrAIdient/Layer2D/BN2D.swift:719` 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/GrAIdient/Layer2D/Concat2D.swift:106 — Sources/GrAIdient/Layer2D/Concat2D.swift:106-115 | Sources/GrAIdient/Layer2D/Concat2D.swift:199-208 | Sources/GrAIdient/Layer2D/Concat2D.swift:270-279 — 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/GrAIdient/Layer2D/Concat2D.swift:106` 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/GrAIdient/Layer2D/MSE2D.swift:113 — Sources/GrAIdient/Layer2D/MSE2D.swift:113-124 | Sources/GrAIdient/Layer2D/MSE2D.swift:183-192 | Sources/GrAIdient/Layer2D/MSE2D.swift:343-352 — 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/GrAIdient/Layer2D/MSE2D.swift:113` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (10 lines × 3) Sources/GrAIdient/LayerSeq/ConstantSeq.swift:320 — Sources/GrAIdient/LayerSeq/ConstantSeq.swift:320-331 | Sources/GrAIdient/LayerSeq/ConstantSeq.swift:824-835 | Sources/GrAIdient/LayerSeq/EmbeddingSeq.swift:511-520 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/ConstantSeq.swift` and `Sources/GrAIdient/LayerSeq/EmbeddingSeq.swift` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 90 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/GrAIdient/LayerSeq/ConstantSeq.swift:320` 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/GrAIdient/LayerSeq/EmbeddingSeq.swift:522` calls `download` and `Sources/GrAIdient/LayerSeq/ConstantSeq.swift:333` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (10 lines × 3) Sources/GrAIdient/LayerSeq/QuerySeq.swift:356 — Sources/GrAIdient/LayerSeq/QuerySeq.swift:356-365 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:358-367 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:933-942 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/QuerySeq.swift` and `Sources/GrAIdient/LayerSeq/ValueSeq.swift` as WHOLE FILES: this scan already matched 39 separate duplicated blocks between them, totalling at least 427 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/GrAIdient/LayerSeq/QuerySeq.swift:356` 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/GrAIdient/LayerSeq/SoftmaxSeq.swift:248 — Sources/GrAIdient/LayerSeq/SoftmaxSeq.swift:248-257 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:369-378 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:946-955 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/SoftmaxSeq.swift` and `Sources/GrAIdient/LayerSeq/ValueSeq.swift` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 95 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Sources/GrAIdient/LayerSeq/ValueSeq.swift:379` calls `setBuffer` and `Sources/GrAIdient/LayerSeq/SoftmaxSeq.swift:258` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (10 lines × 3) Sources/GrAIdient/LayerSeq/SoftmaxSeq.swift:343 — Sources/GrAIdient/LayerSeq/SoftmaxSeq.swift:343-352 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:510-519 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1112-1121 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/SoftmaxSeq.swift` and `Sources/GrAIdient/LayerSeq/ValueSeq.swift` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 95 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (10 lines × 3) Sources/GrAIdient/Layer1D/Activation1D.swift:110 — Sources/GrAIdient/Layer1D/Activation1D.swift:110-119 | Sources/GrAIdient/Layer2D/Activation2D.swift:117-126 | Sources/GrAIdient/LayerSeq/ActivationSeq.swift:114-123 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Activation1D.swift` and `Sources/GrAIdient/Layer2D/Activation2D.swift` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 83 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 × 3) Sources/GrAIdient/Layer1D/FullyConnected.swift:1189 — Sources/GrAIdient/Layer1D/FullyConnected.swift:1189-1198 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:1267-1276 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:1151-1160 — before extracting anything, compare `Sources/GrAIdient/Layer1D/FullyConnected.swift` and `Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift` as WHOLE FILES: this scan already matched 32 separate duplicated blocks between them, totalling at least 473 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 × 3) Sources/GrAIdient/Layer1D/FullyConnected.swift:1201 — Sources/GrAIdient/Layer1D/FullyConnected.swift:1201-1210 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:1279-1288 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:1163-1172 — before extracting anything, compare `Sources/GrAIdient/Layer1D/FullyConnected.swift` and `Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift` as WHOLE FILES: this scan already matched 32 separate duplicated blocks between them, totalling at least 473 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.
D3 · God Classes · FileTooLong · ×10
  • FileTooLong: Layer/LayerNormalization.swift Sources/GrAIdient/Core/Layer/LayerNormalization.swift — FileTooLong — 1579 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 1079 over it, 3.16× 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: LayerSeq/ValueSeq.swift Sources/GrAIdient/LayerSeq/ValueSeq.swift — FileTooLong — 1129 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 629 over it, 2.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: LayerSeq/QuerySeq.swift Sources/GrAIdient/LayerSeq/QuerySeq.swift — FileTooLong — 1128 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 628 over it, 2.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: Layer2D/Convolution2D.swift Sources/GrAIdient/Layer2D/Convolution2D.swift — FileTooLong — 993 significant lines (blank, comment-only and punctuation-only lines excluded), about 100% of them inside a single declaration: Convolution2D (26-1915). The bar is 500 significant lines; this is 493 over it, 1.99× 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: LayerSeq/FullyConnectedPatch.swift Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift — FileTooLong — 717 significant lines (blank, comment-only and punctuation-only lines excluded), about 100% of them inside a single declaration: FullyConnectedPatch (16-1398). The bar is 500 significant lines; this is 217 over it, 1.43× 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: LayerSeq/FullyConnectedSeq.swift Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift — FileTooLong — 625 significant lines (blank, comment-only and punctuation-only lines excluded), about 100% of them inside a single declaration: FullyConnectedSeq (11-1282). The bar is 500 significant lines; this is 125 over it, 1.25× 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: Layer2D/VQ2D.swift Sources/GrAIdient/Layer2D/VQ2D.swift — FileTooLong — 618 significant lines (blank, comment-only and punctuation-only lines excluded), about 66% of them inside a single declaration: VQ2D (35-921). The bar is 500 significant lines; this is 118 over it, 1.24× 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: Layer1D/FullyConnected.swift Sources/GrAIdient/Layer1D/FullyConnected.swift — FileTooLong — 616 significant lines (blank, comment-only and punctuation-only lines excluded), about 100% of them inside a single declaration: FullyConnected (16-1320). The bar is 500 significant lines; this is 116 over it, 1.23× 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: LayerSeq/VQSeq.swift Sources/GrAIdient/LayerSeq/VQSeq.swift — FileTooLong — 591 significant lines (blank, comment-only and punctuation-only lines excluded), about 66% of them inside a single declaration: VQSeq (12-841). The bar is 500 significant lines; this is 91 over it, 1.18× 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: GrAITestsUtils/Trainer.swift Sources/GrAITestsUtils/Trainer.swift — FileTooLong — 525 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 25 over it, 1.05× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
D3 · God Classes · ClassTooLong · ×9
  • ClassTooLong: Convolution2D Sources/GrAIdient/Layer2D/Convolution2D.swift:26 — ClassTooLong — 991 significant lines (blank, comment-only and punctuation-only lines excluded), 31 methods. The bar is 400 significant lines; this is 591 over it, 2.48× 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: FullyConnectedPatch Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:16 — ClassTooLong — 716 significant lines (blank, comment-only and punctuation-only lines excluded), 30 methods. The bar is 400 significant lines; this is 316 over it, 1.79× 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: FullyConnectedSeq Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:11 — ClassTooLong — 624 significant lines (blank, comment-only and punctuation-only lines excluded), 30 methods. The bar is 400 significant lines; this is 224 over it, 1.56× 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: FullyConnected Sources/GrAIdient/Layer1D/FullyConnected.swift:16 — ClassTooLong — 615 significant lines (blank, comment-only and punctuation-only lines excluded), 30 methods. The bar is 400 significant lines; this is 215 over it, 1.54× 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: QueryCausalSeq Sources/GrAIdient/LayerSeq/QuerySeq.swift:1005 — ClassTooLong — 591 significant lines (blank, comment-only and punctuation-only lines excluded), 22 methods. The bar is 400 significant lines; this is 191 over it, 1.48× 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: ValueCausalSeq Sources/GrAIdient/LayerSeq/ValueSeq.swift:1161 — ClassTooLong — 497 significant lines (blank, comment-only and punctuation-only lines excluded), 18 methods. The bar is 400 significant lines; this is 97 over it, 1.24× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: Deconvolution2D Sources/GrAIdient/Layer2D/Deconvolution2D.swift:22 — ClassTooLong — 469 significant lines (blank, comment-only and punctuation-only lines excluded), 10 methods. The bar is 400 significant lines; this is 69 over it, 1.17× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: AdaptiveAvgPool2D Sources/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:23 — ClassTooLong — 441 significant lines (blank, comment-only and punctuation-only lines excluded), 15 methods. The bar is 400 significant lines; this is 41 over it, 1.10× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: VQ2D Sources/GrAIdient/Layer2D/VQ2D.swift:35 — ClassTooLong — 407 significant lines (blank, comment-only and punctuation-only lines excluded), 29 methods. The bar is 400 significant lines; this is 7 over it, 1.02× 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 · Duplicated block (20 lines × 2) · ×9
  • Duplicated block (20 lines × 2) Sources/GrAITestsUtils/Trainer.swift:808 — Sources/GrAITestsUtils/Trainer.swift:808-827 | Sources/GrAITestsUtils/Trainer.swift:928-947 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (20 lines × 2) Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1320 — Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1320-1339 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1356-1375 — both copies are in the same file, so extract the 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/GrAIdient/Core/Layer/LayerNormalization.swift:1320` 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/GrAIdient/Layer1D/Constant1D.swift:223 — Sources/GrAIdient/Layer1D/Constant1D.swift:223-242 | Sources/GrAIdient/LayerSeq/ConstantSeq.swift:710-729 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Constant1D.swift` and `Sources/GrAIdient/LayerSeq/ConstantSeq.swift` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 267 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 (20 lines × 2) Sources/GrAIdient/Layer2D/Convolution2D.swift:893 — Sources/GrAIdient/Layer2D/Convolution2D.swift:893-912 | Sources/GrAIdient/Layer2D/Deconvolution2D.swift:324-343 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Convolution2D.swift` and `Sources/GrAIdient/Layer2D/Deconvolution2D.swift` as WHOLE FILES: this scan already matched 26 separate duplicated blocks between them, totalling at least 499 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/GrAIdient/Layer2D/Convolution2D.swift:893` it begins part-way through the construct above it, so those exact lines 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/GrAIdient/Layer2D/Multiply2D.swift:526 — Sources/GrAIdient/Layer2D/Multiply2D.swift:526-545 | Sources/GrAIdient/LayerSeq/MutiplySeq.swift:485-504 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Multiply2D.swift` and `Sources/GrAIdient/LayerSeq/MutiplySeq.swift` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 103 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/GrAIdient/Layer2D/Multiply2D.swift:526` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (20 lines × 2) Sources/GrAIdient/Layer2D/SimilarityError2D.swift:215 — Sources/GrAIdient/Layer2D/SimilarityError2D.swift:215-234 | Sources/GrAIdient/Layer2D/SimilarityError2D.swift:306-325 — both copies are in the same file, so extract the 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/GrAIdient/Layer2D/SimilarityError2D.swift:215` 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/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:604 — Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:604-623 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift:530-549 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift` and `Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 252 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/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:604` 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/GrAIdient/Layer2D/VQ2D.swift:836 — Sources/GrAIdient/Layer2D/VQ2D.swift:836-855 | Sources/GrAIdient/LayerSeq/VQSeq.swift:757-776 — before extracting anything, compare `Sources/GrAIdient/Layer2D/VQ2D.swift` and `Sources/GrAIdient/LayerSeq/VQSeq.swift` as WHOLE FILES: this scan already matched 30 separate duplicated blocks between them, totalling at least 378 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 (20 lines × 2) Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:495 — Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:495-514 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:469-488 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift` and `Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift` as WHOLE FILES: this scan already matched 54 separate duplicated blocks between them, totalling at least 760 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (12 lines × 4) · ×9
  • Duplicated block (12 lines × 4) Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:263 — Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:263-274 | Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:333-344 | Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:544-555 | Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:626-637 — 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/GrAIdient/Core/Optimizer/OptimizerImpl.swift:263` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:348` calls `max` and `Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:279` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (12 lines × 4) Sources/GrAIdient/Layer1D/Concat1D.swift:101 — Sources/GrAIdient/Layer1D/Concat1D.swift:101-112 | Sources/GrAIdient/Layer1D/Concat1D.swift:182-193 | Sources/GrAIdient/Layer2D/Concat2D.swift:120-131 | Sources/GrAIdient/Layer2D/Concat2D.swift:213-224 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Concat1D.swift` and `Sources/GrAIdient/Layer2D/Concat2D.swift` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 87 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. 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/GrAIdient/Layer1D/Concat1D.swift:101` 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 (12 lines × 4) Sources/GrAIdient/Layer1D/FullyConnected.swift:1094 — Sources/GrAIdient/Layer1D/FullyConnected.swift:1094-1105 | Sources/GrAIdient/Layer1D/FullyConnected.swift:1130-1141 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:1206-1217 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:1091-1102 — before extracting anything, compare `Sources/GrAIdient/Layer1D/FullyConnected.swift` and `Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift` as WHOLE FILES: this scan already matched 32 separate duplicated blocks between them, totalling at least 473 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/GrAIdient/Layer1D/FullyConnected.swift:1094` 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/GrAIdient/LayerSeq/FullyConnectedPatch.swift:1218` calls `setBytes` and `Sources/GrAIdient/Layer1D/FullyConnected.swift:1142` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (12 lines × 4) Sources/GrAIdient/Layer2D/Concat2D.swift:58 — Sources/GrAIdient/Layer2D/Concat2D.swift:58-69 | Sources/GrAIdient/Layer2D/Multiply2D.swift:80-91 | Sources/GrAIdient/Layer2D/SimilarityError2D.swift:122-133 | Sources/GrAIdient/Layer2D/Sum2D.swift:69-80 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Concat2D.swift` and `Sources/GrAIdient/Layer2D/Multiply2D.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/GrAIdient/Layer2D/Concat2D.swift:58` 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 (12 lines × 4) Sources/GrAIdient/Layer2D/Transform/FTFrequences2D.swift:151 — Sources/GrAIdient/Layer2D/Transform/FTFrequences2D.swift:151-162 | Sources/GrAIdient/Layer2D/Transform/FTFrequences2D.swift:168-179 | Sources/GrAIdient/Layer2D/Transform/FTFrequences2D.swift:189-200 | Sources/GrAIdient/Layer2D/Transform/FTFrequences2D.swift:206-217 — 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/GrAIdient/Layer2D/Transform/FTFrequences2D.swift:151` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 4) Sources/GrAIdient/LayerSeq/ActivationSeq.swift:184 — Sources/GrAIdient/LayerSeq/ActivationSeq.swift:184-195 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:699-710 | Sources/GrAIdient/LayerSeq/RoPESeq.swift:241-252 | Sources/GrAIdient/LayerSeq/SoftmaxSeq.swift:123-134 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/QuerySeq.swift` and `Sources/GrAIdient/LayerSeq/RoPESeq.swift` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 52 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/GrAIdient/LayerSeq/ActivationSeq.swift:184` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 4) Sources/GrAIdient/LayerSeq/QuerySeq.swift:422 — Sources/GrAIdient/LayerSeq/QuerySeq.swift:422-433 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:453-464 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:1929-1940 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:1969-1980 — 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/GrAIdient/LayerSeq/QuerySeq.swift:422` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 4) Sources/GrAIdient/LayerSeq/QuerySeq.swift:486 — Sources/GrAIdient/LayerSeq/QuerySeq.swift:486-497 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:2005-2016 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:486-497 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1997-2008 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/QuerySeq.swift` and `Sources/GrAIdient/LayerSeq/ValueSeq.swift` as WHOLE FILES: this scan already matched 39 separate duplicated blocks between them, totalling at least 427 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/GrAIdient/LayerSeq/QuerySeq.swift:486` 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 × 4) Sources/GrAIdient/Layer2D/BN2D.swift:44 — Sources/GrAIdient/Layer2D/BN2D.swift:44-55 | Sources/GrAIdient/Layer2D/InstanceNorm2D.swift:44-55 | Sources/GrAIdient/LayerSeq/LayerNormSeq.swift:44-55 | Sources/GrAIdient/LayerSeq/RMSNormSeq.swift:47-58 — before extracting anything, compare `Sources/GrAIdient/Layer2D/BN2D.swift` and `Sources/GrAIdient/Layer2D/InstanceNorm2D.swift` as WHOLE FILES: this scan already matched 21 separate duplicated blocks between them, totalling at least 320 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (7 lines × 3) · ×9
  • Duplicated block (7 lines × 3) Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1785 — Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1785-1791 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1819-1825 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:2569-2575 — 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/GrAIdient/Core/Layer/LayerNormalization.swift:1785` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 3) Sources/GrAIdient/Layer1D/Base/LayerOutput1D.swift:53 — Sources/GrAIdient/Layer1D/Base/LayerOutput1D.swift:53-59 | Sources/GrAIdient/Layer2D/Base/LayerOutput2D.swift:55-61 | Sources/GrAIdient/Layer2D/SimilarityError2D.swift:83-89 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Base/LayerOutput1D.swift` and `Sources/GrAIdient/Layer2D/Base/LayerOutput2D.swift` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 78 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (7 lines × 3) Sources/GrAIdient/Layer1D/FullyConnected.swift:1122 — Sources/GrAIdient/Layer1D/FullyConnected.swift:1122-1128 | Sources/GrAIdient/Layer2D/Constant2D.swift:551-558 | Sources/GrAIdient/LayerSeq/ConstantSeq.swift:986-993 — before extracting anything, compare `Sources/GrAIdient/Layer1D/FullyConnected.swift` and `Sources/GrAIdient/Layer2D/Constant2D.swift` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 36 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/GrAIdient/Layer1D/FullyConnected.swift:1122` 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/GrAIdient/Layer1D/FullyConnected.swift:1121` calls `setBuffer` and `Sources/GrAIdient/Layer2D/Constant2D.swift:551` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (7 lines × 3) Sources/GrAIdient/Layer1D/LinearError1D.swift:297 — Sources/GrAIdient/Layer1D/LinearError1D.swift:297-303 | Sources/GrAIdient/Layer1D/Softmax1D.swift:311-317 | Sources/GrAIdient/Layer2D/SimilarityBatchError2D.swift:334-340 — 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. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Sources/GrAIdient/Layer1D/Softmax1D.swift:318` calls `setBuffer` and `Sources/GrAIdient/Layer1D/LinearError1D.swift:304` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (7 lines × 3) Sources/GrAIdient/Layer2D/Convolution2D.swift:1664 — Sources/GrAIdient/Layer2D/Convolution2D.swift:1664-1670 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:1174-1180 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:1061-1067 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Convolution2D.swift` and `Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift` as WHOLE FILES: this scan already matched 23 separate duplicated blocks between them, totalling at least 186 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/GrAIdient/Layer2D/Convolution2D.swift:1664` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 3) Sources/GrAIdient/Layer2D/Normalize2D.swift:285 — Sources/GrAIdient/Layer2D/Normalize2D.swift:285-291 | Sources/GrAIdient/Layer2D/Normalize2D.swift:758-764 | Sources/GrAIdient/Layer2D/SelfCorrelate2D.swift:268-274 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Normalize2D.swift` and `Sources/GrAIdient/Layer2D/SelfCorrelate2D.swift` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 74 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Sources/GrAIdient/Layer2D/Normalize2D.swift:765` calls `setBuffer` and `Sources/GrAIdient/Layer2D/SelfCorrelate2D.swift:275` 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 (7 lines × 3) Sources/GrAIdient/LayerSeq/ConcatSeq.swift:283 — Sources/GrAIdient/LayerSeq/ConcatSeq.swift:283-291 | Sources/GrAIdient/LayerSeq/ConcatSeq.swift:715-723 | Sources/GrAIdient/LayerSeq/EmbeddingSeq.swift:583-589 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/LayerSeq/ConcatSeq.swift:283` 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 (7 lines × 3) Sources/GrAIdient/LayerSeq/EmbeddingSeq.swift:587 — Sources/GrAIdient/LayerSeq/EmbeddingSeq.swift:587-593 | Sources/GrAIdient/LayerSeq/RoPESeq.swift:361-367 | Sources/GrAIdient/LayerSeq/VQSeq.swift:753-759 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/EmbeddingSeq.swift` and `Sources/GrAIdient/LayerSeq/VQSeq.swift` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 112 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/GrAIdient/LayerSeq/RoPESeq.swift:360` calls `UInt32` and `Sources/GrAIdient/LayerSeq/EmbeddingSeq.swift:585` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (7 lines × 3) Sources/GrAIdient/Layer1D/Base/LayerMerge1D.swift:119 — Sources/GrAIdient/Layer1D/Base/LayerMerge1D.swift:119-125 | Sources/GrAIdient/Layer2D/Base/LayerMerge2D.swift:177-183 | Sources/GrAIdient/LayerSeq/Base/LayerMergeSeq.swift:122-128 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Base/LayerMerge1D.swift` and `Sources/GrAIdient/Layer2D/Base/LayerMerge2D.swift` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 129 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.
D4 · Code Duplication · Duplicated block (5 lines × 2) · ×9
  • Duplicated block (5 lines × 2) Sources/GrAIdient/Core/Layer/LayerNormalization.swift:986 — Sources/GrAIdient/Core/Layer/LayerNormalization.swift:986-990 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:3112-3116 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Sources/GrAIdient/Core/Layer/LayerNormalization.swift:983` calls `setBuffer` and `Sources/GrAIdient/Core/Layer/LayerNormalization.swift:3110` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (5 lines × 2) Sources/GrAIdient/Core/Layer/LayerNormalization.swift:985 — Sources/GrAIdient/Core/Layer/LayerNormalization.swift:985-989 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1098-1102 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Sources/GrAIdient/Core/Layer/LayerNormalization.swift:983` calls `setBuffer` and `Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1097` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (5 lines × 2) Sources/GrAIdient/Layer1D/Dropout1D.swift:342 — Sources/GrAIdient/Layer1D/Dropout1D.swift:342-346 | Sources/GrAIdient/Layer1D/Dropout1D.swift:422-426 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (5 lines × 2) Sources/GrAIdient/Layer1D/SelectNeurons1D.swift:252 — Sources/GrAIdient/Layer1D/SelectNeurons1D.swift:252-256 | Sources/GrAIdient/Layer1D/SelectNeurons1D.swift:329-333 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (5 lines × 2) Sources/GrAIdient/LayerSeq/QuerySeq.swift:1491 — Sources/GrAIdient/LayerSeq/QuerySeq.swift:1491-1495 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1514-1518 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/QuerySeq.swift` and `Sources/GrAIdient/LayerSeq/ValueSeq.swift` as WHOLE FILES: this scan already matched 39 separate duplicated blocks between them, totalling at least 427 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (5 lines × 2) Sources/GrAIdient/LayerSeq/RoPESeq.swift:369 — Sources/GrAIdient/LayerSeq/RoPESeq.swift:369-373 | Sources/GrAIdient/LayerSeq/RoPESeq.swift:456-460 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (5 lines × 2) Sources/GrAIdient/Layer2D/VQ2D.swift:1140 — Sources/GrAIdient/Layer2D/VQ2D.swift:1140-1144 | Sources/GrAIdient/LayerSeq/VQSeq.swift:1060-1064 — before extracting anything, compare `Sources/GrAIdient/Layer2D/VQ2D.swift` and `Sources/GrAIdient/LayerSeq/VQSeq.swift` as WHOLE FILES: this scan already matched 30 separate duplicated blocks between them, totalling at least 378 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 × 2) Sources/GrAIdient/Layer2D/VQ2D.swift:1171 — Sources/GrAIdient/Layer2D/VQ2D.swift:1171-1175 | Sources/GrAIdient/LayerSeq/VQSeq.swift:1091-1095 — before extracting anything, compare `Sources/GrAIdient/Layer2D/VQ2D.swift` and `Sources/GrAIdient/LayerSeq/VQSeq.swift` as WHOLE FILES: this scan already matched 30 separate duplicated blocks between them, totalling at least 378 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 × 2) Sources/GrAIdient/Layer2D/Multiply2D.swift:203 — Sources/GrAIdient/Layer2D/Multiply2D.swift:203-207 | Sources/GrAIdient/Layer2D/Multiply2D.swift:293-297 — both copies are in the same file, so extract the 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/GrAIdient/Layer2D/Multiply2D.swift:203` 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 · Duplicated block (12 lines × 3) · ×8
  • Duplicated block (12 lines × 3) Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1064 — Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1064-1075 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1846-1857 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:2599-2610 — 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/GrAIdient/Core/Layer/LayerNormalization.swift:1064` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 3) Sources/GrAIdient/Layer1D/Concat1D.swift:48 — Sources/GrAIdient/Layer1D/Concat1D.swift:48-59 | Sources/GrAIdient/Layer1D/DotProduct1D.swift:94-105 | Sources/GrAIdient/Layer1D/Sum1D.swift:65-76 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Concat1D.swift` and `Sources/GrAIdient/Layer1D/DotProduct1D.swift` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 46 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/Layer1D/Concat1D.swift:48` 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 (12 lines × 3) Sources/GrAIdient/Layer1D/Concat1D.swift:366 — Sources/GrAIdient/Layer1D/Concat1D.swift:366-377 | Sources/GrAIdient/Layer2D/Concat2D.swift:410-421 | Sources/GrAIdient/LayerSeq/ConcatSeq.swift:829-840 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Concat1D.swift` and `Sources/GrAIdient/Layer2D/Concat2D.swift` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 87 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. 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/GrAIdient/Layer1D/Concat1D.swift:366` 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 (12 lines × 3) Sources/GrAIdient/Layer1D/LinearError1D.swift:146 — Sources/GrAIdient/Layer1D/LinearError1D.swift:146-157 | Sources/GrAIdient/Layer1D/MSE1D.swift:146-157 | Sources/GrAIdient/Layer1D/MSE1D.swift:271-282 — before extracting anything, compare `Sources/GrAIdient/Layer1D/LinearError1D.swift` and `Sources/GrAIdient/Layer1D/MSE1D.swift` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 104 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/GrAIdient/Layer1D/LinearError1D.swift:146` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 3) Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:331 — Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:331-342 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:461-472 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:629-640 — 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/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:331` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 3) Sources/GrAIdient/LayerSeq/QuerySeq.swift:403 — Sources/GrAIdient/LayerSeq/QuerySeq.swift:403-415 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:434-446 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:406-417 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/QuerySeq.swift` and `Sources/GrAIdient/LayerSeq/ValueSeq.swift` as WHOLE FILES: this scan already matched 39 separate duplicated blocks between them, totalling at least 427 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/GrAIdient/LayerSeq/QuerySeq.swift:403` 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 after the matched lines, `Sources/GrAIdient/LayerSeq/ValueSeq.swift:418` calls `get` and `Sources/GrAIdient/LayerSeq/QuerySeq.swift:415` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (12 lines × 3) Sources/GrAIdient/LayerSeq/RoPESeq.swift:263 — Sources/GrAIdient/LayerSeq/RoPESeq.swift:263-274 | Sources/GrAIdient/LayerSeq/RoPESeq.swift:320-331 | Sources/GrAIdient/LayerSeq/RoPESeq.swift:397-408 — 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/GrAIdient/LayerSeq/RoPESeq.swift:263` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 3) Sources/GrAIdient/LayerSeq/ValueSeq.swift:538 — Sources/GrAIdient/LayerSeq/ValueSeq.swift:538-549 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1142-1153 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:2053-2064 — 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/GrAIdient/LayerSeq/ValueSeq.swift:538` 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.
D4 · Code Duplication · Duplicated block (9 lines × 3) · ×8
  • Duplicated block (9 lines × 3) Sources/GrAITestsUtils/Trainer.swift:820 — Sources/GrAITestsUtils/Trainer.swift:820-828 | Sources/GrAITestsUtils/Trainer.swift:940-948 | Sources/GrAITestsUtils/Trainer.swift:968-976 — 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/GrAIdient/Layer1D/Base/LayerOutput1D.swift:232 — Sources/GrAIdient/Layer1D/Base/LayerOutput1D.swift:232-240 | Sources/GrAIdient/Layer1D/SelectNeurons1D.swift:175-183 | Sources/GrAIdient/Layer1D/Softmax1D.swift:121-129 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/Layer1D/Base/LayerOutput1D.swift:232` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 3) Sources/GrAIdient/Layer1D/FullyConnected.swift:299 — Sources/GrAIdient/Layer1D/FullyConnected.swift:299-307 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:204-212 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:183-191 — before extracting anything, compare `Sources/GrAIdient/Layer1D/FullyConnected.swift` and `Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift` as WHOLE FILES: this scan already matched 32 separate duplicated blocks between them, totalling at least 473 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/GrAIdient/Layer1D/FullyConnected.swift:299` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:203` calls `decode` and `Sources/GrAIdient/Layer1D/FullyConnected.swift:298` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (9 lines × 3) Sources/GrAIdient/Layer2D/Base/LayerOutput2D.swift:383 — Sources/GrAIdient/Layer2D/Base/LayerOutput2D.swift:383-391 | Sources/GrAIdient/Layer2D/Concat2D.swift:366-374 | Sources/GrAIdient/Layer2D/Input2D.swift:480-490 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Base/LayerOutput2D.swift` and `Sources/GrAIdient/Layer2D/Input2D.swift` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 136 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/GrAIdient/Layer2D/Base/LayerOutput2D.swift:383` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (9 lines × 3) Sources/GrAIdient/Layer2D/Constant2D.swift:461 — Sources/GrAIdient/Layer2D/Constant2D.swift:461-469 | Sources/GrAIdient/Layer2D/Normalize2D.swift:183-191 | Sources/GrAIdient/Layer2D/Transform/IRDFT2RGB.swift:196-204 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Constant2D.swift` and `Sources/GrAIdient/Layer2D/Transform/IRDFT2RGB.swift` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 47 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (9 lines × 3) Sources/GrAIdient/Layer2D/Sum2D.swift:117 — Sources/GrAIdient/Layer2D/Sum2D.swift:117-125 | Sources/GrAIdient/Layer2D/Sum2D.swift:207-215 | Sources/GrAIdient/Layer2D/Sum2D.swift:274-283 — 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/GrAIdient/Layer2D/Sum2D.swift:117` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (9 lines × 3) Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:561 — Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:561-569 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:653-661 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:887-895 — 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/GrAIdient/LayerSeq/FullyConnectedPatch.swift:561` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 3) Sources/GrAIdient/Layer1D/Base/LayerMerge1D.swift:194 — Sources/GrAIdient/Layer1D/Base/LayerMerge1D.swift:194-202 | Sources/GrAIdient/Layer2D/Base/LayerMerge2D.swift:252-260 | Sources/GrAIdient/LayerSeq/Base/LayerMergeSeq.swift:197-205 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Base/LayerMerge1D.swift` and `Sources/GrAIdient/Layer2D/Base/LayerMerge2D.swift` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 129 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.
D4 · Code Duplication · Duplicated block (8 lines × 3) · ×8
  • Duplicated block (8 lines × 3) Sources/GrAIdient/Layer1D/Activation1D.swift:221 — Sources/GrAIdient/Layer1D/Activation1D.swift:221-230 | Sources/GrAIdient/Layer1D/Base/LayerOutput1D.swift:270-277 | Sources/GrAIdient/Layer1D/SelectNeurons1D.swift:216-225 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Activation1D.swift` and `Sources/GrAIdient/Layer1D/Base/LayerOutput1D.swift` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 130 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/GrAIdient/Layer1D/Activation1D.swift:221` 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/GrAIdient/Layer1D/Constant1D.swift:464 — Sources/GrAIdient/Layer1D/Constant1D.swift:464-471 | Sources/GrAIdient/Layer1D/Constant1D.swift:498-505 | Sources/GrAIdient/LayerSeq/ConstantSeq.swift:1006-1013 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Constant1D.swift` and `Sources/GrAIdient/LayerSeq/ConstantSeq.swift` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 267 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/GrAIdient/Layer1D/Constant1D.swift:464` 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 (8 lines × 3) Sources/GrAIdient/Layer2D/BN2D.swift:745 — Sources/GrAIdient/Layer2D/BN2D.swift:745-752 | Sources/GrAIdient/Layer2D/BN2D.swift:791-798 | Sources/GrAIdient/Layer2D/BN2D.swift:837-844 — 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/GrAIdient/Layer2D/BN2D.swift:745` 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/GrAIdient/Layer2D/Convolution2D.swift:1362 — Sources/GrAIdient/Layer2D/Convolution2D.swift:1362-1369 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:933-940 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:837-844 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Convolution2D.swift` and `Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift` as WHOLE FILES: this scan already matched 23 separate duplicated blocks between them, totalling at least 186 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/GrAIdient/Layer2D/Convolution2D.swift:1362` it begins part-way through the construct above it, so those 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/GrAIdient/LayerSeq/FullyConnectedPatch.swift:941` calls `setBytes` and `Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:845` 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 × 3) Sources/GrAIdient/Layer2D/Convolution2D.swift:1706 — Sources/GrAIdient/Layer2D/Convolution2D.swift:1706-1713 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:1214-1221 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:1099-1106 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Convolution2D.swift` and `Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift` as WHOLE FILES: this scan already matched 23 separate duplicated blocks between them, totalling at least 186 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/GrAIdient/Layer2D/Convolution2D.swift:1706` it begins part-way through the construct above it, so those exact lines 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/GrAIdient/LayerSeq/ValueSeq.swift:528 — Sources/GrAIdient/LayerSeq/ValueSeq.swift:528-535 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1130-1137 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:2041-2048 — 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/GrAIdient/LayerSeq/ValueSeq.swift:528` it begins part-way through the construct above it, so those exact lines 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/GrAIdient/Layer1D/Activation1D.swift:90 — Sources/GrAIdient/Layer1D/Activation1D.swift:90-97 | Sources/GrAIdient/Layer2D/Activation2D.swift:97-104 | Sources/GrAIdient/LayerSeq/ActivationSeq.swift:94-101 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Activation1D.swift` and `Sources/GrAIdient/Layer2D/Activation2D.swift` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 83 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (8 lines × 3) Sources/GrAIdient/Layer2D/AdaIN.swift:91 — Sources/GrAIdient/Layer2D/AdaIN.swift:91-98 | Sources/GrAIdient/Layer2D/InstanceNorm2D.swift:118-125 | Sources/GrAIdient/LayerSeq/LayerNormSeq.swift:117-124 — before extracting anything, compare `Sources/GrAIdient/Layer2D/AdaIN.swift` and `Sources/GrAIdient/Layer2D/InstanceNorm2D.swift` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 92 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (6 lines × 4) · ×8
  • Duplicated block (6 lines × 4) Sources/GrAIdient/Core/Layer/LayerNormalization.swift:905 — Sources/GrAIdient/Core/Layer/LayerNormalization.swift:905-910 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1785-1790 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1819-1824 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:2569-2574 — 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/GrAIdient/Core/Layer/LayerNormalization.swift:905` it begins part-way through the construct above it, so those exact lines 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 × 4) Sources/GrAIdient/Layer1D/FullyConnected.swift:300 — Sources/GrAIdient/Layer1D/FullyConnected.swift:300-305 | Sources/GrAIdient/Layer2D/Convolution2D.swift:481-486 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:205-210 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:184-189 — before extracting anything, compare `Sources/GrAIdient/Layer1D/FullyConnected.swift` and `Sources/GrAIdient/Layer2D/Convolution2D.swift` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 103 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/GrAIdient/Layer2D/Convolution2D.swift:478` calls `decode` and `Sources/GrAIdient/Layer1D/FullyConnected.swift:298` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (6 lines × 4) Sources/GrAIdient/Layer1D/FullyConnected.swift:1047 — Sources/GrAIdient/Layer1D/FullyConnected.swift:1047-1052 | Sources/GrAIdient/Layer2D/Convolution2D.swift:1558-1563 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:1106-1111 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:998-1003 — before extracting anything, compare `Sources/GrAIdient/Layer1D/FullyConnected.swift` and `Sources/GrAIdient/Layer2D/Convolution2D.swift` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 103 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/GrAIdient/Layer1D/FullyConnected.swift:1047` it begins part-way through the construct above it, so those exact lines 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 × 4) Sources/GrAIdient/Layer1D/FullyConnected.swift:1174 — Sources/GrAIdient/Layer1D/FullyConnected.swift:1174-1179 | Sources/GrAIdient/Layer2D/Convolution2D.swift:1744-1749 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:1252-1257 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:1136-1141 — before extracting anything, compare `Sources/GrAIdient/Layer1D/FullyConnected.swift` and `Sources/GrAIdient/Layer2D/Convolution2D.swift` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 103 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/GrAIdient/Layer1D/FullyConnected.swift:1174` it begins part-way through the construct above it, so those exact lines 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 × 4) Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:573 — Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:573-578 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:696-701 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift:494-499 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift:626-631 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift` and `Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 252 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/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:573` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 4) Sources/GrAIdient/LayerSeq/QuerySeq.swift:322 — Sources/GrAIdient/LayerSeq/QuerySeq.swift:322-327 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:1612-1617 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:324-329 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1606-1611 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/QuerySeq.swift` and `Sources/GrAIdient/LayerSeq/ValueSeq.swift` as WHOLE FILES: this scan already matched 39 separate duplicated blocks between them, totalling at least 427 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/GrAIdient/LayerSeq/QuerySeq.swift:322` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 4) Sources/GrAIdient/Layer1D/Softmax1D.swift:59 — Sources/GrAIdient/Layer1D/Softmax1D.swift:59-64 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:65-70 | Sources/GrAIdient/LayerSeq/SoftmaxSeq.swift:61-66 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:69-74 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Softmax1D.swift` and `Sources/GrAIdient/LayerSeq/SoftmaxSeq.swift` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 38 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 (6 lines × 4) Sources/GrAIdient/Layer1D/Softmax1D.swift:77 — Sources/GrAIdient/Layer1D/Softmax1D.swift:77-82 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:83-88 | Sources/GrAIdient/LayerSeq/SoftmaxSeq.swift:79-84 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:87-92 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Softmax1D.swift` and `Sources/GrAIdient/LayerSeq/SoftmaxSeq.swift` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 38 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.
D4 · Code Duplication · Duplicated block (6 lines × 3) · ×8
  • Duplicated block (6 lines × 3) Sources/GrAIdient/Core/Layer/LayerNormalization.swift:969 — Sources/GrAIdient/Core/Layer/LayerNormalization.swift:969-974 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1015-1020 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1085-1090 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
  • Duplicated block (6 lines × 3) Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1036 — Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1036-1041 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1930-1935 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1972-1977 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
  • Duplicated block (6 lines × 3) Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1062 — Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1062-1067 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1844-1849 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:3170-3175 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1069` calls `setBuffer` and `Sources/GrAIdient/Core/Layer/LayerNormalization.swift:3177` 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 × 3) Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1720 — Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1720-1725 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1753-1758 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:2537-2542 — 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/GrAIdient/Core/Layer/LayerNormalization.swift:1720` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 3) Sources/GrAIdient/LayerSeq/QuerySeq.swift:263 — Sources/GrAIdient/LayerSeq/QuerySeq.swift:263-268 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:266-271 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:838-843 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/QuerySeq.swift` and `Sources/GrAIdient/LayerSeq/ValueSeq.swift` as WHOLE FILES: this scan already matched 39 separate duplicated blocks between them, totalling at least 427 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/GrAIdient/LayerSeq/QuerySeq.swift:263` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 3) Sources/GrAIdient/Layer1D/Base/LayerMerge1D.swift:68 — Sources/GrAIdient/Layer1D/Base/LayerMerge1D.swift:68-73 | Sources/GrAIdient/Layer2D/Base/LayerMerge2D.swift:126-131 | Sources/GrAIdient/LayerSeq/Base/LayerMergeSeq.swift:71-76 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Base/LayerMerge1D.swift` and `Sources/GrAIdient/Layer2D/Base/LayerMerge2D.swift` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 129 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 (6 lines × 3) Sources/GrAIdient/Layer1D/Base/LayerMerge1D.swift:86 — Sources/GrAIdient/Layer1D/Base/LayerMerge1D.swift:86-91 | Sources/GrAIdient/Layer2D/Base/LayerMerge2D.swift:144-149 | Sources/GrAIdient/LayerSeq/Base/LayerMergeSeq.swift:89-94 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Base/LayerMerge1D.swift` and `Sources/GrAIdient/Layer2D/Base/LayerMerge2D.swift` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 129 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 (6 lines × 3) Sources/GrAIdient/Layer1D/Base/LayerOutput1D.swift:72 — Sources/GrAIdient/Layer1D/Base/LayerOutput1D.swift:72-77 | Sources/GrAIdient/Layer2D/Base/LayerOutput2D.swift:74-79 | Sources/GrAIdient/Layer2D/SimilarityError2D.swift:102-107 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Base/LayerOutput1D.swift` and `Sources/GrAIdient/Layer2D/Base/LayerOutput2D.swift` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 78 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. 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.
D4 · Code Duplication · Duplicated block (6 lines × 2) · ×8
  • Duplicated block (6 lines × 2) Sources/GrAITestsUtils/Trainer.swift:547 — Sources/GrAITestsUtils/Trainer.swift:547-552 | Sources/GrAITestsUtils/Trainer.swift:602-607 — both copies are in the same file, so extract the 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/GrAITestsUtils/Trainer.swift:547` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 2) Sources/GrAIdient/Core/Function/Normalization.swift:30 — Sources/GrAIdient/Core/Function/Normalization.swift:30-35 | Sources/GrAIdient/Core/Function/Normalization.swift:51-56 — both copies are in the same file, so extract the 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/GrAIdient/Core/Function/Normalization.swift:30` 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 (6 lines × 2) Sources/GrAIdient/LayerSeq/AvgPoolSeq.swift:219 — Sources/GrAIdient/LayerSeq/AvgPoolSeq.swift:219-224 | Sources/GrAIdient/LayerSeq/VQSeq.swift:568-573 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/AvgPoolSeq.swift` and `Sources/GrAIdient/LayerSeq/VQSeq.swift` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 38 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/GrAIdient/LayerSeq/AvgPoolSeq.swift:219` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 2) Sources/GrAIdient/LayerSeq/QuerySeq.swift:366 — Sources/GrAIdient/LayerSeq/QuerySeq.swift:366-371 | Sources/GrAIdient/LayerSeq/SoftmaxSeq.swift:521-526 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/QuerySeq.swift` and `Sources/GrAIdient/LayerSeq/SoftmaxSeq.swift` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 86 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (6 lines × 2) Sources/GrAIdient/LayerSeq/VQSeq.swift:442 — Sources/GrAIdient/LayerSeq/VQSeq.swift:442-447 | Sources/GrAIdient/LayerSeq/VQSeq.swift:1251-1256 — both copies are in the same file, so extract the 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/GrAIdient/LayerSeq/VQSeq.swift:1257` calls `Float` and `Sources/GrAIdient/LayerSeq/VQSeq.swift:449` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (6 lines × 2) Sources/GrAIdient/Core/State/Neurons.swift:154 — Sources/GrAIdient/Core/State/Neurons.swift:154-159 | Sources/GrAIdient/Core/State/Weights.swift:185-190 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (6 lines × 2) Sources/GrAIdient/Layer2D/LayerCAM2D.swift:68 — Sources/GrAIdient/Layer2D/LayerCAM2D.swift:68-73 | Sources/GrAIdient/LayerSeq/LayerCAMSeq.swift:67-72 — before extracting anything, compare `Sources/GrAIdient/Layer2D/LayerCAM2D.swift` and `Sources/GrAIdient/LayerSeq/LayerCAMSeq.swift` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 39 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. 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 (6 lines × 2) Sources/GrAIdient/Layer1D/Base/LayerOutput1D.swift:38 — Sources/GrAIdient/Layer1D/Base/LayerOutput1D.swift:38-43 | Sources/GrAIdient/LayerSeq/AvgPoolSeq.swift:22-27 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Note first that the copies are not typed on the same thing: the declarations holding them bind `layerPrev` to `Layer1D` in one and `LayerSeq` 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.
D4 · Code Duplication · Edited copy of a member (15 corresponding lines) · ×7
  • Edited copy of a member (15 corresponding lines) Sources/GrAIdient/Core/Function/Activation.swift:931 — Sources/GrAIdient/Core/Function/Activation.swift:931-945 | Sources/GrAIdient/Core/Function/Activation.swift:953-969 — 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.
  • Edited copy of a member (15 corresponding lines) Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:227 — Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:227-242 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift:199-213 — 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.
  • Edited copy of a member (15 corresponding lines) Sources/GrAIdient/Utils/Serialization.swift:168 — Sources/GrAIdient/Utils/Serialization.swift:168-182 | Sources/GrAIdient/Utils/Serialization.swift:234-250 — 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.
  • Edited copy of a member (15 corresponding lines) Sources/GrAIdient/Layer1D/Base/Layer1D.swift:214 — Sources/GrAIdient/Layer1D/Base/Layer1D.swift:214-228 | Sources/GrAIdient/Layer2D/Base/Layer2D.swift:304-319 — 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.
  • Edited copy of a member (15 corresponding lines) Sources/GrAIdient/Layer2D/Input2D.swift:343 — Sources/GrAIdient/Layer2D/Input2D.swift:343-357 | Sources/GrAIdient/Layer2D/Input2D.swift:372-386 — 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.
  • Edited copy of a member (15 corresponding lines) Sources/GrAIdient/Layer1D/Base/Layer1D.swift:116 — Sources/GrAIdient/Layer1D/Base/Layer1D.swift:116-130 | Sources/GrAIdient/LayerSeq/Base/LayerSeq.swift:126-140 — 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.
  • Edited copy of a member (15 corresponding lines) Sources/GrAIdient/Layer1D/LinearError1D.swift:177 — Sources/GrAIdient/Layer1D/LinearError1D.swift:177-191 | Sources/GrAIdient/Layer1D/MSE1D.swift:177-192 — 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 · Duplicated block (22 lines × 2) · ×7
  • Duplicated block (22 lines × 2) Sources/GrAITestsUtils/Trainer.swift:344 — Sources/GrAITestsUtils/Trainer.swift:344-365 | Sources/GrAITestsUtils/Trainer.swift:634-655 — both copies are in the same file, so extract the 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/GrAITestsUtils/Trainer.swift:344` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (22 lines × 2) Sources/GrAIdient/Layer2D/SimilarityError2D.swift:421 — Sources/GrAIdient/Layer2D/SimilarityError2D.swift:421-442 | Sources/GrAIdient/Layer2D/SimilarityError2D.swift:650-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. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/Layer2D/SimilarityError2D.swift:421` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (22 lines × 2) Sources/GrAIdient/LayerSeq/ConstantSeq.swift:386 — Sources/GrAIdient/LayerSeq/ConstantSeq.swift:386-407 | Sources/GrAIdient/LayerSeq/ConstantSeq.swift:889-910 — both copies are in the same file, so extract the 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/GrAIdient/LayerSeq/ConstantSeq.swift:386` 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 lines × 2) Sources/GrAIdient/LayerSeq/LayerNormSeq.swift:394 — Sources/GrAIdient/LayerSeq/LayerNormSeq.swift:394-415 | Sources/GrAIdient/LayerSeq/RMSNormSeq.swift:408-429 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/LayerNormSeq.swift` and `Sources/GrAIdient/LayerSeq/RMSNormSeq.swift` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 276 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/GrAIdient/LayerSeq/LayerNormSeq.swift:394` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (22 lines × 2) Sources/GrAIdient/LayerSeq/QuerySeq.swift:148 — Sources/GrAIdient/LayerSeq/QuerySeq.swift:148-169 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:240-261 — both copies are in the same file, so extract the 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/GrAIdient/LayerSeq/QuerySeq.swift:263` calls `download` and `Sources/GrAIdient/LayerSeq/QuerySeq.swift:171` 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 (22 lines × 2) Sources/GrAIdient/LayerSeq/QuerySeq.swift:171 — Sources/GrAIdient/LayerSeq/QuerySeq.swift:171-192 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:266-287 — both copies are in the same file, so extract the 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/GrAIdient/LayerSeq/QuerySeq.swift:171` 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/GrAIdient/LayerSeq/QuerySeq.swift:263` calls `download` and `Sources/GrAIdient/LayerSeq/QuerySeq.swift:169` 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 (22 lines × 2) Sources/GrAIdient/LayerSeq/ValueSeq.swift:1421 — Sources/GrAIdient/LayerSeq/ValueSeq.swift:1421-1442 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1520-1541 — both copies are in the same file, so extract the 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/GrAIdient/LayerSeq/ValueSeq.swift:1421` 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.
D4 · Code Duplication · Duplicated block (21 lines × 2) · ×7
  • Duplicated block (21 lines × 2) Sources/GrAIdient/Core/Layer/LayerUpdate.swift:317 — Sources/GrAIdient/Core/Layer/LayerUpdate.swift:317-337 | Sources/GrAIdient/Core/Layer/LayerUpdate.swift:449-469 — both copies are in the same file, so extract the 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/GrAIdient/Core/Layer/LayerUpdate.swift:317` 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 (21 lines × 2) Sources/GrAIdient/Core/Layer/LayerUpdate.swift:381 — Sources/GrAIdient/Core/Layer/LayerUpdate.swift:381-401 | Sources/GrAIdient/Core/Layer/LayerUpdate.swift:517-537 — both copies are in the same file, so extract the 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/GrAIdient/Core/Layer/LayerUpdate.swift:381` 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 (21 lines × 2) Sources/GrAIdient/Layer2D/BCESigmoid2D.swift:159 — Sources/GrAIdient/Layer2D/BCESigmoid2D.swift:159-179 | Sources/GrAIdient/Layer2D/BCESigmoid2D.swift:249-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/GrAIdient/Layer2D/BCESigmoid2D.swift:159` 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 (21 lines × 2) Sources/GrAIdient/Layer2D/BN2D.swift:471 — Sources/GrAIdient/Layer2D/BN2D.swift:471-491 | Sources/GrAIdient/Layer2D/InstanceNorm2D.swift:395-415 — before extracting anything, compare `Sources/GrAIdient/Layer2D/BN2D.swift` and `Sources/GrAIdient/Layer2D/InstanceNorm2D.swift` as WHOLE FILES: this scan already matched 21 separate duplicated blocks between them, totalling at least 320 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/GrAIdient/Layer2D/BN2D.swift:471` 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 (21 lines × 2) Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:392 — Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:392-412 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:508-528 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:414` calls `Double` and `Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:530` 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 lines × 2) Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:549 — Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:549-569 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:875-895 — both copies are in the same file, so extract the 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/GrAIdient/LayerSeq/FullyConnectedPatch.swift:549` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (21 lines × 2) Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:1176 — Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:1176-1196 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:1063-1083 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift` and `Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift` as WHOLE FILES: this scan already matched 54 separate duplicated blocks between them, totalling at least 760 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/GrAIdient/LayerSeq/FullyConnectedPatch.swift:1176` 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 · Duplicated block (17 lines × 2) · ×7
  • Duplicated block (17 lines × 2) Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1052 — Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1052-1068 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1834-1850 — both copies are in the same file, so extract the 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/GrAIdient/Layer1D/Concat1D.swift:145 — Sources/GrAIdient/Layer1D/Concat1D.swift:145-161 | Sources/GrAIdient/Layer1D/Sum1D.swift:154-170 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Concat1D.swift` and `Sources/GrAIdient/Layer1D/Sum1D.swift` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 36 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/GrAIdient/Layer1D/Concat1D.swift:145` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (17 lines × 2) Sources/GrAIdient/Layer2D/Constant2D.swift:372 — Sources/GrAIdient/Layer2D/Constant2D.swift:372-388 | Sources/GrAIdient/Layer2D/Constant2D.swift:418-434 — both copies are in the same file, so extract the 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/GrAIdient/Layer2D/Constant2D.swift:372` 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 lines × 2) Sources/GrAIdient/Layer2D/Constant2D.swift:542 — Sources/GrAIdient/Layer2D/Constant2D.swift:542-558 | Sources/GrAIdient/LayerSeq/ConstantSeq.swift:977-993 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Constant2D.swift` and `Sources/GrAIdient/LayerSeq/ConstantSeq.swift` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 150 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/GrAIdient/Layer2D/Constant2D.swift:542` 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 (17 lines × 2) Sources/GrAIdient/Layer2D/Normalize2D.swift:183 — Sources/GrAIdient/Layer2D/Normalize2D.swift:183-199 | Sources/GrAIdient/Layer2D/Transform/IRDFT2RGB.swift:196-212 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Normalize2D.swift` and `Sources/GrAIdient/Layer2D/Transform/IRDFT2RGB.swift` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 148 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/GrAIdient/Layer2D/Normalize2D.swift:183` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (17 lines × 2) Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:623 — Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:623-639 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:796-812 — both copies are in the same file, so extract the 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/GrAIdient/LayerSeq/FullyConnectedPatch.swift:623` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (17 lines × 2) Sources/GrAIdient/LayerSeq/QuerySeq.swift:1327 — Sources/GrAIdient/LayerSeq/QuerySeq.swift:1327-1343 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1377-1393 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/QuerySeq.swift` and `Sources/GrAIdient/LayerSeq/ValueSeq.swift` as WHOLE FILES: this scan already matched 39 separate duplicated blocks between them, totalling at least 427 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.
D3 · God Classes · MethodTooLong · ×6
  • MethodTooLong: Deconvolution2D._forwardGCGPU Sources/GrAIdient/Layer2D/Deconvolution2D.swift:473 — MethodTooLong — _forwardGCGPU runs 150 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 50 over it, 1.50× 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: Convolution2D._forwardGCGPU Sources/GrAIdient/Layer2D/Convolution2D.swift:1038 — MethodTooLong — _forwardGCGPU runs 134 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 34 over it, 1.34× 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: Convolution2D._backwardWeightsGPU Sources/GrAIdient/Layer2D/Convolution2D.swift:1582 — MethodTooLong — _backwardWeightsGPU runs 123 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 23 over it, 1.23× 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: Deconvolution2D._forwardGCCPU Sources/GrAIdient/Layer2D/Deconvolution2D.swift:268 — MethodTooLong — _forwardGCCPU runs 119 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 19 over it, 1.19× 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: Convolution2D._forwardGCCPU Sources/GrAIdient/Layer2D/Convolution2D.swift:842 — MethodTooLong — _forwardGCCPU 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: FullyConnectedPatch._forwardGCGPU Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:687 — MethodTooLong — _forwardGCGPU 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.
D4 · Code Duplication · Edited copy of a member (31 corresponding lines) · ×6
  • Edited copy of a member (31 corresponding lines) Sources/GrAIdient/Core/Optimizer/OptimizerAlgorithm.swift:219 — Sources/GrAIdient/Core/Optimizer/OptimizerAlgorithm.swift:219-250 | Sources/GrAIdient/Core/Optimizer/OptimizerAlgorithm.swift:439-475 — These two members are one piece of code written twice and then edited apart: 31 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 (31 corresponding lines) Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1050 — Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1050-1080 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1832-1862 — These two members are one piece of code written twice and then edited apart: 31 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 (31 corresponding lines) Sources/GrAIdient/Core/Layer/LayerNormalization.swift:853 — Sources/GrAIdient/Core/Layer/LayerNormalization.swift:853-883 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1013-1047 — These two members are one piece of code written twice and then edited apart: 31 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 (31 corresponding lines) Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1765 — Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1765-1795 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1798-1829 — These two members are one piece of code written twice and then edited apart: 31 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 (31 corresponding lines) Sources/GrAIdient/Layer2D/AvgPool2D.swift:190 — Sources/GrAIdient/Layer2D/AvgPool2D.swift:190-222 | Sources/GrAIdient/Layer2D/Transform/Pad2D.swift:254-284 — These two members are one piece of code written twice and then edited apart: 31 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 (31 corresponding lines) Sources/GrAIdient/LayerSeq/QuerySeq.swift:1255 — Sources/GrAIdient/LayerSeq/QuerySeq.swift:1255-1293 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1337-1367 — These two members are one piece of code written twice and then edited apart: 31 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 (12 corresponding lines) · ×6
  • Edited copy of a member (12 corresponding lines) Sources/GrAIdient/Layer2D/VQ2D.swift:155 — Sources/GrAIdient/Layer2D/VQ2D.swift:155-166 | Sources/GrAIdient/LayerSeq/VQSeq.swift:143-155 — 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.
  • Edited copy of a member (12 corresponding lines) Sources/GrAIdient/LayerSeq/Base/LayerSeq.swift:187 — Sources/GrAIdient/LayerSeq/Base/LayerSeq.swift:187-198 | Sources/GrAIdient/LayerSeq/Base/LayerSeq.swift:214-230 — 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.
  • Edited copy of a member (12 corresponding lines) Sources/GrAIdient/Layer1D/Base/Layer1D.swift:194 — Sources/GrAIdient/Layer1D/Base/Layer1D.swift:194-205 | Sources/GrAIdient/Layer1D/Base/Layer1D.swift:237-253 — 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.
  • Edited copy of a member (12 corresponding lines) Sources/GrAIdient/Layer1D/Input1D.swift:222 — Sources/GrAIdient/Layer1D/Input1D.swift:222-233 | Sources/GrAIdient/Layer2D/Input2D.swift:292-303 — 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.
  • Edited copy of a member (12 corresponding lines) Sources/GrAIdient/Layer2D/VQ2D.swift:330 — Sources/GrAIdient/Layer2D/VQ2D.swift:330-341 | Sources/GrAIdient/LayerSeq/VQSeq.swift:320-331 — 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.
  • Edited copy of a member (12 corresponding lines) Sources/GrAIdient/Layer1D/Input1D.swift:147 — Sources/GrAIdient/Layer1D/Input1D.swift:147-158 | Sources/GrAIdient/Layer2D/Input2D.swift:173-184 — 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 · Duplicated block (24 lines × 2) · ×6
  • Duplicated block (24 lines × 2) Sources/GrAIdient/Layer1D/Constant1D.swift:530 — Sources/GrAIdient/Layer1D/Constant1D.swift:530-553 | Sources/GrAIdient/LayerSeq/ConstantSeq.swift:1038-1061 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Constant1D.swift` and `Sources/GrAIdient/LayerSeq/ConstantSeq.swift` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 267 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (24 lines × 2) Sources/GrAIdient/Layer2D/SimilarityError2D.swift:478 — Sources/GrAIdient/Layer2D/SimilarityError2D.swift:478-501 | Sources/GrAIdient/Layer2D/SimilarityError2D.swift:718-741 — both copies are in the same file, so extract the 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/GrAIdient/Layer2D/SimilarityError2D.swift:478` 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/GrAIdient/Layer2D/SimilarityError2D.swift:715` calls `Float`, `UInt32` and `Sources/GrAIdient/Layer2D/SimilarityError2D.swift:476` 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 (24 lines × 2) Sources/GrAIdient/Layer2D/VQ2D.swift:1085 — Sources/GrAIdient/Layer2D/VQ2D.swift:1085-1108 | Sources/GrAIdient/LayerSeq/VQSeq.swift:1005-1028 — before extracting anything, compare `Sources/GrAIdient/Layer2D/VQ2D.swift` and `Sources/GrAIdient/LayerSeq/VQSeq.swift` as WHOLE FILES: this scan already matched 30 separate duplicated blocks between them, totalling at least 378 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/GrAIdient/Layer2D/VQ2D.swift:1085` 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 (24 lines × 2) Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:273 — Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:273-296 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:250-273 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift` and `Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift` as WHOLE FILES: this scan already matched 54 separate duplicated blocks between them, totalling at least 760 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/GrAIdient/LayerSeq/FullyConnectedPatch.swift:273` 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 (24 lines × 2) Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:320 — Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:320-343 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:296-319 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift` and `Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift` as WHOLE FILES: this scan already matched 54 separate duplicated blocks between them, totalling at least 760 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/GrAIdient/LayerSeq/FullyConnectedPatch.swift:320` 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 (24 lines × 2) Sources/GrAIdient/LayerSeq/QuerySeq.swift:1759 — Sources/GrAIdient/LayerSeq/QuerySeq.swift:1759-1782 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1753-1776 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/QuerySeq.swift` and `Sources/GrAIdient/LayerSeq/ValueSeq.swift` as WHOLE FILES: this scan already matched 39 separate duplicated blocks between them, totalling at least 427 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/GrAIdient/LayerSeq/QuerySeq.swift:1759` 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 (17 corresponding lines) · ×5
  • Edited copy of a member (17 corresponding lines) Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:174 — Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:174-193 | Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:228-248 — 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.
  • Edited copy of a member (17 corresponding lines) Sources/GrAIdient/Core/Model/Model.swift:125 — Sources/GrAIdient/Core/Model/Model.swift:125-141 | Sources/GrAIdient/Core/Model/Model.swift:203-225 — 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.
  • Edited copy of a member (17 corresponding lines) Sources/GrAIdient/Core/Model/Model.swift:1013 — Sources/GrAIdient/Core/Model/Model.swift:1013-1031 | Sources/GrAIdient/Core/Model/Model.swift:1042-1058 — 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.
  • Edited copy of a member (17 corresponding lines) Sources/GrAIdient/Layer2D/Multiply2D.swift:146 — Sources/GrAIdient/Layer2D/Multiply2D.swift:146-162 | Sources/GrAIdient/LayerSeq/MutiplySeq.swift:145-161 — 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.
  • Edited copy of a member (17 corresponding lines) Sources/GrAIdient/Layer2D/Constant2D.swift:307 — Sources/GrAIdient/Layer2D/Constant2D.swift:307-325 | Sources/GrAIdient/LayerSeq/ConstantSeq.swift:252-268 — 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 · Duplicated block (20 lines × 3) · ×5
  • Duplicated block (20 lines × 3) Sources/GrAIdient/Layer1D/BCE1D.swift:209 — Sources/GrAIdient/Layer1D/BCE1D.swift:209-228 | Sources/GrAIdient/Layer1D/BCESigmoid1D.swift:232-251 | Sources/GrAIdient/Layer1D/MSE1D.swift:205-224 — before extracting anything, compare `Sources/GrAIdient/Layer1D/BCE1D.swift` and `Sources/GrAIdient/Layer1D/BCESigmoid1D.swift` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 218 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/Layer1D/BCE1D.swift:209` 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 × 3) Sources/GrAIdient/Layer1D/FullyConnected.swift:168 — Sources/GrAIdient/Layer1D/FullyConnected.swift:168-187 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:75-94 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:67-86 — before extracting anything, compare `Sources/GrAIdient/Layer1D/FullyConnected.swift` and `Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift` as WHOLE FILES: this scan already matched 32 separate duplicated blocks between them, totalling at least 473 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (20 lines × 3) Sources/GrAIdient/Layer1D/FullyConnected.swift:1167 — Sources/GrAIdient/Layer1D/FullyConnected.swift:1167-1186 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:1245-1264 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:1129-1148 — before extracting anything, compare `Sources/GrAIdient/Layer1D/FullyConnected.swift` and `Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift` as WHOLE FILES: this scan already matched 32 separate duplicated blocks between them, totalling at least 473 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/GrAIdient/Layer1D/FullyConnected.swift:1167` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (20 lines × 3) Sources/GrAIdient/Layer2D/Constant2D.swift:409 — Sources/GrAIdient/Layer2D/Constant2D.swift:409-428 | Sources/GrAIdient/Layer2D/Convolution2D.swift:1164-1183 | Sources/GrAIdient/Layer2D/Deconvolution2D.swift:611-630 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Constant2D.swift` and `Sources/GrAIdient/Layer2D/Convolution2D.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. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/Layer2D/Constant2D.swift:409` 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 × 3) Sources/GrAIdient/Layer2D/Deconvolution2D.swift:554 — Sources/GrAIdient/Layer2D/Deconvolution2D.swift:554-573 | Sources/GrAIdient/Layer2D/Deconvolution2D.swift:632-651 | Sources/GrAIdient/Layer2D/Deconvolution2D.swift:683-702 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/Layer2D/Deconvolution2D.swift:554` 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.
D4 · Code Duplication · Duplicated block (17 lines × 3) · ×5
  • Duplicated block (17 lines × 3) Sources/GrAIdient/Layer1D/FullyConnected.swift:324 — Sources/GrAIdient/Layer1D/FullyConnected.swift:324-340 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:230-246 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:208-224 — before extracting anything, compare `Sources/GrAIdient/Layer1D/FullyConnected.swift` and `Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift` as WHOLE FILES: this scan already matched 32 separate duplicated blocks between them, totalling at least 473 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/GrAIdient/Layer1D/FullyConnected.swift:324` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:229` calls `encode` and `Sources/GrAIdient/Layer1D/FullyConnected.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 (17 lines × 3) Sources/GrAIdient/Layer1D/FullyConnected.swift:700 — Sources/GrAIdient/Layer1D/FullyConnected.swift:700-716 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:635-651 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:580-596 — before extracting anything, compare `Sources/GrAIdient/Layer1D/FullyConnected.swift` and `Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift` as WHOLE FILES: this scan already matched 32 separate duplicated blocks between them, totalling at least 473 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/GrAIdient/Layer1D/FullyConnected.swift:700` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (17 lines × 3) Sources/GrAIdient/Layer1D/FullyConnected.swift:821 — Sources/GrAIdient/Layer1D/FullyConnected.swift:821-837 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:808-824 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:716-732 — before extracting anything, compare `Sources/GrAIdient/Layer1D/FullyConnected.swift` and `Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift` as WHOLE FILES: this scan already matched 32 separate duplicated blocks between them, totalling at least 473 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/GrAIdient/Layer1D/FullyConnected.swift:821` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (17 lines × 3) Sources/GrAIdient/Layer2D/BCE2D.swift:517 — Sources/GrAIdient/Layer2D/BCE2D.swift:517-533 | Sources/GrAIdient/Layer2D/BCESigmoid2D.swift:552-568 | Sources/GrAIdient/Layer2D/MSE2D.swift:487-503 — before extracting anything, compare `Sources/GrAIdient/Layer2D/BCE2D.swift` and `Sources/GrAIdient/Layer2D/BCESigmoid2D.swift` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 271 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/GrAIdient/Layer2D/BCE2D.swift:517` 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 lines × 3) Sources/GrAIdient/Layer2D/Convolution2D.swift:1114 — Sources/GrAIdient/Layer2D/Convolution2D.swift:1114-1130 | Sources/GrAIdient/Layer2D/Convolution2D.swift:1185-1201 | Sources/GrAIdient/Layer2D/Convolution2D.swift:1230-1246 — 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/GrAIdient/Layer2D/Convolution2D.swift:1114` 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.
D4 · Code Duplication · Duplicated block (16 lines × 3) · ×5
  • Duplicated block (16 lines × 3) Sources/GrAIdient/Layer1D/BCE1D.swift:392 — Sources/GrAIdient/Layer1D/BCE1D.swift:392-407 | Sources/GrAIdient/Layer1D/BCESigmoid1D.swift:411-426 | Sources/GrAIdient/Layer1D/MSE1D.swift:375-390 — before extracting anything, compare `Sources/GrAIdient/Layer1D/BCE1D.swift` and `Sources/GrAIdient/Layer1D/BCESigmoid1D.swift` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 218 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/Layer1D/BCE1D.swift:392` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 3) Sources/GrAIdient/Layer1D/Constant1D.swift:580 — Sources/GrAIdient/Layer1D/Constant1D.swift:580-595 | Sources/GrAIdient/Layer2D/Constant2D.swift:653-668 | Sources/GrAIdient/LayerSeq/ConstantSeq.swift:1088-1103 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Constant1D.swift` and `Sources/GrAIdient/Layer2D/Constant2D.swift` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 131 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 (16 lines × 3) Sources/GrAIdient/Layer2D/Convolution2D.swift:1224 — Sources/GrAIdient/Layer2D/Convolution2D.swift:1224-1239 | Sources/GrAIdient/Layer2D/Deconvolution2D.swift:548-563 | Sources/GrAIdient/Layer2D/Deconvolution2D.swift:677-692 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Convolution2D.swift` and `Sources/GrAIdient/Layer2D/Deconvolution2D.swift` as WHOLE FILES: this scan already matched 26 separate duplicated blocks between them, totalling at least 499 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/GrAIdient/Layer2D/Convolution2D.swift:1224` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 3) Sources/GrAIdient/LayerSeq/ActivationSeq.swift:227 — Sources/GrAIdient/LayerSeq/ActivationSeq.swift:227-242 | Sources/GrAIdient/LayerSeq/LayerNormSeq.swift:486-501 | Sources/GrAIdient/LayerSeq/RMSNormSeq.swift:500-515 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/ActivationSeq.swift` and `Sources/GrAIdient/LayerSeq/LayerNormSeq.swift` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 132 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/GrAIdient/LayerSeq/ActivationSeq.swift:227` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 3) Sources/GrAIdient/Layer1D/BCE1D.swift:335 — Sources/GrAIdient/Layer1D/BCE1D.swift:335-350 | Sources/GrAIdient/Layer1D/BCESigmoid1D.swift:354-369 | Sources/GrAIdient/Layer1D/MSE1D.swift:318-333 — before extracting anything, compare `Sources/GrAIdient/Layer1D/BCE1D.swift` and `Sources/GrAIdient/Layer1D/BCESigmoid1D.swift` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 218 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (15 lines × 3) · ×5
  • Duplicated block (15 lines × 3) Sources/GrAIdient/Layer1D/Constant1D.swift:487 — Sources/GrAIdient/Layer1D/Constant1D.swift:487-501 | Sources/GrAIdient/Layer2D/Constant2D.swift:560-574 | Sources/GrAIdient/LayerSeq/ConstantSeq.swift:995-1009 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Constant1D.swift` and `Sources/GrAIdient/Layer2D/Constant2D.swift` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 131 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/GrAIdient/Layer1D/Constant1D.swift:487` 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 (15 lines × 3) Sources/GrAIdient/Layer1D/FullyConnected.swift:1088 — Sources/GrAIdient/Layer1D/FullyConnected.swift:1088-1102 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:1238-1252 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:1122-1136 — before extracting anything, compare `Sources/GrAIdient/Layer1D/FullyConnected.swift` and `Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift` as WHOLE FILES: this scan already matched 32 separate duplicated blocks between them, totalling at least 473 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/GrAIdient/Layer1D/FullyConnected.swift:1088` 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/GrAIdient/LayerSeq/FullyConnectedPatch.swift:1235` calls `setBytes` and `Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:1119` 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 × 3) Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:670 — Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:670-684 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift:595-609 | Sources/GrAIdient/Layer2D/Transform/Rotate2D.swift:448-462 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift` and `Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 252 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/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:670` 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 × 3) Sources/GrAIdient/LayerSeq/QuerySeq.swift:415 — Sources/GrAIdient/LayerSeq/QuerySeq.swift:415-429 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:446-460 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:1922-1936 — 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/GrAIdient/LayerSeq/QuerySeq.swift:415` 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 (15 lines × 3) Sources/GrAIdient/LayerSeq/QuerySeq.swift:511 — Sources/GrAIdient/LayerSeq/QuerySeq.swift:511-525 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:2032-2046 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:2024-2038 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/QuerySeq.swift` and `Sources/GrAIdient/LayerSeq/ValueSeq.swift` as WHOLE FILES: this scan already matched 39 separate duplicated blocks between them, totalling at least 427 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/GrAIdient/LayerSeq/QuerySeq.swift:511` 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 · Duplicated block (14 lines × 3) · ×5
  • Duplicated block (14 lines × 3) Sources/GrAIdient/Core/Layer/LayerNormalization.swift:603 — Sources/GrAIdient/Core/Layer/LayerNormalization.swift:603-616 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1418-1431 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:2305-2318 — 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/GrAIdient/Core/Layer/LayerNormalization.swift:603` 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 × 3) Sources/GrAIdient/Layer1D/Constant1D.swift:529 — Sources/GrAIdient/Layer1D/Constant1D.swift:529-542 | Sources/GrAIdient/Layer2D/Constant2D.swift:602-615 | Sources/GrAIdient/LayerSeq/ConstantSeq.swift:1037-1050 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Constant1D.swift` and `Sources/GrAIdient/Layer2D/Constant2D.swift` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 131 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/GrAIdient/Layer1D/Constant1D.swift:529` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (14 lines × 3) Sources/GrAIdient/Layer1D/DotProduct1D.swift:122 — Sources/GrAIdient/Layer1D/DotProduct1D.swift:122-135 | Sources/GrAIdient/Layer1D/DotProduct1D.swift:202-215 | Sources/GrAIdient/Layer1D/Sum1D.swift:89-102 — before extracting anything, compare `Sources/GrAIdient/Layer1D/DotProduct1D.swift` and `Sources/GrAIdient/Layer1D/Sum1D.swift` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 54 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (14 lines × 3) Sources/GrAIdient/Layer2D/Convolution2D.swift:971 — Sources/GrAIdient/Layer2D/Convolution2D.swift:971-984 | Sources/GrAIdient/Layer2D/Convolution2D.swift:1006-1019 | Sources/GrAIdient/Layer2D/Convolution2D.swift:1294-1307 — 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/GrAIdient/Layer2D/Convolution2D.swift:971` 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 × 3) Sources/GrAIdient/Layer2D/MaxPool2D.swift:473 — Sources/GrAIdient/Layer2D/MaxPool2D.swift:473-486 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:713-726 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift:646-659 — before extracting anything, compare `Sources/GrAIdient/Layer2D/MaxPool2D.swift` and `Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 76 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. 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/GrAIdient/Layer2D/MaxPool2D.swift:473` 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.
D4 · Code Duplication · Duplicated block (13 lines × 4) · ×5
  • Duplicated block (13 lines × 4) Sources/GrAIdient/Layer1D/Dropout1D.swift:426 — Sources/GrAIdient/Layer1D/Dropout1D.swift:426-438 | Sources/GrAIdient/Layer1D/LinearError1D.swift:306-318 | Sources/GrAIdient/Layer1D/Softmax1D.swift:321-333 | Sources/GrAIdient/LayerSeq/SelectSeq.swift:271-283 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 4 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 4 times. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/Layer1D/Dropout1D.swift:426` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Sources/GrAIdient/Layer1D/Dropout1D.swift:423` calls `setBytes` and `Sources/GrAIdient/Layer1D/Softmax1D.swift:318` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (13 lines × 4) Sources/GrAIdient/Layer1D/FullyConnected.swift:1087 — Sources/GrAIdient/Layer1D/FullyConnected.swift:1087-1099 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:1156-1168 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:1237-1249 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:1121-1133 — before extracting anything, compare `Sources/GrAIdient/Layer1D/FullyConnected.swift` and `Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift` as WHOLE FILES: this scan already matched 32 separate duplicated blocks between them, totalling at least 473 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/GrAIdient/Layer1D/FullyConnected.swift:1087` 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/GrAIdient/Layer1D/FullyConnected.swift:1084` calls `setBuffer` and `Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:1118` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (13 lines × 4) Sources/GrAIdient/Layer2D/AdaIN.swift:111 — Sources/GrAIdient/Layer2D/AdaIN.swift:111-123 | Sources/GrAIdient/Layer2D/BN2D.swift:213-225 | Sources/GrAIdient/Layer2D/InstanceNorm2D.swift:138-150 | Sources/GrAIdient/LayerSeq/LayerNormSeq.swift:137-149 — before extracting anything, compare `Sources/GrAIdient/Layer2D/AdaIN.swift` and `Sources/GrAIdient/Layer2D/InstanceNorm2D.swift` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 92 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 × 4) Sources/GrAIdient/Layer2D/Concat2D.swift:171 — Sources/GrAIdient/Layer2D/Concat2D.swift:171-183 | Sources/GrAIdient/Layer2D/Multiply2D.swift:257-269 | Sources/GrAIdient/Layer2D/SimilarityError2D.swift:259-271 | Sources/GrAIdient/Layer2D/Sum2D.swift:179-191 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Concat2D.swift` and `Sources/GrAIdient/Layer2D/Multiply2D.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.
  • Duplicated block (13 lines × 4) Sources/GrAIdient/Layer1D/FullyConnected.swift:196 — Sources/GrAIdient/Layer1D/FullyConnected.swift:196-208 | Sources/GrAIdient/Layer2D/Convolution2D.swift:181-193 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:103-115 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:95-107 — before extracting anything, compare `Sources/GrAIdient/Layer1D/FullyConnected.swift` and `Sources/GrAIdient/Layer2D/Convolution2D.swift` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 103 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (7 lines × 4) · ×5
  • Duplicated block (7 lines × 4) Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1032 — Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1032-1038 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1926-1932 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:2641-2647 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:3210-3216 — 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/GrAIdient/Core/Layer/LayerNormalization.swift:1032` it begins part-way through the construct above it, so those 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/GrAIdient/Core/Layer/LayerNormalization.swift:1039` calls `setBytes` and `Sources/GrAIdient/Core/Layer/LayerNormalization.swift:2648` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (7 lines × 4) Sources/GrAIdient/Layer1D/LinearError1D.swift:300 — Sources/GrAIdient/Layer1D/LinearError1D.swift:300-306 | Sources/GrAIdient/Layer2D/SimilarityBatchError2D.swift:251-257 | Sources/GrAIdient/Layer2D/SimilarityBatchError2D.swift:337-343 | Sources/GrAIdient/Layer2D/SimilarityError2D.swift:613-619 — before extracting anything, compare `Sources/GrAIdient/Layer1D/LinearError1D.swift` and `Sources/GrAIdient/Layer2D/SimilarityBatchError2D.swift` as WHOLE FILES: this scan already matched 4 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. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Sources/GrAIdient/Layer2D/SimilarityBatchError2D.swift:345` calls `setBytes` and `Sources/GrAIdient/Layer1D/LinearError1D.swift:308` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (7 lines × 4) Sources/GrAIdient/Layer2D/Normalize2D.swift:547 — Sources/GrAIdient/Layer2D/Normalize2D.swift:547-553 | Sources/GrAIdient/Layer2D/Normalize2D.swift:600-606 | Sources/GrAIdient/Layer2D/Normalize2D.swift:700-706 | Sources/GrAIdient/Layer2D/VQ2D.swift:1279-1285 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Normalize2D.swift` and `Sources/GrAIdient/Layer2D/VQ2D.swift` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 51 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Sources/GrAIdient/Layer2D/Normalize2D.swift:608` calls `setBuffer` and `Sources/GrAIdient/Layer2D/Normalize2D.swift:555` 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 (7 lines × 4) Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:928 — Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:928-934 | Sources/GrAIdient/LayerSeq/LayerCAMSeq.swift:176-182 | Sources/GrAIdient/LayerSeq/RoPESeq.swift:362-368 | Sources/GrAIdient/LayerSeq/VQSeq.swift:754-760 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 4 call sites, so a change lands once. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:936` calls `setBuffer` and `Sources/GrAIdient/LayerSeq/LayerCAMSeq.swift:184` 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 (7 lines × 4) Sources/GrAIdient/LayerSeq/QuerySeq.swift:146 — Sources/GrAIdient/LayerSeq/QuerySeq.swift:146-152 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:326-332 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:150-156 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:328-334 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/QuerySeq.swift` and `Sources/GrAIdient/LayerSeq/ValueSeq.swift` as WHOLE FILES: this scan already matched 39 separate duplicated blocks between them, totalling at least 427 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/GrAIdient/LayerSeq/QuerySeq.swift:146` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D10 · Test Quality · Skipped test · ×4
  • Skipped test: testPrecision Tests/GrAITests/Layer2DTests.swift:6864 — Skipped — throws XCTSkip
  • Skipped test: testPrecision Tests/GrAITests/Layer2DTests.swift:7391 — Skipped — throws XCTSkip
  • Skipped test: testGenerate2Float16 Tests/GrAITests/NLPTests.swift:2265 — Skipped — throws XCTSkip
  • Skipped test: testGenerateBatchSize2Float16 Tests/GrAITests/NLPTests.swift:2290 — Skipped — throws XCTSkip
D17 · Explicit Debt · TodoComment · ×4
  • TodoComment Tests/GrAIExamples/Base/python_lib/nlp/model.py:137 — # TODO: Should replace this with finfo(dtype).min — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment Tests/GrAIExamples/Base/python_lib/nlp/gemma2/model.py:140 — # TODO: Should replace this with finfo(dtype).min — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment Sources/GrAIdient/LayerSeq/QuerySeq.swift:1767 — // TODO: when using sliding window with an instruct model, — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment Sources/GrAIdient/LayerSeq/ValueSeq.swift:1761 — // TODO: when using sliding window with an instruct model, — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
D4 · Code Duplication · Edited copy of a member (29 corresponding lines) · ×4
  • Edited copy of a member (29 corresponding lines) Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift:363 — Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift:363-449 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift:456-527 — 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.
  • Edited copy of a member (29 corresponding lines) Sources/GrAIdient/Layer2D/VQ2D.swift:789 — Sources/GrAIdient/Layer2D/VQ2D.swift:789-819 | Sources/GrAIdient/LayerSeq/VQSeq.swift:712-740 — 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.
  • Edited copy of a member (29 corresponding lines) Sources/GrAIdient/Utils/Image.swift:188 — Sources/GrAIdient/Utils/Image.swift:188-216 | Sources/GrAIdient/Utils/Image.swift:229-258 — 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.
  • Edited copy of a member (29 corresponding lines) Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:161 — Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:161-189 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift:132-160 — These two members are one piece of code written twice and then edited apart: 29 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Members sharing a duplicated core (6 members, 50+ identical tokens) · ×4
  • Members sharing a duplicated core (6 members, 50+ identical tokens) Sources/GrAIdient/Core/Layer/LayerNormalization.swift:2582 — Sources/GrAIdient/Core/Layer/LayerNormalization.swift:2582-2615 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:2656-2683 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:3087-3124 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:3157-3188 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:3191-3222 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:3225-3248 — These 6 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
  • Members sharing a duplicated core (6 members, 50+ identical tokens) Sources/GrAIdient/Layer1D/SelectNeurons1D.swift:299 — Sources/GrAIdient/Layer1D/SelectNeurons1D.swift:299-344 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:670-726 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift:595-659 | Sources/GrAIdient/Layer2D/Transform/Rotate2D.swift:448-493 | Sources/GrAIdient/LayerSeq/SelectSeq.swift:238-283 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1059-1153 — These 6 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
  • Members sharing a duplicated core (6 members, 50+ identical tokens) Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:306 — Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:306-369 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:386-495 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:604-663 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift:269-346 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift:363-449 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift:530-588 — These 6 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
  • Members sharing a duplicated core (6 members, 50+ identical tokens) Sources/GrAIdient/LayerSeq/QuerySeq.swift:34 — Sources/GrAIdient/LayerSeq/QuerySeq.swift:34-55 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:589-618 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:1064-1107 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:32-59 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:584-615 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1197-1233 — These 6 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
D4 · Code Duplication · Edited copy of a member (35 corresponding lines) · ×4
  • Edited copy of a member (35 corresponding lines) Sources/GrAIdient/LayerSeq/ValueSeq.swift:358 — Sources/GrAIdient/LayerSeq/ValueSeq.swift:358-392 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:933-971 — 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/GrAIdient/LayerSeq/FullyConnectedPatch.swift:917 — Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:917-951 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:799-839 — 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/GrAIdient/Layer1D/Dropout1D.swift:307 — Sources/GrAIdient/Layer1D/Dropout1D.swift:307-355 | Sources/GrAIdient/Layer1D/Dropout1D.swift:404-438 — 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/GrAIdient/Layer2D/Multiply2D.swift:511 — Sources/GrAIdient/Layer2D/Multiply2D.swift:511-545 | Sources/GrAIdient/LayerSeq/MutiplySeq.swift:470-504 — 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 (30 corresponding lines) · ×4
  • Edited copy of a member (30 corresponding lines) Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1700 — Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1700-1729 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1732-1762 — 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/GrAIdient/Layer2D/Transform/Flip2D.swift:189 — Sources/GrAIdient/Layer2D/Transform/Flip2D.swift:189-218 | Sources/GrAIdient/Layer2D/Transform/Flip2D.swift:436-465 — 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/GrAIdient/LayerSeq/EmbeddingSeq.swift:321 — Sources/GrAIdient/LayerSeq/EmbeddingSeq.swift:321-350 | Sources/GrAIdient/LayerSeq/EmbeddingSeq.swift:362-395 — 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/GrAIdient/Layer1D/FullyConnected.swift:936 — Sources/GrAIdient/Layer1D/FullyConnected.swift:936-965 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:864-896 — 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 (16 corresponding lines) · ×4
  • Edited copy of a member (16 corresponding lines) Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:199 — Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:199-214 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift:170-186 — 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/GrAIdient/Layer1D/Sum1D.swift:230 — Sources/GrAIdient/Layer1D/Sum1D.swift:230-245 | Sources/GrAIdient/LayerSeq/SumSeq.swift:240-256 — 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/GrAIdient/Layer2D/Multiply2D.swift:124 — Sources/GrAIdient/Layer2D/Multiply2D.swift:124-139 | Sources/GrAIdient/LayerSeq/MutiplySeq.swift:123-138 — 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/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:165 — Sources/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:165-180 | Sources/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:187-202 — 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 (18 corresponding lines) · ×4
  • Edited copy of a member (18 corresponding lines) Sources/GrAIdient/Layer2D/Base/Layer2D.swift:278 — Sources/GrAIdient/Layer2D/Base/Layer2D.swift:278-295 | Sources/GrAIdient/Layer2D/Base/Layer2D.swift:328-350 — 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/GrAIdient/Layer2D/SelectNeurons2D.swift:232 — Sources/GrAIdient/Layer2D/SelectNeurons2D.swift:232-249 | Sources/GrAIdient/LayerSeq/AvgPoolSeq.swift:121-145 — 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/GrAIdient/Layer1D/Softmax1D.swift:32 — Sources/GrAIdient/Layer1D/Softmax1D.swift:32-49 | Sources/GrAIdient/LayerSeq/SoftmaxSeq.swift:33-51 — 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/GrAIdient/Layer2D/Base/LayerInput2D.swift:200 — Sources/GrAIdient/Layer2D/Base/LayerInput2D.swift:200-217 | Sources/GrAIdient/Layer2D/Base/LayerOutput2D.swift:225-242 — 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 (13 corresponding lines) · ×4
  • Edited copy of a member (13 corresponding lines) Sources/GrAIdient/Layer2D/AdaIN.swift:548 — Sources/GrAIdient/Layer2D/AdaIN.swift:548-561 | Sources/GrAIdient/Layer2D/AdaIN.swift:607-619 — 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.
  • Edited copy of a member (13 corresponding lines) Sources/GrAIdient/Core/Function/Normalization.swift:67 — Sources/GrAIdient/Core/Function/Normalization.swift:67-79 | Sources/GrAIdient/Core/Function/Normalization.swift:156-173 — 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.
  • Edited copy of a member (13 corresponding lines) Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:155 — Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:155-167 | Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:206-221 — 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.
  • Edited copy of a member (13 corresponding lines) Sources/GrAIdient/Layer1D/Input1D.swift:241 — Sources/GrAIdient/Layer1D/Input1D.swift:241-253 | Sources/GrAIdient/Layer2D/Input2D.swift:311-323 — 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 copy of a member (8 corresponding lines) · ×4
  • Edited copy of a member (8 corresponding lines) Sources/GrAIdient/LayerSeq/QuerySeq.swift:628 — Sources/GrAIdient/LayerSeq/QuerySeq.swift:628-636 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:625-632 — 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/GrAIdient/LayerSeq/QuerySeq.swift:649 — Sources/GrAIdient/LayerSeq/QuerySeq.swift:649-657 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:645-652 — 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/GrAIdient/Layer2D/Base/Layer2D.swift:112 — Sources/GrAIdient/Layer2D/Base/Layer2D.swift:112-119 | Sources/GrAIdient/LayerSeq/Base/LayerSeq.swift:53-61 — 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/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:116 — Sources/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:116-123 | Sources/GrAIdient/Layer2D/Normalize2D.swift:347-354 — 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.
D4 · Code Duplication · Edited copy of a member (10 corresponding lines) · ×4
  • Edited copy of a member (10 corresponding lines) Sources/GrAIdient/Layer2D/VQ2D.swift:1032 — Sources/GrAIdient/Layer2D/VQ2D.swift:1032-1041 | Sources/GrAIdient/LayerSeq/VQSeq.swift:952-961 — 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.
  • Edited copy of a member (10 corresponding lines) Sources/GrAIdient/Core/Layer/LayerNormalization.swift:153 — Sources/GrAIdient/Core/Layer/LayerNormalization.swift:153-162 | Sources/GrAIdient/Core/Model/Model.swift:88-101 — 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.
  • Edited copy of a member (10 corresponding lines) Sources/GrAIdient/Layer2D/Base/Layer2D.swift:261 — Sources/GrAIdient/Layer2D/Base/Layer2D.swift:261-271 | Sources/GrAIdient/Layer1D/Base/Layer1D.swift:178-187 — 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.
  • Edited copy of a member (10 corresponding lines) Sources/GrAIdient/Layer1D/Activation1D.swift:46 — Sources/GrAIdient/Layer1D/Activation1D.swift:46-55 | Sources/GrAIdient/LayerSeq/ActivationSeq.swift:46-56 — 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 copy of a member (11 corresponding lines) · ×4
  • Edited copy of a member (11 corresponding lines) Sources/GrAIdient/Layer2D/VQ2D.swift:1012 — Sources/GrAIdient/Layer2D/VQ2D.swift:1012-1022 | Sources/GrAIdient/LayerSeq/VQSeq.swift:932-942 — 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/GrAIdient/Layer1D/Input1D.swift:14 — Sources/GrAIdient/Layer1D/Input1D.swift:14-24 | Sources/GrAIdient/Layer1D/Input1D.swift:39-49 — 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/GrAIdient/Core/Optimizer/OptimizerVariable.swift:226 — Sources/GrAIdient/Core/Optimizer/OptimizerVariable.swift:226-236 | Sources/GrAIdient/Core/Optimizer/OptimizerVariable.swift:246-256 — 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/GrAIdient/LayerSeq/RMSNormSeq.swift:102 — Sources/GrAIdient/LayerSeq/RMSNormSeq.swift:102-116 | Sources/GrAIdient/LayerSeq/LayerNormSeq.swift:97-107 — 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 (7 corresponding lines) · ×4
  • Edited copy of a member (7 corresponding lines) Sources/GrAIdient/Utils/Serialization.swift:195 — Sources/GrAIdient/Utils/Serialization.swift:195-201 | Sources/GrAIdient/Utils/Serialization.swift:263-269 — 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/GrAIdient/Layer2D/Base/Layer2D.swift:149 — Sources/GrAIdient/Layer2D/Base/Layer2D.swift:149-156 | Sources/GrAIdient/LayerSeq/Base/LayerSeq.swift:90-96 — 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/GrAIdient/Layer1D/Input1D.swift:270 — Sources/GrAIdient/Layer1D/Input1D.swift:270-276 | Sources/GrAIdient/LayerSeq/EmbeddingSeq.swift:407-417 — 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/GrAIdient/Layer1D/Input1D.swift:288 — Sources/GrAIdient/Layer1D/Input1D.swift:288-294 | Sources/GrAIdient/LayerSeq/EmbeddingSeq.swift:429-439 — 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 (6 corresponding lines) · ×4
  • Edited copy of a member (6 corresponding lines) Sources/GrAIdient/Layer2D/MaxPool2D.swift:116 — Sources/GrAIdient/Layer2D/MaxPool2D.swift:116-122 | Sources/GrAIdient/Layer1D/DotProduct1D.swift:56-61 — 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/GrAIdient/LayerSeq/Base/LayerSeq.swift:71 — Sources/GrAIdient/LayerSeq/Base/LayerSeq.swift:71-77 | Sources/GrAIdient/Layer1D/Base/Layer1D.swift:63-68 — 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/GrAIdient/Layer2D/MaxPool2D.swift:135 — Sources/GrAIdient/Layer2D/MaxPool2D.swift:135-141 | Sources/GrAIdient/Layer1D/DotProduct1D.swift:74-79 — 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/GrAIdient/Layer1D/Input1D.swift:131 — Sources/GrAIdient/Layer1D/Input1D.swift:131-137 | Sources/GrAIdient/Layer2D/AvgPool2D.swift:22-27 — 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.
D4 · Code Duplication · Duplicated block (27 lines × 2) · ×4
  • Duplicated block (27 lines × 2) Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1769 — Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1769-1795 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1803-1829 — both copies are in the same file, so extract the 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/GrAIdient/Core/Layer/LayerNormalization.swift:1769` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (27 lines × 2) Sources/GrAIdient/Layer1D/Constant1D.swift:481 — Sources/GrAIdient/Layer1D/Constant1D.swift:481-507 | Sources/GrAIdient/LayerSeq/ConstantSeq.swift:989-1015 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Constant1D.swift` and `Sources/GrAIdient/LayerSeq/ConstantSeq.swift` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 267 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/GrAIdient/Layer1D/Constant1D.swift:481` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Sources/GrAIdient/LayerSeq/ConstantSeq.swift:988` calls `setBytes` and `Sources/GrAIdient/Layer1D/Constant1D.swift:480` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (27 lines × 2) Sources/GrAIdient/LayerSeq/LayerNormSeq.swift:453 — Sources/GrAIdient/LayerSeq/LayerNormSeq.swift:453-479 | Sources/GrAIdient/LayerSeq/RMSNormSeq.swift:467-493 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/LayerNormSeq.swift` and `Sources/GrAIdient/LayerSeq/RMSNormSeq.swift` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 276 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/GrAIdient/LayerSeq/LayerNormSeq.swift:453` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (27 lines × 2) Sources/GrAIdient/LayerSeq/QuerySeq.swift:1411 — Sources/GrAIdient/LayerSeq/QuerySeq.swift:1411-1437 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:1540-1566 — both copies are in the same file, so extract the 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/GrAIdient/LayerSeq/QuerySeq.swift:1411` 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/GrAIdient/LayerSeq/QuerySeq.swift:1537` calls `download` and `Sources/GrAIdient/LayerSeq/QuerySeq.swift:1409` 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.
D4 · Code Duplication · Duplicated block (25 lines × 2) · ×4
  • Duplicated block (25 lines × 2) Sources/GrAIdient/Layer1D/Sum1D.swift:91 — Sources/GrAIdient/Layer1D/Sum1D.swift:91-115 | Sources/GrAIdient/Layer1D/Sum1D.swift:164-188 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (25 lines × 2) Sources/GrAIdient/Layer2D/BCESigmoid2D.swift:403 — Sources/GrAIdient/Layer2D/BCESigmoid2D.swift:403-427 | Sources/GrAIdient/Layer2D/BCESigmoid2D.swift:441-465 — both copies are in the same file, so extract the 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/GrAIdient/Layer2D/BCESigmoid2D.swift:403` 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 (25 lines × 2) Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift:369 — Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift:369-393 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift:462-486 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift:395` calls `Double` and `Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift:488` 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 (25 lines × 2) Sources/GrAIdient/Layer2D/VQ2D.swift:727 — Sources/GrAIdient/Layer2D/VQ2D.swift:727-751 | Sources/GrAIdient/LayerSeq/VQSeq.swift:650-674 — before extracting anything, compare `Sources/GrAIdient/Layer2D/VQ2D.swift` and `Sources/GrAIdient/LayerSeq/VQSeq.swift` as WHOLE FILES: this scan already matched 30 separate duplicated blocks between them, totalling at least 378 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/GrAIdient/Layer2D/VQ2D.swift:727` 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 · Duplicated block (24 lines × 3) · ×4
  • Duplicated block (24 lines × 3) Sources/GrAIdient/Layer1D/BCE1D.swift:261 — Sources/GrAIdient/Layer1D/BCE1D.swift:261-284 | Sources/GrAIdient/Layer1D/BCESigmoid1D.swift:284-307 | Sources/GrAIdient/Layer1D/MSE1D.swift:257-280 — before extracting anything, compare `Sources/GrAIdient/Layer1D/BCE1D.swift` and `Sources/GrAIdient/Layer1D/BCESigmoid1D.swift` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 218 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/Layer1D/BCE1D.swift:261` 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 (24 lines × 3) Sources/GrAIdient/Layer2D/Activation2D.swift:285 — Sources/GrAIdient/Layer2D/Activation2D.swift:285-308 | Sources/GrAIdient/Layer2D/BN2D.swift:625-648 | Sources/GrAIdient/Layer2D/InstanceNorm2D.swift:549-572 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Activation2D.swift` and `Sources/GrAIdient/Layer2D/BN2D.swift` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 171 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/GrAIdient/Layer2D/Activation2D.swift:285` 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 (24 lines × 3) Sources/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:349 — Sources/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:349-372 | Sources/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:482-505 | Sources/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:696-719 — 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/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:349` 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/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:374` calls `get` and `Sources/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:721` 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 (24 lines × 3) Sources/GrAIdient/Layer2D/BN2D.swift:293 — Sources/GrAIdient/Layer2D/BN2D.swift:293-316 | Sources/GrAIdient/Layer2D/InstanceNorm2D.swift:218-241 | Sources/GrAIdient/LayerSeq/LayerNormSeq.swift:217-240 — before extracting anything, compare `Sources/GrAIdient/Layer2D/BN2D.swift` and `Sources/GrAIdient/Layer2D/InstanceNorm2D.swift` as WHOLE FILES: this scan already matched 21 separate duplicated blocks between them, totalling at least 320 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/GrAIdient/Layer2D/BN2D.swift:293` 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.
D4 · Code Duplication · Duplicated block (23 lines × 3) · ×4
  • Duplicated block (23 lines × 3) Sources/GrAIdient/Layer1D/Sum1D.swift:342 — Sources/GrAIdient/Layer1D/Sum1D.swift:342-364 | Sources/GrAIdient/Layer2D/Sum2D.swift:393-415 | Sources/GrAIdient/LayerSeq/SumSeq.swift:354-376 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Sum1D.swift` and `Sources/GrAIdient/Layer2D/Sum2D.swift` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 61 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. 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/GrAIdient/Layer1D/Sum1D.swift:342` 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 (23 lines × 3) Sources/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:281 — Sources/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:281-303 | Sources/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:421-443 | Sources/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:653-675 — 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/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:281` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (23 lines × 3) Sources/GrAIdient/Layer2D/BN2D.swift:250 — Sources/GrAIdient/Layer2D/BN2D.swift:250-272 | Sources/GrAIdient/Layer2D/InstanceNorm2D.swift:175-197 | Sources/GrAIdient/LayerSeq/LayerNormSeq.swift:174-196 — before extracting anything, compare `Sources/GrAIdient/Layer2D/BN2D.swift` and `Sources/GrAIdient/Layer2D/InstanceNorm2D.swift` as WHOLE FILES: this scan already matched 21 separate duplicated blocks between them, totalling at least 320 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/GrAIdient/Layer2D/BN2D.swift:250` 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 (23 lines × 3) Sources/GrAIdient/LayerSeq/ActivationSeq.swift:283 — Sources/GrAIdient/LayerSeq/ActivationSeq.swift:283-305 | Sources/GrAIdient/LayerSeq/LayerNormSeq.swift:545-567 | Sources/GrAIdient/LayerSeq/RMSNormSeq.swift:559-581 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/ActivationSeq.swift` and `Sources/GrAIdient/LayerSeq/LayerNormSeq.swift` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 132 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/GrAIdient/LayerSeq/ActivationSeq.swift:283` 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.
D4 · Code Duplication · Duplicated block (23 lines × 2) · ×4
  • Duplicated block (23 lines × 2) Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:58 — Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:58-80 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift:83-105 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift` and `Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 252 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (23 lines × 2) Sources/GrAIdient/Layer2D/VQ2D.swift:223 — Sources/GrAIdient/Layer2D/VQ2D.swift:223-245 | Sources/GrAIdient/LayerSeq/VQSeq.swift:213-235 — before extracting anything, compare `Sources/GrAIdient/Layer2D/VQ2D.swift` and `Sources/GrAIdient/LayerSeq/VQSeq.swift` as WHOLE FILES: this scan already matched 30 separate duplicated blocks between them, totalling at least 378 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/GrAIdient/Layer2D/VQ2D.swift:223` 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 (23 lines × 2) Sources/GrAIdient/LayerSeq/ValueSeq.swift:511 — Sources/GrAIdient/LayerSeq/ValueSeq.swift:511-533 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1113-1135 — both copies are in the same file, so extract the 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/GrAIdient/LayerSeq/ValueSeq.swift:511` 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 (23 lines × 2) Sources/GrAIdient/LayerSeq/ValueSeq.swift:1447 — Sources/GrAIdient/LayerSeq/ValueSeq.swift:1447-1469 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1549-1571 — both copies are in the same file, so extract the 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/GrAIdient/LayerSeq/ValueSeq.swift:1447` 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/GrAIdient/LayerSeq/ValueSeq.swift:1546` calls `download` and `Sources/GrAIdient/LayerSeq/ValueSeq.swift:1445` 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.
D4 · Code Duplication · Duplicated block (18 lines × 3) · ×4
  • Duplicated block (18 lines × 3) Sources/GrAIdient/Core/Layer/LayerNormalization.swift:926 — Sources/GrAIdient/Core/Layer/LayerNormalization.swift:926-943 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1620-1637 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1664-1681 — 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 (18 lines × 3) Sources/GrAIdient/Layer1D/Sum1D.swift:260 — Sources/GrAIdient/Layer1D/Sum1D.swift:260-277 | Sources/GrAIdient/Layer2D/Sum2D.swift:305-322 | Sources/GrAIdient/LayerSeq/SumSeq.swift:271-288 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Sum1D.swift` and `Sources/GrAIdient/Layer2D/Sum2D.swift` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 61 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. 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/GrAIdient/Layer1D/Sum1D.swift:260` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (18 lines × 3) Sources/GrAIdient/Layer2D/BCE2D.swift:242 — Sources/GrAIdient/Layer2D/BCE2D.swift:242-259 | Sources/GrAIdient/Layer2D/BCESigmoid2D.swift:285-302 | Sources/GrAIdient/Layer2D/MSE2D.swift:238-255 — before extracting anything, compare `Sources/GrAIdient/Layer2D/BCE2D.swift` and `Sources/GrAIdient/Layer2D/BCESigmoid2D.swift` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 271 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (18 lines × 3) Sources/GrAIdient/Layer2D/BCE2D.swift:455 — Sources/GrAIdient/Layer2D/BCE2D.swift:455-472 | Sources/GrAIdient/Layer2D/BCESigmoid2D.swift:490-507 | Sources/GrAIdient/Layer2D/MSE2D.swift:425-442 — before extracting anything, compare `Sources/GrAIdient/Layer2D/BCE2D.swift` and `Sources/GrAIdient/Layer2D/BCESigmoid2D.swift` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 271 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (17 lines × 4) · ×4
  • Duplicated block (17 lines × 4) Sources/GrAIdient/Layer1D/Constant1D.swift:129 — Sources/GrAIdient/Layer1D/Constant1D.swift:129-145 | Sources/GrAIdient/Layer2D/Constant2D.swift:136-152 | Sources/GrAIdient/LayerSeq/ConstantSeq.swift:130-146 | Sources/GrAIdient/LayerSeq/ConstantSeq.swift:615-631 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Constant1D.swift` and `Sources/GrAIdient/Layer2D/Constant2D.swift` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 131 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 (17 lines × 4) Sources/GrAIdient/Layer2D/BN2D.swift:454 — Sources/GrAIdient/Layer2D/BN2D.swift:454-470 | Sources/GrAIdient/Layer2D/BN2D.swift:512-528 | Sources/GrAIdient/Layer2D/InstanceNorm2D.swift:378-394 | Sources/GrAIdient/Layer2D/InstanceNorm2D.swift:436-452 — before extracting anything, compare `Sources/GrAIdient/Layer2D/BN2D.swift` and `Sources/GrAIdient/Layer2D/InstanceNorm2D.swift` as WHOLE FILES: this scan already matched 21 separate duplicated blocks between them, totalling at least 320 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/GrAIdient/Layer2D/BN2D.swift:454` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (17 lines × 4) Sources/GrAIdient/LayerSeq/ConcatSeq.swift:163 — Sources/GrAIdient/LayerSeq/ConcatSeq.swift:163-179 | Sources/GrAIdient/LayerSeq/ConcatSeq.swift:595-611 | Sources/GrAIdient/LayerSeq/MutiplySeq.swift:238-254 | Sources/GrAIdient/LayerSeq/SumSeq.swift:160-176 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/ConcatSeq.swift` and `Sources/GrAIdient/LayerSeq/MutiplySeq.swift` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 36 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/GrAIdient/LayerSeq/ConcatSeq.swift:163` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (17 lines × 4) Sources/GrAIdient/LayerSeq/ConstantSeq.swift:297 — Sources/GrAIdient/LayerSeq/ConstantSeq.swift:297-313 | Sources/GrAIdient/LayerSeq/ConstantSeq.swift:344-360 | Sources/GrAIdient/LayerSeq/EmbeddingSeq.swift:488-504 | Sources/GrAIdient/LayerSeq/EmbeddingSeq.swift:537-553 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/ConstantSeq.swift` and `Sources/GrAIdient/LayerSeq/EmbeddingSeq.swift` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 90 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/GrAIdient/LayerSeq/ConstantSeq.swift:297` 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.
D4 · Code Duplication · Duplicated block (14–15 lines × 2) · ×4
  • Duplicated block (14–15 lines × 2) Sources/GrAIdient/Layer1D/Dropout1D.swift:261 — Sources/GrAIdient/Layer1D/Dropout1D.swift:261-275 | Sources/GrAIdient/Layer1D/Dropout1D.swift:316-329 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (14–15 lines × 2) Sources/GrAIdient/Layer2D/Activation2D.swift:71 — Sources/GrAIdient/Layer2D/Activation2D.swift:71-84 | Sources/GrAIdient/LayerSeq/ActivationSeq.swift:68-82 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Activation2D.swift` and `Sources/GrAIdient/LayerSeq/ActivationSeq.swift` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 98 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/Layer2D/Activation2D.swift:71` 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 (14–15 lines × 2) Sources/GrAIdient/Layer2D/Transform/Crop2D.swift:324 — Sources/GrAIdient/Layer2D/Transform/Crop2D.swift:324-337 | Sources/GrAIdient/Layer2D/Transform/Pad2D.swift:254-268 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Transform/Crop2D.swift` and `Sources/GrAIdient/Layer2D/Transform/Pad2D.swift` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 178 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/GrAIdient/Layer2D/Transform/Crop2D.swift:324` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (14–15 lines × 2) Sources/GrAIdient/LayerSeq/QuerySeq.swift:1945 — Sources/GrAIdient/LayerSeq/QuerySeq.swift:1945-1958 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1907-1921 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/QuerySeq.swift` and `Sources/GrAIdient/LayerSeq/ValueSeq.swift` as WHOLE FILES: this scan already matched 39 separate duplicated blocks between them, totalling at least 427 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/GrAIdient/LayerSeq/QuerySeq.swift:1945` 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.
D4 · Code Duplication · Duplicated block (11 lines × 4) · ×4
  • Duplicated block (11 lines × 4) Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1070 — Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1070-1080 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1100-1110 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1852-1862 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1890-1900 — 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/GrAIdient/Core/Layer/LayerNormalization.swift:1070` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1889` calls `setBytes` and `Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1069` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (11 lines × 4) Sources/GrAIdient/Layer1D/Concat1D.swift:363 — Sources/GrAIdient/Layer1D/Concat1D.swift:363-373 | Sources/GrAIdient/Layer2D/Concat2D.swift:407-417 | Sources/GrAIdient/LayerSeq/ConcatSeq.swift:401-411 | Sources/GrAIdient/LayerSeq/ConcatSeq.swift:826-836 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Concat1D.swift` and `Sources/GrAIdient/Layer2D/Concat2D.swift` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 87 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. 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 (11 lines × 4) Sources/GrAIdient/Layer2D/Convolution2D.swift:895 — Sources/GrAIdient/Layer2D/Convolution2D.swift:895-905 | Sources/GrAIdient/Layer2D/Convolution2D.swift:1102-1112 | Sources/GrAIdient/Layer2D/Deconvolution2D.swift:326-336 | Sources/GrAIdient/Layer2D/Deconvolution2D.swift:542-552 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Convolution2D.swift` and `Sources/GrAIdient/Layer2D/Deconvolution2D.swift` as WHOLE FILES: this scan already matched 26 separate duplicated blocks between them, totalling at least 499 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/GrAIdient/Layer2D/Convolution2D.swift:895` 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/GrAIdient/Layer2D/Convolution2D.swift:1100` calls `download` and `Sources/GrAIdient/Layer2D/Convolution2D.swift:893` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (11 lines × 4) Sources/GrAIdient/Layer2D/Convolution2D.swift:995 — Sources/GrAIdient/Layer2D/Convolution2D.swift:995-1005 | Sources/GrAIdient/Layer2D/Convolution2D.swift:1222-1232 | Sources/GrAIdient/Layer2D/Deconvolution2D.swift:437-447 | Sources/GrAIdient/Layer2D/Deconvolution2D.swift:675-685 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Convolution2D.swift` and `Sources/GrAIdient/Layer2D/Deconvolution2D.swift` as WHOLE FILES: this scan already matched 26 separate duplicated blocks between them, totalling at least 499 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/GrAIdient/Layer2D/Convolution2D.swift:995` 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.
D4 · Code Duplication · Duplicated block (11 lines × 3) · ×4
  • Duplicated block (11 lines × 3) Sources/GrAIdient/Layer2D/Concat2D.swift:105 — Sources/GrAIdient/Layer2D/Concat2D.swift:105-115 | Sources/GrAIdient/Layer2D/Concat2D.swift:128-138 | Sources/GrAIdient/Layer2D/Concat2D.swift:198-208 — 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/GrAIdient/Layer2D/Concat2D.swift:105` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 3) Sources/GrAIdient/Layer2D/Constant2D.swift:493 — Sources/GrAIdient/Layer2D/Constant2D.swift:493-503 | Sources/GrAIdient/Layer2D/Convolution2D.swift:1487-1498 | Sources/GrAIdient/Layer2D/Deconvolution2D.swift:860-871 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Constant2D.swift` and `Sources/GrAIdient/Layer2D/Convolution2D.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. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/Layer2D/Constant2D.swift:493` 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/GrAIdient/Layer2D/Transform/Rotate2D.swift:239 — Sources/GrAIdient/Layer2D/Transform/Rotate2D.swift:239-249 | Sources/GrAIdient/Layer2D/Transform/Rotate2D.swift:312-322 | Sources/GrAIdient/Layer2D/Transform/Rotate2D.swift:417-427 — 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/GrAIdient/Layer2D/Transform/Rotate2D.swift:239` 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/GrAIdient/LayerSeq/ValueSeq.swift:257 — Sources/GrAIdient/LayerSeq/ValueSeq.swift:257-267 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:829-839 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1537-1547 — 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/GrAIdient/LayerSeq/ValueSeq.swift:257` 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 · Duplicated block (10 lines × 6) · ×4
  • Duplicated block (10 lines × 6) Sources/GrAIdient/Layer1D/DotProduct1D.swift:426 — Sources/GrAIdient/Layer1D/DotProduct1D.swift:426-435 | Sources/GrAIdient/Layer1D/DotProduct1D.swift:453-462 | Sources/GrAIdient/Layer1D/Dropout1D.swift:425-434 | Sources/GrAIdient/Layer1D/LinearError1D.swift:305-314 | Sources/GrAIdient/Layer1D/Softmax1D.swift:320-329 | Sources/GrAIdient/LayerSeq/SelectSeq.swift:270-279 — there are 6 copies across 5 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 6 sites; resolving a subset leaves the remainder to drift apart. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Sources/GrAIdient/Layer1D/Dropout1D.swift:422` calls `setBuffer`, `setBytes` and `Sources/GrAIdient/Layer1D/LinearError1D.swift:303` 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 × 6) Sources/GrAIdient/Layer1D/Sum1D.swift:118 — Sources/GrAIdient/Layer1D/Sum1D.swift:118-127 | Sources/GrAIdient/Layer1D/Sum1D.swift:191-200 | Sources/GrAIdient/LayerSeq/MutiplySeq.swift:202-211 | Sources/GrAIdient/LayerSeq/MutiplySeq.swift:278-287 | Sources/GrAIdient/LayerSeq/SumSeq.swift:124-133 | Sources/GrAIdient/LayerSeq/SumSeq.swift:200-209 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Sum1D.swift` and `Sources/GrAIdient/LayerSeq/SumSeq.swift` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 71 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/GrAIdient/Layer1D/Sum1D.swift:118` 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 × 6) Sources/GrAIdient/Layer2D/BCE2D.swift:115 — Sources/GrAIdient/Layer2D/BCE2D.swift:115-124 | Sources/GrAIdient/Layer2D/BCE2D.swift:185-194 | Sources/GrAIdient/Layer2D/BCE2D.swift:347-356 | Sources/GrAIdient/Layer2D/BCESigmoid2D.swift:118-127 | Sources/GrAIdient/Layer2D/BCESigmoid2D.swift:208-217 | Sources/GrAIdient/Layer2D/BCESigmoid2D.swift:390-399 — before extracting anything, compare `Sources/GrAIdient/Layer2D/BCE2D.swift` and `Sources/GrAIdient/Layer2D/BCESigmoid2D.swift` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 271 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/GrAIdient/Layer2D/BCE2D.swift:115` 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 × 6) Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:336 — Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:336-345 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:466-475 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:634-643 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift:316-325 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift:419-428 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift:561-570 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift` and `Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 252 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (10 lines × 4) · ×4
  • Duplicated block (10 lines × 4) Sources/GrAIdient/Layer1D/Concat1D.swift:372 — Sources/GrAIdient/Layer1D/Concat1D.swift:372-381 | Sources/GrAIdient/Layer2D/Concat2D.swift:416-425 | Sources/GrAIdient/Layer2D/SimilarityError2D.swift:496-505 | Sources/GrAIdient/LayerSeq/ConcatSeq.swift:835-844 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Concat1D.swift` and `Sources/GrAIdient/Layer2D/Concat2D.swift` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 87 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Sources/GrAIdient/Layer2D/Concat2D.swift:428` calls `setBytes` and `Sources/GrAIdient/Layer1D/Concat1D.swift:384` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (10 lines × 4) Sources/GrAIdient/Layer2D/Convolution2D.swift:935 — Sources/GrAIdient/Layer2D/Convolution2D.swift:935-944 | Sources/GrAIdient/Layer2D/Convolution2D.swift:1152-1161 | Sources/GrAIdient/Layer2D/Deconvolution2D.swift:372-381 | Sources/GrAIdient/Layer2D/Deconvolution2D.swift:599-608 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Convolution2D.swift` and `Sources/GrAIdient/Layer2D/Deconvolution2D.swift` as WHOLE FILES: this scan already matched 26 separate duplicated blocks between them, totalling at least 499 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/GrAIdient/Layer2D/Convolution2D.swift:935` it begins part-way through the construct above it, so those exact lines 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 × 4) Sources/GrAIdient/LayerSeq/ConcatSeq.swift:845 — Sources/GrAIdient/LayerSeq/ConcatSeq.swift:845-854 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:537-546 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1141-1150 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:2052-2061 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/ConcatSeq.swift` and `Sources/GrAIdient/LayerSeq/ValueSeq.swift` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 92 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (10 lines × 4) Sources/GrAIdient/Layer1D/FullyConnected.swift:506 — Sources/GrAIdient/Layer1D/FullyConnected.swift:506-515 | Sources/GrAIdient/Layer2D/Convolution2D.swift:697-706 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:397-406 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:372-381 — before extracting anything, compare `Sources/GrAIdient/Layer1D/FullyConnected.swift` and `Sources/GrAIdient/Layer2D/Convolution2D.swift` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 103 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.
D4 · Code Duplication · Duplicated block (9–10 lines × 2) · ×4
  • Duplicated block (9–10 lines × 2) Sources/GrAIdient/Core/Layer/LayerNormalization.swift:455 — Sources/GrAIdient/Core/Layer/LayerNormalization.swift:455-463 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1242-1251 — both copies are in the same file, so extract the 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/GrAIdient/Core/Layer/LayerNormalization.swift:455` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (9–10 lines × 2) Sources/GrAIdient/Layer2D/Normalize2D.swift:163 — Sources/GrAIdient/Layer2D/Normalize2D.swift:163-172 | Sources/GrAIdient/Layer2D/Normalize2D.swift:521-529 — both copies are in the same file, so extract the 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/GrAIdient/Layer2D/Normalize2D.swift:163` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9–10 lines × 2) Sources/GrAIdient/Layer2D/VQ2D.swift:555 — Sources/GrAIdient/Layer2D/VQ2D.swift:555-563 | Sources/GrAIdient/Layer2D/VQ2D.swift:609-618 — both copies are in the same file, so extract the 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/GrAIdient/Layer2D/VQ2D.swift:555` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9–10 lines × 2) Sources/GrAIdient/LayerSeq/QuerySeq.swift:367 — Sources/GrAIdient/LayerSeq/QuerySeq.swift:367-375 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:814-823 — both copies are in the same file, so extract the 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/GrAIdient/LayerSeq/QuerySeq.swift:814` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (9 lines × 4) · ×4
  • Duplicated block (9 lines × 4) Sources/GrAIdient/Layer1D/DotProduct1D.swift:158 — Sources/GrAIdient/Layer1D/DotProduct1D.swift:158-166 | Sources/GrAIdient/Layer1D/DotProduct1D.swift:241-249 | Sources/GrAIdient/Layer1D/Sum1D.swift:117-125 | Sources/GrAIdient/Layer1D/Sum1D.swift:190-198 — before extracting anything, compare `Sources/GrAIdient/Layer1D/DotProduct1D.swift` and `Sources/GrAIdient/Layer1D/Sum1D.swift` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 54 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/GrAIdient/Layer1D/DotProduct1D.swift:158` 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/GrAIdient/Layer1D/DotProduct1D.swift:238` calls `download` and `Sources/GrAIdient/Layer1D/DotProduct1D.swift:156` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (9 lines × 4) Sources/GrAIdient/Layer1D/FullyConnected.swift:1104 — Sources/GrAIdient/Layer1D/FullyConnected.swift:1104-1112 | Sources/GrAIdient/Layer1D/FullyConnected.swift:1176-1184 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:1254-1262 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:1138-1146 — before extracting anything, compare `Sources/GrAIdient/Layer1D/FullyConnected.swift` and `Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift` as WHOLE FILES: this scan already matched 32 separate duplicated blocks between them, totalling at least 473 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/GrAIdient/Layer1D/FullyConnected.swift:1104` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 4) Sources/GrAIdient/Layer2D/AvgPool2D.swift:169 — Sources/GrAIdient/Layer2D/AvgPool2D.swift:169-177 | Sources/GrAIdient/Layer2D/MaxPool2D.swift:370-378 | Sources/GrAIdient/Layer2D/SelectNeurons2D.swift:268-276 | Sources/GrAIdient/Layer2D/SelfCorrelate2D.swift:185-193 — before extracting anything, compare `Sources/GrAIdient/Layer2D/AvgPool2D.swift` and `Sources/GrAIdient/Layer2D/MaxPool2D.swift` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 39 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Sources/GrAIdient/Layer2D/MaxPool2D.swift:369` calls `UInt32` and `Sources/GrAIdient/Layer2D/AvgPool2D.swift:168` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (9 lines × 4) Sources/GrAIdient/LayerSeq/ConcatSeq.swift:121 — Sources/GrAIdient/LayerSeq/ConcatSeq.swift:121-129 | Sources/GrAIdient/LayerSeq/ConcatSeq.swift:208-216 | Sources/GrAIdient/LayerSeq/ConcatSeq.swift:553-561 | Sources/GrAIdient/LayerSeq/ConcatSeq.swift:640-648 — 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/GrAIdient/LayerSeq/ConcatSeq.swift:121` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (8–9 lines × 2) · ×4
  • Duplicated block (8–9 lines × 2) Sources/GrAIdient/Layer2D/Multiply2D.swift:370 — Sources/GrAIdient/Layer2D/Multiply2D.swift:370-378 | Sources/GrAIdient/LayerSeq/MutiplySeq.swift:337-344 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Multiply2D.swift` and `Sources/GrAIdient/LayerSeq/MutiplySeq.swift` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 103 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/GrAIdient/Layer2D/Multiply2D.swift:370` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (8–9 lines × 2) Sources/GrAIdient/Layer2D/Normalize2D.swift:236 — Sources/GrAIdient/Layer2D/Normalize2D.swift:236-244 | Sources/GrAIdient/Layer2D/Normalize2D.swift:656-663 — both copies are in the same file, so extract the 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/GrAIdient/Layer2D/Normalize2D.swift:656` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (8–9 lines × 2) Sources/GrAIdient/Layer2D/Transform/Crop2D.swift:302 — Sources/GrAIdient/Layer2D/Transform/Crop2D.swift:302-309 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:580-588 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Transform/Crop2D.swift` and `Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 117 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/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:580` it begins part-way through the construct above it, so those exact lines 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–9 lines × 2) Sources/GrAIdient/LayerSeq/ValueSeq.swift:712 — Sources/GrAIdient/LayerSeq/ValueSeq.swift:712-719 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:901-909 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/LayerSeq/ValueSeq.swift:712` 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.
D4 · Code Duplication · Duplicated block (8 lines × 4) · ×4
  • Duplicated block (8 lines × 4) Sources/GrAIdient/Layer2D/AvgPool2D.swift:240 — Sources/GrAIdient/Layer2D/AvgPool2D.swift:240-247 | Sources/GrAIdient/Layer2D/MaxPool2D.swift:460-467 | Sources/GrAIdient/Layer2D/SelectNeurons2D.swift:342-349 | Sources/GrAIdient/Layer2D/SelfCorrelate2D.swift:266-273 — before extracting anything, compare `Sources/GrAIdient/Layer2D/AvgPool2D.swift` and `Sources/GrAIdient/Layer2D/MaxPool2D.swift` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 39 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Sources/GrAIdient/Layer2D/SelectNeurons2D.swift:339` calls `UInt32` and `Sources/GrAIdient/Layer2D/AvgPool2D.swift:236` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (8 lines × 4) Sources/GrAIdient/Layer2D/VQ2D.swift:526 — Sources/GrAIdient/Layer2D/VQ2D.swift:526-533 | Sources/GrAIdient/Layer2D/VQ2D.swift:1350-1357 | Sources/GrAIdient/LayerSeq/VQSeq.swift:454-461 | Sources/GrAIdient/LayerSeq/VQSeq.swift:1267-1274 — before extracting anything, compare `Sources/GrAIdient/Layer2D/VQ2D.swift` and `Sources/GrAIdient/LayerSeq/VQSeq.swift` as WHOLE FILES: this scan already matched 30 separate duplicated blocks between them, totalling at least 378 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/GrAIdient/Layer2D/VQ2D.swift:526` 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/GrAIdient/Layer2D/VQ2D.swift:1347` calls `setBuffer`, `setBytes` and `Sources/GrAIdient/Layer2D/VQ2D.swift:525` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (8 lines × 4) Sources/GrAIdient/Layer2D/VQ2D.swift:713 — Sources/GrAIdient/Layer2D/VQ2D.swift:713-720 | Sources/GrAIdient/Layer2D/VQ2D.swift:746-753 | Sources/GrAIdient/LayerSeq/VQSeq.swift:636-643 | Sources/GrAIdient/LayerSeq/VQSeq.swift:669-676 — before extracting anything, compare `Sources/GrAIdient/Layer2D/VQ2D.swift` and `Sources/GrAIdient/LayerSeq/VQSeq.swift` as WHOLE FILES: this scan already matched 30 separate duplicated blocks between them, totalling at least 378 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (8 lines × 4) Sources/GrAIdient/Layer1D/Constant1D.swift:109 — Sources/GrAIdient/Layer1D/Constant1D.swift:109-116 | Sources/GrAIdient/Layer2D/Constant2D.swift:116-123 | Sources/GrAIdient/LayerSeq/ConstantSeq.swift:110-117 | Sources/GrAIdient/LayerSeq/ConstantSeq.swift:595-602 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Constant1D.swift` and `Sources/GrAIdient/Layer2D/Constant2D.swift` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 131 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.
D4 · Code Duplication · Duplicated block (7 lines × 6) · ×4
  • Duplicated block (7 lines × 6) Sources/GrAIdient/Layer1D/DotProduct1D.swift:419 — Sources/GrAIdient/Layer1D/DotProduct1D.swift:419-425 | Sources/GrAIdient/Layer1D/DotProduct1D.swift:446-452 | Sources/GrAIdient/Layer2D/Convolution2D.swift:1616-1622 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:1147-1153 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:1191-1197 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:1078-1084 — there are 6 copies across 4 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 6 sites; resolving a subset leaves the remainder to drift apart.
  • Duplicated block (7 lines × 6) Sources/GrAIdient/Layer2D/Convolution2D.swift:1690 — Sources/GrAIdient/Layer2D/Convolution2D.swift:1690-1696 | Sources/GrAIdient/Layer2D/VQ2D.swift:753-759 | Sources/GrAIdient/LayerSeq/EmbeddingSeq.swift:724-730 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:1198-1204 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:1083-1089 | Sources/GrAIdient/LayerSeq/VQSeq.swift:676-682 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 6 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 6 times. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/Layer2D/Convolution2D.swift:1690` 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/GrAIdient/LayerSeq/FullyConnectedPatch.swift:1196` calls `setBytes` and `Sources/GrAIdient/Layer2D/VQ2D.swift:751` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (7 lines × 6) Sources/GrAIdient/LayerSeq/ConcatSeq.swift:309 — Sources/GrAIdient/LayerSeq/ConcatSeq.swift:309-315 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:821-827 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:1777-1783 | Sources/GrAIdient/LayerSeq/SoftmaxSeq.swift:255-261 | Sources/GrAIdient/LayerSeq/SoftmaxSeq.swift:529-535 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1771-1777 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/ConcatSeq.swift` and `Sources/GrAIdient/LayerSeq/QuerySeq.swift` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 81 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/LayerSeq/ConcatSeq.swift:309` 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/GrAIdient/LayerSeq/QuerySeq.swift:829` calls `setBytes` and `Sources/GrAIdient/LayerSeq/ConcatSeq.swift:317` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (7 lines × 6) Sources/GrAIdient/LayerSeq/QuerySeq.swift:360 — Sources/GrAIdient/LayerSeq/QuerySeq.swift:360-366 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:480-486 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:362-368 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:480-486 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:937-943 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1066-1072 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/QuerySeq.swift` and `Sources/GrAIdient/LayerSeq/ValueSeq.swift` as WHOLE FILES: this scan already matched 39 separate duplicated blocks between them, totalling at least 427 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (5 lines × 4) · ×4
  • Duplicated block (5 lines × 4) Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1037 — Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1037-1041 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1931-1935 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1973-1977 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:2645-2649 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1036` calls `setBytes` and `Sources/GrAIdient/Core/Layer/LayerNormalization.swift:2644` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (5 lines × 4) Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1068 — Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1068-1072 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1850-1854 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1887-1891 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:2603-2607 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1892` calls `setBytes` and `Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1073` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (5 lines × 4) Sources/GrAIdient/Layer1D/FullyConnected.swift:913 — Sources/GrAIdient/Layer1D/FullyConnected.swift:913-917 | Sources/GrAIdient/Layer2D/Convolution2D.swift:1364-1368 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:935-939 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:839-843 — before extracting anything, compare `Sources/GrAIdient/Layer1D/FullyConnected.swift` and `Sources/GrAIdient/Layer2D/Convolution2D.swift` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 103 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:940` calls `setBytes` and `Sources/GrAIdient/Layer1D/FullyConnected.swift:918` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (5 lines × 4) Sources/GrAIdient/Layer2D/AdaIN.swift:713 — Sources/GrAIdient/Layer2D/AdaIN.swift:713-717 | Sources/GrAIdient/Layer2D/InstanceNorm2D.swift:644-648 | Sources/GrAIdient/Layer2D/InstanceNorm2D.swift:683-687 | Sources/GrAIdient/Layer2D/InstanceNorm2D.swift:721-725 — before extracting anything, compare `Sources/GrAIdient/Layer2D/AdaIN.swift` and `Sources/GrAIdient/Layer2D/InstanceNorm2D.swift` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 92 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/GrAIdient/Layer2D/AdaIN.swift:713` 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.
D36 · Supply-chain Provenance & Signing · REDACTED · ×3
  • REDACTED
  • REDACTED
  • REDACTED
D4 · Code Duplication · Edited copy of a member (39 corresponding lines) · ×3
  • Edited copy of a member (39 corresponding lines) Sources/GrAIdient/Core/Layer/LayerNormalization.swift:920 — Sources/GrAIdient/Core/Layer/LayerNormalization.swift:920-964 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1614-1653 — 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.
  • Edited copy of a member (39 corresponding lines) Sources/GrAIdient/LayerSeq/RoPESeq.swift:239 — Sources/GrAIdient/LayerSeq/RoPESeq.swift:239-289 | Sources/GrAIdient/LayerSeq/RoPESeq.swift:306-344 — 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.
  • Edited copy of a member (39 corresponding lines) Sources/GrAIdient/Layer1D/Softmax1D.swift:258 — Sources/GrAIdient/Layer1D/Softmax1D.swift:258-296 | Sources/GrAIdient/LayerSeq/SoftmaxSeq.swift:273-314 — 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 copy of a member (42 corresponding lines) · ×3
  • Edited copy of a member (42 corresponding lines) Sources/GrAIdient/Layer2D/VQ2D.swift:1322 — Sources/GrAIdient/Layer2D/VQ2D.swift:1322-1363 | Sources/GrAIdient/LayerSeq/VQSeq.swift:1239-1280 — These two members are one piece of code written twice and then edited apart: 42 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 (42 corresponding lines) Sources/GrAIdient/Layer1D/BCESigmoid1D.swift:95 — Sources/GrAIdient/Layer1D/BCESigmoid1D.swift:95-137 | Sources/GrAIdient/Layer1D/BCESigmoid1D.swift:150-191 — These two members are one piece of code written twice and then edited apart: 42 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 (42 corresponding lines) Sources/GrAIdient/Layer2D/SelfCorrelate2D.swift:79 — Sources/GrAIdient/Layer2D/SelfCorrelate2D.swift:79-120 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:697-741 — These two members are one piece of code written twice and then edited apart: 42 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) · ×3
  • Edited copy of a member (41 corresponding lines) Sources/GrAIdient/Layer2D/VQ2D.swift:548 — Sources/GrAIdient/Layer2D/VQ2D.swift:548-591 | Sources/GrAIdient/LayerSeq/VQSeq.swift:476-516 — 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.
  • Edited copy of a member (41 corresponding lines) Sources/GrAIdient/LayerSeq/LayerNormSeq.swift:375 — Sources/GrAIdient/LayerSeq/LayerNormSeq.swift:375-415 | Sources/GrAIdient/LayerSeq/RMSNormSeq.swift:389-429 — 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.
  • Edited copy of a member (41 corresponding lines) Sources/GrAIdient/Layer1D/FullyConnected.swift:354 — Sources/GrAIdient/Layer1D/FullyConnected.swift:354-396 | Sources/GrAIdient/Layer1D/FullyConnected.swift:408-448 — 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 (40 corresponding lines) · ×3
  • Edited copy of a member (40 corresponding lines) Sources/GrAIdient/Layer2D/BN2D.swift:452 — Sources/GrAIdient/Layer2D/BN2D.swift:452-491 | Sources/GrAIdient/Layer2D/InstanceNorm2D.swift:376-415 — 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.
  • Edited copy of a member (40 corresponding lines) Sources/GrAIdient/Layer1D/Dropout1D.swift:162 — Sources/GrAIdient/Layer1D/Dropout1D.swift:162-201 | Sources/GrAIdient/Layer1D/Dropout1D.swift:208-247 — 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.
  • Edited copy of a member (40 corresponding lines) Sources/GrAIdient/Layer2D/Convolution2D.swift:600 — Sources/GrAIdient/Layer2D/Convolution2D.swift:600-639 | Sources/GrAIdient/Layer2D/Deconvolution2D.swift:196-235 — 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 (34 corresponding lines) · ×3
  • Edited copy of a member (34 corresponding lines) Sources/GrAIdient/Layer2D/Multiply2D.swift:347 — Sources/GrAIdient/Layer2D/Multiply2D.swift:347-386 | Sources/GrAIdient/LayerSeq/MutiplySeq.swift:318-351 — 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.
  • Edited copy of a member (34 corresponding lines) Sources/GrAIdient/Core/Layer/LayerUpdate.swift:436 — Sources/GrAIdient/Core/Layer/LayerUpdate.swift:436-469 | Sources/GrAIdient/Core/Layer/LayerUpdate.swift:504-537 — 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.
  • Edited copy of a member (34 corresponding lines) Sources/GrAIdient/LayerSeq/QuerySeq.swift:1820 — Sources/GrAIdient/LayerSeq/QuerySeq.swift:1820-1853 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1814-1847 — 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 (26 corresponding lines) · ×3
  • Edited copy of a member (26 corresponding lines) Sources/GrAIdient/LayerSeq/ConstantSeq.swift:386 — Sources/GrAIdient/LayerSeq/ConstantSeq.swift:386-411 | Sources/GrAIdient/LayerSeq/ConstantSeq.swift:889-914 — These two members are one piece of code written twice and then edited apart: 26 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 (26 corresponding lines) Sources/GrAIdient/Layer2D/Transform/Rotate2D.swift:42 — Sources/GrAIdient/Layer2D/Transform/Rotate2D.swift:42-68 | Sources/GrAIdient/Layer2D/Transform/Rotate2D.swift:80-105 — These two members are one piece of code written twice and then edited apart: 26 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 (26 corresponding lines) Sources/GrAIdient/Utils/Buffer.swift:21 — Sources/GrAIdient/Utils/Buffer.swift:21-46 | Sources/GrAIdient/Utils/Buffer.swift:58-85 — These two members are one piece of code written twice and then edited apart: 26 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 (20 corresponding lines) · ×3
  • Edited copy of a member (20 corresponding lines) Sources/GrAIdient/Core/Function/Normalization.swift:249 — Sources/GrAIdient/Core/Function/Normalization.swift:249-268 | Sources/GrAIdient/Core/Function/Normalization.swift:281-309 — 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.
  • Edited copy of a member (20 corresponding lines) Sources/GrAIdient/Layer2D/VQ2D.swift:179 — Sources/GrAIdient/Layer2D/VQ2D.swift:179-198 | Sources/GrAIdient/LayerSeq/VQSeq.swift:168-188 — 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.
  • Edited copy of a member (20 corresponding lines) Sources/GrAIdient/Layer2D/Concat2D.swift:23 — Sources/GrAIdient/Layer2D/Concat2D.swift:23-42 | Sources/GrAIdient/Layer2D/SimilarityError2D.swift:50-73 — 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 copy of a member (22 corresponding lines) · ×3
  • Edited copy of a member (22 corresponding lines) Sources/GrAIdient/Layer2D/Transform/FTFrequences2D.swift:229 — Sources/GrAIdient/Layer2D/Transform/FTFrequences2D.swift:229-250 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:1296-1317 — 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/GrAIdient/Layer1D/Concat1D.swift:228 — Sources/GrAIdient/Layer1D/Concat1D.swift:228-249 | Sources/GrAIdient/Layer2D/Concat2D.swift:264-287 — 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/GrAIdient/LayerSeq/ConcatSeq.swift:23 — Sources/GrAIdient/LayerSeq/ConcatSeq.swift:23-44 | Sources/GrAIdient/LayerSeq/ConcatSeq.swift:455-476 — These two members are one piece of code written twice and then edited apart: 22 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (23 corresponding lines) · ×3
  • Edited copy of a member (23 corresponding lines) Sources/GrAIdient/Layer1D/Base/LayerOutput1D.swift:312 — Sources/GrAIdient/Layer1D/Base/LayerOutput1D.swift:312-335 | Sources/GrAIdient/Layer1D/Input1D.swift:366-388 — 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.
  • Edited copy of a member (23 corresponding lines) Sources/GrAIdient/Layer2D/Convolution2D.swift:207 — Sources/GrAIdient/Layer2D/Convolution2D.swift:207-229 | Sources/GrAIdient/Layer2D/Convolution2D.swift:240-262 — 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.
  • Edited copy of a member (23 corresponding lines) Sources/GrAIdient/Layer2D/Base/LayerMerge2D.swift:32 — Sources/GrAIdient/Layer2D/Base/LayerMerge2D.swift:32-58 | Sources/GrAIdient/Layer2D/Base/LayerMerge2D.swift:61-83 — 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 copies of one member (3 members, 16+ corresponding lines) · ×3
  • Edited copies of one member (3 members, 16+ corresponding lines) Sources/GrAIdient/Core/Function/Activation.swift:128 — Sources/GrAIdient/Core/Function/Activation.swift:128-143 | Sources/GrAIdient/Core/Function/Activation.swift:150-166 | Sources/GrAIdient/Core/Function/Activation.swift:173-188 — 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.
  • Edited copies of one member (3 members, 16+ corresponding lines) Sources/GrAIdient/Layer2D/Transform/Flip2D.swift:45 — Sources/GrAIdient/Layer2D/Transform/Flip2D.swift:45-60 | Sources/GrAIdient/Layer2D/Transform/LinearScale2D.swift:31-47 | Sources/GrAIdient/Layer2D/Transform/Pad2D.swift:33-50 — 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.
  • Edited copies of one member (3 members, 16+ corresponding lines) Sources/GrAIdient/Layer1D/Base/Layer1D.swift:156 — Sources/GrAIdient/Layer1D/Base/Layer1D.swift:156-171 | Sources/GrAIdient/Layer2D/Base/Layer2D.swift:237-254 | Sources/GrAIdient/LayerSeq/Base/LayerSeq.swift:167-184 — 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 · Duplicated block (28 lines × 2) · ×3
  • Duplicated block (28 lines × 2) Sources/GrAITestsUtils/Trainer.swift:866 — Sources/GrAITestsUtils/Trainer.swift:866-893 | Sources/GrAITestsUtils/Trainer.swift:971-998 — both copies are in the same file, so extract the 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/GrAITestsUtils/Trainer.swift:866` 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 (28 lines × 2) Sources/GrAIdient/Layer2D/Multiply2D.swift:420 — Sources/GrAIdient/Layer2D/Multiply2D.swift:420-447 | Sources/GrAIdient/LayerSeq/MutiplySeq.swift:385-412 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Multiply2D.swift` and `Sources/GrAIdient/LayerSeq/MutiplySeq.swift` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 103 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/GrAIdient/Layer2D/Multiply2D.swift:420` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (28 lines × 2) Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:1047 — Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:1047-1074 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:920-947 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift` and `Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift` as WHOLE FILES: this scan already matched 54 separate duplicated blocks between them, totalling at least 760 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/GrAIdient/LayerSeq/FullyConnectedPatch.swift:1047` 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.
D4 · Code Duplication · Duplicated block (22 lines × 3) · ×3
  • Duplicated block (22 lines × 3) Sources/GrAIdient/Core/Layer/LayerNormalization.swift:404 — Sources/GrAIdient/Core/Layer/LayerNormalization.swift:404-425 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1207-1228 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:2079-2100 — 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 (22 lines × 3) Sources/GrAIdient/Layer1D/FullyConnected.swift:1267 — Sources/GrAIdient/Layer1D/FullyConnected.swift:1267-1288 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:1345-1366 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:1229-1250 — before extracting anything, compare `Sources/GrAIdient/Layer1D/FullyConnected.swift` and `Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift` as WHOLE FILES: this scan already matched 32 separate duplicated blocks between them, totalling at least 473 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 (22 lines × 3) Sources/GrAIdient/Layer2D/BCE2D.swift:492 — Sources/GrAIdient/Layer2D/BCE2D.swift:492-513 | Sources/GrAIdient/Layer2D/BCESigmoid2D.swift:527-548 | Sources/GrAIdient/Layer2D/MSE2D.swift:462-483 — before extracting anything, compare `Sources/GrAIdient/Layer2D/BCE2D.swift` and `Sources/GrAIdient/Layer2D/BCESigmoid2D.swift` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 271 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/GrAIdient/Layer2D/BCE2D.swift:492` 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.
D4 · Code Duplication · Duplicated block (20–21 lines × 2) · ×3
  • Duplicated block (20–21 lines × 2) Sources/GrAIdient/Core/Layer/LayerUpdate.swift:305 — Sources/GrAIdient/Core/Layer/LayerUpdate.swift:305-325 | Sources/GrAIdient/Core/Layer/LayerUpdate.swift:370-389 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/Core/Layer/LayerUpdate.swift:305` 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 (20–21 lines × 2) Sources/GrAIdient/Layer2D/AdaIN.swift:332 — Sources/GrAIdient/Layer2D/AdaIN.swift:332-352 | Sources/GrAIdient/Layer2D/AdaIN.swift:455-474 — both copies are in the same file, so extract the 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/GrAIdient/Layer2D/AdaIN.swift:332` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (20–21 lines × 2) Sources/GrAIdient/Layer2D/Convolution2D.swift:917 — Sources/GrAIdient/Layer2D/Convolution2D.swift:917-936 | Sources/GrAIdient/Layer2D/Deconvolution2D.swift:352-372 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Convolution2D.swift` and `Sources/GrAIdient/Layer2D/Deconvolution2D.swift` as WHOLE FILES: this scan already matched 26 separate duplicated blocks between them, totalling at least 499 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/GrAIdient/Layer2D/Convolution2D.swift:917` it begins part-way through the construct above it, so those 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.
D4 · Code Duplication · Duplicated block (15 lines × 4) · ×3
  • Duplicated block (15 lines × 4) Sources/GrAIdient/Layer1D/FullyConnected.swift:572 — Sources/GrAIdient/Layer1D/FullyConnected.swift:572-586 | Sources/GrAIdient/Layer2D/Convolution2D.swift:778-792 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:463-477 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:438-452 — before extracting anything, compare `Sources/GrAIdient/Layer1D/FullyConnected.swift` and `Sources/GrAIdient/Layer2D/Convolution2D.swift` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 103 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/GrAIdient/Layer1D/FullyConnected.swift:572` 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 (15 lines × 4) Sources/GrAIdient/Layer2D/Deconvolution2D.swift:296 — Sources/GrAIdient/Layer2D/Deconvolution2D.swift:296-310 | Sources/GrAIdient/Layer2D/Deconvolution2D.swift:334-348 | Sources/GrAIdient/Layer2D/Deconvolution2D.swift:441-455 | Sources/GrAIdient/Layer2D/Deconvolution2D.swift:734-748 — 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/GrAIdient/Layer2D/Deconvolution2D.swift:296` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15 lines × 4) Sources/GrAIdient/Layer2D/VQ2D.swift:479 — Sources/GrAIdient/Layer2D/VQ2D.swift:479-493 | Sources/GrAIdient/Layer2D/VQ2D.swift:1225-1239 | Sources/GrAIdient/LayerSeq/VQSeq.swift:407-421 | Sources/GrAIdient/LayerSeq/VQSeq.swift:1143-1157 — before extracting anything, compare `Sources/GrAIdient/Layer2D/VQ2D.swift` and `Sources/GrAIdient/LayerSeq/VQSeq.swift` as WHOLE FILES: this scan already matched 30 separate duplicated blocks between them, totalling at least 378 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/GrAIdient/Layer2D/VQ2D.swift:479` 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 · Duplicated block (13 lines × 6) · ×3
  • Duplicated block (13 lines × 6) Sources/GrAIdient/Layer1D/BCE1D.swift:384 — Sources/GrAIdient/Layer1D/BCE1D.swift:384-396 | Sources/GrAIdient/Layer1D/BCESigmoid1D.swift:403-415 | Sources/GrAIdient/Layer1D/MSE1D.swift:367-379 | Sources/GrAIdient/Layer2D/BCE2D.swift:509-521 | Sources/GrAIdient/Layer2D/BCESigmoid2D.swift:544-556 | Sources/GrAIdient/Layer2D/MSE2D.swift:479-491 — before extracting anything, compare `Sources/GrAIdient/Layer1D/BCE1D.swift` and `Sources/GrAIdient/Layer1D/BCESigmoid1D.swift` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 218 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (13 lines × 6) Sources/GrAIdient/Layer1D/Constant1D.swift:488 — Sources/GrAIdient/Layer1D/Constant1D.swift:488-500 | Sources/GrAIdient/Layer2D/Constant2D.swift:561-573 | Sources/GrAIdient/Layer2D/VQ2D.swift:762-774 | Sources/GrAIdient/LayerSeq/ConstantSeq.swift:996-1008 | Sources/GrAIdient/LayerSeq/EmbeddingSeq.swift:733-745 | Sources/GrAIdient/LayerSeq/VQSeq.swift:685-697 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Constant1D.swift` and `Sources/GrAIdient/Layer2D/Constant2D.swift` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 131 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/GrAIdient/Layer1D/Constant1D.swift:488` it begins part-way through the construct above it, so those exact lines 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 × 6) Sources/GrAIdient/Layer2D/Activation2D.swift:228 — Sources/GrAIdient/Layer2D/Activation2D.swift:228-240 | Sources/GrAIdient/Layer2D/BN2D.swift:565-577 | Sources/GrAIdient/Layer2D/InstanceNorm2D.swift:489-501 | Sources/GrAIdient/Layer2D/Transform/IRDFT2RGB.swift:153-165 | Sources/GrAIdient/Layer2D/Transform/LinearScale2D.swift:168-180 | Sources/GrAIdient/Layer2D/Transform/Pad2D.swift:187-199 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Activation2D.swift` and `Sources/GrAIdient/Layer2D/BN2D.swift` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 171 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/GrAIdient/Layer2D/Activation2D.swift:228` 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.
D4 · Code Duplication · Duplicated block (12–13 lines × 4) · ×3
  • Duplicated block (12–13 lines × 4) Sources/GrAIdient/Layer1D/Activation1D.swift:182 — Sources/GrAIdient/Layer1D/Activation1D.swift:182-194 | Sources/GrAIdient/Layer1D/Base/LayerOutput1D.swift:234-245 | Sources/GrAIdient/Layer1D/SelectNeurons1D.swift:177-189 | Sources/GrAIdient/Layer2D/SelectNeurons2D.swift:195-207 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Activation1D.swift` and `Sources/GrAIdient/Layer1D/Base/LayerOutput1D.swift` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 130 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/GrAIdient/Layer1D/Activation1D.swift:182` 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 × 4) Sources/GrAIdient/Layer2D/Activation2D.swift:285 — Sources/GrAIdient/Layer2D/Activation2D.swift:285-297 | Sources/GrAIdient/Layer2D/BN2D.swift:625-637 | Sources/GrAIdient/Layer2D/InstanceNorm2D.swift:549-561 | Sources/GrAIdient/Layer2D/Transform/LinearScale2D.swift:226-237 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Activation2D.swift` and `Sources/GrAIdient/Layer2D/BN2D.swift` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 171 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/GrAIdient/Layer2D/Activation2D.swift:285` 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/GrAIdient/Layer2D/Activation2D.swift:283` calls `backwardCPU` and `Sources/GrAIdient/Layer2D/Transform/LinearScale2D.swift:225` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (12–13 lines × 4) Sources/GrAIdient/LayerSeq/QuerySeq.swift:405 — Sources/GrAIdient/LayerSeq/QuerySeq.swift:405-416 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:436-447 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:850-862 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:884-896 — 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/GrAIdient/LayerSeq/QuerySeq.swift:405` 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.
D4 · Code Duplication · Duplicated block (13 lines × 3) · ×3
  • Duplicated block (13 lines × 3) Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:300 — Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:300-312 | Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:372-384 | Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:455-467 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:387` calls `setBuffer` and `Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:316` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (13 lines × 3) Sources/GrAIdient/Layer2D/Convolution2D.swift:897 — Sources/GrAIdient/Layer2D/Convolution2D.swift:897-909 | Sources/GrAIdient/Layer2D/Deconvolution2D.swift:328-340 | Sources/GrAIdient/Layer2D/Deconvolution2D.swift:544-556 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Convolution2D.swift` and `Sources/GrAIdient/Layer2D/Deconvolution2D.swift` as WHOLE FILES: this scan already matched 26 separate duplicated blocks between them, totalling at least 499 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/GrAIdient/Layer2D/Convolution2D.swift:897` 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/GrAIdient/Layer2D/Deconvolution2D.swift:540` calls `download` and `Sources/GrAIdient/Layer2D/Convolution2D.swift:893` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (13 lines × 3) Sources/GrAIdient/LayerSeq/QuerySeq.swift:473 — Sources/GrAIdient/LayerSeq/QuerySeq.swift:473-485 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:473-485 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1059-1071 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/QuerySeq.swift` and `Sources/GrAIdient/LayerSeq/ValueSeq.swift` as WHOLE FILES: this scan already matched 39 separate duplicated blocks between them, totalling at least 427 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/GrAIdient/LayerSeq/QuerySeq.swift:473` 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.
D4 · Code Duplication · Duplicated block (11–12 lines × 2) · ×3
  • Duplicated block (11–12 lines × 2) Sources/GrAIdient/Core/Layer/LayerNormalization.swift:473 — Sources/GrAIdient/Core/Layer/LayerNormalization.swift:473-483 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1264-1275 — both copies are in the same file, so extract the 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/GrAIdient/Core/Layer/LayerNormalization.swift:473` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (11–12 lines × 2) Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1015 — Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1015-1025 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1905-1916 — both copies are in the same file, so extract the 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/GrAIdient/Core/Layer/LayerNormalization.swift:1015` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (11–12 lines × 2) Sources/GrAIdient/LayerSeq/ValueSeq.swift:1418 — Sources/GrAIdient/LayerSeq/ValueSeq.swift:1418-1428 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1610-1621 — both copies are in the same file, so extract the 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/GrAIdient/LayerSeq/ValueSeq.swift:1418` 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.
D4 · Code Duplication · Duplicated block (7 lines × 9) · ×3
  • Duplicated block (7 lines × 9) Sources/GrAIdient/Core/Layer/LayerNormalization.swift:925 — Sources/GrAIdient/Core/Layer/LayerNormalization.swift:925-931 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1015-1021 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1054-1060 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1619-1625 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1663-1669 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1836-1842 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1871-1877 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1905-1911 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1947-1953 — all 9 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
  • Duplicated block (7 lines × 9) Sources/GrAIdient/Layer1D/Constant1D.swift:494 — Sources/GrAIdient/Layer1D/Constant1D.swift:494-500 | Sources/GrAIdient/Layer1D/FullyConnected.swift:1154-1160 | Sources/GrAIdient/Layer2D/Constant2D.swift:567-573 | Sources/GrAIdient/Layer2D/VQ2D.swift:768-774 | Sources/GrAIdient/LayerSeq/ConstantSeq.swift:1002-1008 | Sources/GrAIdient/LayerSeq/EmbeddingSeq.swift:739-745 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:1231-1237 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:1116-1122 | Sources/GrAIdient/LayerSeq/VQSeq.swift:691-697 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Constant1D.swift` and `Sources/GrAIdient/Layer1D/FullyConnected.swift` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 51 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:1239` calls `setBytes` and `Sources/GrAIdient/Layer1D/FullyConnected.swift:1162` 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 (7 lines × 9) Sources/GrAIdient/Layer2D/Normalize2D.swift:278 — Sources/GrAIdient/Layer2D/Normalize2D.swift:278-284 | Sources/GrAIdient/Layer2D/Normalize2D.swift:750-756 | Sources/GrAIdient/Layer2D/Transform/Crop2D.swift:370-376 | Sources/GrAIdient/Layer2D/Transform/DecorrelateRGB.swift:288-294 | Sources/GrAIdient/Layer2D/Transform/Flip2D.swift:300-306 | Sources/GrAIdient/Layer2D/Transform/IRDFT2RGB.swift:275-281 | Sources/GrAIdient/Layer2D/Transform/LinearScale2D.swift:260-266 | Sources/GrAIdient/Layer2D/Transform/Pad2D.swift:293-299 | Sources/GrAIdient/Layer2D/VQ2D.swift:645-651 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Normalize2D.swift` and `Sources/GrAIdient/Layer2D/Transform/Crop2D.swift` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 109 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/GrAIdient/Layer2D/Normalize2D.swift:278` 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/GrAIdient/Layer2D/Transform/Crop2D.swift:377` calls `UInt32` and `Sources/GrAIdient/Layer2D/Normalize2D.swift:285` 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.
D4 · Code Duplication · Duplicated block (7 lines × 5) · ×3
  • Duplicated block (7 lines × 5) Sources/GrAIdient/Core/Layer/LayerNormalization.swift:948 — Sources/GrAIdient/Core/Layer/LayerNormalization.swift:948-954 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1642-1648 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1686-1692 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:2503-2509 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:3113-3119 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/Core/Layer/LayerNormalization.swift:948` 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 × 5) Sources/GrAIdient/Layer1D/Concat1D.swift:371 — Sources/GrAIdient/Layer1D/Concat1D.swift:371-377 | Sources/GrAIdient/Layer2D/Concat2D.swift:415-421 | Sources/GrAIdient/Layer2D/SimilarityError2D.swift:495-501 | Sources/GrAIdient/Layer2D/SimilarityError2D.swift:735-741 | Sources/GrAIdient/LayerSeq/ConcatSeq.swift:834-840 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Concat1D.swift` and `Sources/GrAIdient/Layer2D/Concat2D.swift` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 87 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (7 lines × 5) Sources/GrAIdient/LayerSeq/ConcatSeq.swift:417 — Sources/GrAIdient/LayerSeq/ConcatSeq.swift:417-423 | Sources/GrAIdient/LayerSeq/ConstantSeq.swift:458-464 | Sources/GrAIdient/LayerSeq/ConstantSeq.swift:967-973 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:1173-1179 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:1060-1066 — there are 5 copies across 4 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 5 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/LayerSeq/ConcatSeq.swift:417` 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/GrAIdient/LayerSeq/ConcatSeq.swift:424` calls `setBytes` and `Sources/GrAIdient/LayerSeq/ConstantSeq.swift:465` 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.
D15 · Churn × Complexity Hotspots · Hotspot · ×2
  • Hotspot: Sources/GrAIdient/LayerSeq/QuerySeq.swift Sources/GrAIdient/LayerSeq/QuerySeq.swift:1350 — Sources/GrAIdient/LayerSeq/QuerySeq.swift changed 4 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 20 in QueryCausalSeq.forwardGCCPU at line 1350. 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 2024-06-03..2024-09-01, the 90 days ending at the analysed commit. Reproduce with `git log --since='2024-06-03 23:32:52 +02:00' --until='2024-09-01 23:32:52 +02:00' --full-history --no-merges -- Sources/GrAIdient/LayerSeq/QuerySeq.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/GrAIdient/LayerSeq/ValueSeq.swift Sources/GrAIdient/LayerSeq/ValueSeq.swift:1400 — Sources/GrAIdient/LayerSeq/ValueSeq.swift changed 3 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 18 in ValueCausalSeq.forwardGCCPU at line 1400. 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 2024-06-03..2024-09-01, the 90 days ending at the analysed commit. Reproduce with `git log --since='2024-06-03 23:32:52 +02:00' --until='2024-09-01 23:32:52 +02:00' --full-history --no-merges -- Sources/GrAIdient/LayerSeq/ValueSeq.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.
D29 · Static Analysis (SAST) · REDACTED
  • REDACTED
  • REDACTED
D4 · Code Duplication · Near-duplicate member family (4 members, 21 shared lines) · ×2
  • Near-duplicate member family (4 members, 21 shared lines) Sources/GrAIdient/Layer1D/Concat1D.swift:344 — Sources/GrAIdient/Layer1D/Concat1D.swift:344-395 | Sources/GrAIdient/Layer2D/Concat2D.swift:387-440 | Sources/GrAIdient/LayerSeq/ConcatSeq.swift:379-437 | Sources/GrAIdient/LayerSeq/ConcatSeq.swift:806-859 — These 4 members are variants of one another: a block of 21 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 family (4 members, 21 shared lines) Sources/GrAIdient/Layer2D/Constant2D.swift:516 — Sources/GrAIdient/Layer2D/Constant2D.swift:516-580 | Sources/GrAIdient/LayerSeq/ConstantSeq.swift:948-1015 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:1128-1264 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:1018-1148 — These 4 members are variants of one another: a block of 21 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
D4 · Code Duplication · Members sharing a duplicated core (13 members, 50+ identical tokens) · ×2
  • Members sharing a duplicated core (13 members, 50+ identical tokens) Sources/GrAIdient/Layer1D/Activation1D.swift:244 — Sources/GrAIdient/Layer1D/Activation1D.swift:244-267 | Sources/GrAIdient/Layer1D/Base/LayerOutput1D.swift:288-309 | Sources/GrAIdient/Layer1D/Input1D.swift:342-363 | Sources/GrAIdient/Layer2D/Activation2D.swift:255-278 | Sources/GrAIdient/Layer2D/BN2D.swift:593-617 | Sources/GrAIdient/Layer2D/Base/LayerOutput2D.swift:344-365 | Sources/GrAIdient/Layer2D/Input2D.swift:444-465 | Sources/GrAIdient/Layer2D/InstanceNorm2D.swift:517-541 | Sources/GrAIdient/LayerSeq/ActivationSeq.swift:253-276 | Sources/GrAIdient/LayerSeq/LayerNormSeq.swift:513-537 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:1327-1343 | Sources/GrAIdient/LayerSeq/RMSNormSeq.swift:527-551 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1377-1393 — These 13 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 13 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 13 times.
  • Members sharing a duplicated core (13 members, 50+ identical tokens) Sources/GrAIdient/LayerSeq/ActivationSeq.swift:137 — Sources/GrAIdient/LayerSeq/ActivationSeq.swift:137-153 | Sources/GrAIdient/LayerSeq/AvgPoolSeq.swift:54-66 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:238-274 | Sources/GrAIdient/LayerSeq/LayerCAMSeq.swift:86-101 | Sources/GrAIdient/LayerSeq/LayerNormSeq.swift:163-196 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:671-690 | Sources/GrAIdient/LayerSeq/RMSNormSeq.swift:174-208 | Sources/GrAIdient/LayerSeq/RoPESeq.swift:134-151 | Sources/GrAIdient/LayerSeq/SelectSeq.swift:86-102 | Sources/GrAIdient/LayerSeq/SoftmaxSeq.swift:98-114 | Sources/GrAIdient/LayerSeq/SoftmaxSeq.swift:447-467 | Sources/GrAIdient/LayerSeq/VQSeq.swift:202-235 | Sources/GrAIdient/LayerSeq/VQSeq.swift:994-1028 — These 13 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 13 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 13 times.
D4 · Code Duplication · Edited copy of a member (65 corresponding lines) · ×2
  • Edited copy of a member (65 corresponding lines) Sources/GrAIdient/Core/Layer/LayerNormalization.swift:445 — Sources/GrAIdient/Core/Layer/LayerNormalization.swift:445-509 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1231-1308 — These two members are one piece of code written twice and then edited apart: 65 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 (65 corresponding lines) Sources/GrAIdient/Layer2D/Multiply2D.swift:393 — Sources/GrAIdient/Layer2D/Multiply2D.swift:393-457 | Sources/GrAIdient/LayerSeq/MutiplySeq.swift:358-422 — These two members are one piece of code written twice and then edited apart: 65 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 (54 corresponding lines) · ×2
  • Edited copy of a member (54 corresponding lines) Sources/GrAIdient/Layer2D/Transform/Rotate2D.swift:214 — Sources/GrAIdient/Layer2D/Transform/Rotate2D.swift:214-267 | Sources/GrAIdient/Layer2D/Transform/Rotate2D.swift:284-339 — These two members are one piece of code written twice and then edited apart: 54 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 (54 corresponding lines) Sources/GrAITestsUtils/FlowChecking.swift:19 — Sources/GrAITestsUtils/FlowChecking.swift:19-72 | Sources/GrAITestsUtils/GradientChecking.swift:20-76 — These two members are one piece of code written twice and then edited apart: 54 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, 42+ corresponding lines) · ×2
  • Edited copies of one member (3 members, 42+ corresponding lines) Sources/GrAIdient/Layer2D/BCE2D.swift:492 — Sources/GrAIdient/Layer2D/BCE2D.swift:492-533 | Sources/GrAIdient/Layer2D/BCESigmoid2D.swift:527-568 | Sources/GrAIdient/Layer2D/MSE2D.swift:462-503 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 42 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, 42+ corresponding lines) Sources/GrAIdient/Layer1D/Softmax1D.swift:119 — Sources/GrAIdient/Layer1D/Softmax1D.swift:119-169 | Sources/GrAIdient/LayerSeq/SoftmaxSeq.swift:121-175 | Sources/GrAIdient/LayerSeq/SoftmaxSeq.swift:192-233 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 42 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 (38 corresponding lines) · ×2
  • Edited copy of a member (38 corresponding lines) Sources/GrAIdient/Layer2D/MaxPool2D.swift:355 — Sources/GrAIdient/Layer2D/MaxPool2D.swift:355-392 | Sources/GrAIdient/Layer2D/MaxPool2D.swift:445-486 — These two members are one piece of code written twice and then edited apart: 38 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (38 corresponding lines) Sources/GrAIdient/Layer2D/Convolution2D.swift:1275 — Sources/GrAIdient/Layer2D/Convolution2D.swift:1275-1312 | Sources/GrAIdient/Layer2D/Deconvolution2D.swift:722-764 — These two members are one piece of code written twice and then edited apart: 38 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (46 corresponding lines) · ×2
  • Edited copy of a member (46 corresponding lines) Sources/GrAIdient/LayerSeq/LayerNormSeq.swift:434 — Sources/GrAIdient/LayerSeq/LayerNormSeq.swift:434-479 | Sources/GrAIdient/LayerSeq/RMSNormSeq.swift:448-493 — These two members are one piece of code written twice and then edited apart: 46 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 (46 corresponding lines) Sources/GrAIdient/Core/Layer/LayerNormalization.swift:2270 — Sources/GrAIdient/Core/Layer/LayerNormalization.swift:2270-2318 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:2910-2955 — These two members are one piece of code written twice and then edited apart: 46 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, 40+ corresponding lines) · ×2
  • Edited copies of one member (3 members, 40+ corresponding lines) Sources/GrAIdient/Layer1D/BCE1D.swift:368 — Sources/GrAIdient/Layer1D/BCE1D.swift:368-407 | Sources/GrAIdient/Layer1D/BCESigmoid1D.swift:387-426 | Sources/GrAIdient/Layer1D/MSE1D.swift:351-390 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 40 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, 40+ corresponding lines) Sources/GrAIdient/Metal/MetalBuffer.swift:31 — Sources/GrAIdient/Metal/MetalBuffer.swift:31-70 | Sources/GrAIdient/Metal/MetalBuffer.swift:102-146 | Sources/GrAIdient/Metal/MetalBuffer.swift:218-258 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 40 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 (4 members, 36+ corresponding lines) · ×2
  • Edited copies of one member (4 members, 36+ corresponding lines) Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:1089 — Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:1089-1126 | Sources/GrAIdient/LayerSeq/RoPESeq.swift:437-472 | Sources/GrAIdient/LayerSeq/SoftmaxSeq.swift:321-356 | Sources/GrAIdient/LayerSeq/VQSeq.swift:566-602 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 36 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.
  • Edited copies of one member (4 members, 36+ corresponding lines) Sources/GrAIdient/Layer1D/Constant1D.swift:333 — Sources/GrAIdient/Layer1D/Constant1D.swift:333-368 | Sources/GrAIdient/Layer2D/Constant2D.swift:351-388 | Sources/GrAIdient/Layer2D/Constant2D.swift:395-434 | Sources/GrAIdient/LayerSeq/ConstantSeq.swift:780-817 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 36 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 (36 corresponding lines) · ×2
  • Edited copy of a member (36 corresponding lines) Sources/GrAIdient/Core/Layer/LayerNormalization.swift:2473 — Sources/GrAIdient/Core/Layer/LayerNormalization.swift:2473-2514 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:2618-2653 — These two members are one piece of code written twice and then edited apart: 36 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (36 corresponding lines) Sources/GrAIdient/Layer2D/VQ2D.swift:593 — Sources/GrAIdient/Layer2D/VQ2D.swift:593-630 | Sources/GrAIdient/LayerSeq/VQSeq.swift:518-553 — These two members are one piece of code written twice and then edited apart: 36 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 35+ corresponding lines) · ×2
  • Edited copies of one member (3 members, 35+ corresponding lines) Sources/GrAIdient/Layer1D/BCE1D.swift:209 — Sources/GrAIdient/Layer1D/BCE1D.swift:209-243 | Sources/GrAIdient/Layer1D/BCESigmoid1D.swift:232-266 | Sources/GrAIdient/Layer1D/MSE1D.swift:205-239 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 35 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, 35+ corresponding lines) Sources/GrAIdient/Layer1D/Sum1D.swift:252 — Sources/GrAIdient/Layer1D/Sum1D.swift:252-286 | Sources/GrAIdient/Layer2D/Sum2D.swift:297-331 | Sources/GrAIdient/LayerSeq/SumSeq.swift:263-297 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 35 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 (4 members, 30+ corresponding lines) · ×2
  • Edited copies of one member (4 members, 30+ corresponding lines) Sources/GrAIdient/Layer1D/FullyConnected.swift:1027 — Sources/GrAIdient/Layer1D/FullyConnected.swift:1027-1064 | Sources/GrAIdient/Layer1D/LinearError1D.swift:289-318 | Sources/GrAIdient/Layer1D/Softmax1D.swift:303-333 | Sources/GrAIdient/Layer2D/SimilarityBatchError2D.swift:325-356 — These 4 members are one piece of code written 4 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 4 times and the copies will drift further apart.
  • Edited copies of one member (4 members, 30+ corresponding lines) Sources/GrAIdient/Layer1D/Constant1D.swift:159 — Sources/GrAIdient/Layer1D/Constant1D.swift:159-188 | Sources/GrAIdient/LayerSeq/ConstantSeq.swift:160-190 | Sources/GrAIdient/LayerSeq/ConstantSeq.swift:645-675 | Sources/GrAIdient/LayerSeq/EmbeddingSeq.swift:194-231 — These 4 members are one piece of code written 4 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 4 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 41+ corresponding lines) · ×2
  • Edited copies of one member (3 members, 41+ corresponding lines) Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:54 — Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:54-98 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:110-150 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift:77-120 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 41 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, 41+ corresponding lines) Sources/GrAIdient/Layer1D/Concat1D.swift:297 — Sources/GrAIdient/Layer1D/Concat1D.swift:297-337 | Sources/GrAIdient/LayerSeq/ConcatSeq.swift:330-372 | Sources/GrAIdient/LayerSeq/ConcatSeq.swift:757-799 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 41 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, 27+ corresponding lines) · ×2
  • Edited copies of one member (3 members, 27+ corresponding lines) Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:333 — Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:333-359 | Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:544-576 | Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:626-660 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 27 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, 27+ corresponding lines) Sources/GrAIdient/LayerSeq/ActivationSeq.swift:279 — Sources/GrAIdient/LayerSeq/ActivationSeq.swift:279-305 | Sources/GrAIdient/LayerSeq/LayerNormSeq.swift:540-567 | Sources/GrAIdient/LayerSeq/RMSNormSeq.swift:554-581 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 27 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 (27 corresponding lines) · ×2
  • Edited copy of a member (27 corresponding lines) Sources/GrAIdient/Layer2D/AvgPool2D.swift:73 — Sources/GrAIdient/Layer2D/AvgPool2D.swift:73-108 | Sources/GrAIdient/Layer2D/AvgPool2D.swift:125-151 — 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.
  • Edited copy of a member (27 corresponding lines) Sources/GrAITestsUtils/Trainer.swift:275 — Sources/GrAITestsUtils/Trainer.swift:275-301 | Sources/GrAITestsUtils/Trainer.swift:418-444 — 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 (25 corresponding lines) · ×2
  • Edited copy of a member (25 corresponding lines) Sources/GrAIdient/Layer1D/SelectNeurons1D.swift:268 — Sources/GrAIdient/Layer1D/SelectNeurons1D.swift:268-292 | Sources/GrAIdient/LayerSeq/SelectSeq.swift:203-231 — 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.
  • Edited copy of a member (25 corresponding lines) Sources/GrAIdient/Core/Optimizer/OptimizerAlgorithm.swift:291 — Sources/GrAIdient/Core/Optimizer/OptimizerAlgorithm.swift:291-316 | Sources/GrAIdient/Core/Optimizer/OptimizerAlgorithm.swift:357-381 — 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, 20+ corresponding lines) · ×2
  • Edited copies of one member (3 members, 20+ corresponding lines) Sources/GrAIdient/LayerSeq/ActivationSeq.swift:227 — Sources/GrAIdient/LayerSeq/ActivationSeq.swift:227-246 | Sources/GrAIdient/LayerSeq/LayerNormSeq.swift:486-506 | Sources/GrAIdient/LayerSeq/RMSNormSeq.swift:500-520 — 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.
  • Edited copies of one member (3 members, 20+ corresponding lines) Sources/GrAIdient/Core/Optimizer/OptimizerAlgorithm.swift:189 — Sources/GrAIdient/Core/Optimizer/OptimizerAlgorithm.swift:189-208 | Sources/GrAIdient/Core/Optimizer/OptimizerAlgorithm.swift:260-281 | Sources/GrAIdient/Core/Optimizer/OptimizerAlgorithm.swift:326-347 — 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 (9 corresponding lines) · ×2
  • Edited copy of a member (9 corresponding lines) Sources/GrAIdient/LayerSeq/QuerySeq.swift:1117 — Sources/GrAIdient/LayerSeq/QuerySeq.swift:1117-1125 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1243-1251 — These two members are one piece of code written twice and then edited apart: 9 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 (9 corresponding lines) Sources/GrAIdient/LayerSeq/SelectSeq.swift:31 — Sources/GrAIdient/LayerSeq/SelectSeq.swift:31-39 | Sources/GrAIdient/LayerSeq/VQSeq.swift:124-133 — These two members are one piece of code written twice and then edited apart: 9 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) · ×2
  • Edited copies of one member (3 members, 18+ corresponding lines) Sources/GrAIdient/Core/Function/Activation.swift:408 — Sources/GrAIdient/Core/Function/Activation.swift:408-425 | Sources/GrAIdient/Utils/Buffer.swift:122-139 | Sources/GrAIdient/Utils/Buffer.swift:150-167 — 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.
  • Edited copies of one member (3 members, 18+ corresponding lines) Sources/GrAIdient/Layer2D/BN2D.swift:371 — Sources/GrAIdient/Layer2D/BN2D.swift:371-389 | Sources/GrAIdient/LayerSeq/LayerNormSeq.swift:295-312 | Sources/GrAIdient/LayerSeq/RMSNormSeq.swift:309-326 — 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 (14 corresponding lines) · ×2
  • Edited copy of a member (14 corresponding lines) Sources/GrAIdient/Layer2D/BN2D.swift:717 — Sources/GrAIdient/Layer2D/BN2D.swift:717-733 | Sources/GrAIdient/Layer2D/BN2D.swift:743-756 — 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/GrAIdient/Layer2D/Transform/FTFrequences2D.swift:69 — Sources/GrAIdient/Layer2D/Transform/FTFrequences2D.swift:69-82 | Sources/GrAIdient/Layer2D/Transform/FTFrequences2D.swift:98-118 — These two members are one piece of code written twice and then edited apart: 14 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copies of one member (4 members, 19+ corresponding lines) · ×2
  • Edited copies of one member (4 members, 19+ corresponding lines) Sources/GrAIdient/Layer2D/BN2D.swift:325 — Sources/GrAIdient/Layer2D/BN2D.swift:325-343 | Sources/GrAIdient/Layer2D/InstanceNorm2D.swift:250-268 | Sources/GrAIdient/LayerSeq/LayerNormSeq.swift:249-267 | Sources/GrAIdient/LayerSeq/RMSNormSeq.swift:262-281 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 19 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.
  • Edited copies of one member (4 members, 19+ corresponding lines) Sources/GrAIdient/Layer1D/FullyConnected.swift:603 — Sources/GrAIdient/Layer1D/FullyConnected.swift:603-621 | Sources/GrAIdient/Layer2D/Convolution2D.swift:809-828 | Sources/GrAIdient/Layer2D/VQ2D.swift:349-368 | Sources/GrAIdient/LayerSeq/VQSeq.swift:339-358 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 19 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 copies of one member (3 members, 15+ corresponding lines) · ×2
  • Edited copies of one member (3 members, 15+ corresponding lines) Sources/GrAIdient/Layer1D/Activation1D.swift:66 — Sources/GrAIdient/Layer1D/Activation1D.swift:66-80 | Sources/GrAIdient/Layer2D/Activation2D.swift:69-87 | Sources/GrAIdient/LayerSeq/ActivationSeq.swift:67-84 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 15 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, 15+ corresponding lines) Sources/GrAIdient/Layer1D/Base/LayerMerge1D.swift:44 — Sources/GrAIdient/Layer1D/Base/LayerMerge1D.swift:44-58 | Sources/GrAIdient/Layer2D/Base/LayerMerge2D.swift:100-116 | Sources/GrAIdient/LayerSeq/Base/LayerMergeSeq.swift:45-61 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 15 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 (5 members, 11+ corresponding lines) · ×2
  • Edited copies of one member (5 members, 11+ corresponding lines) Sources/GrAIdient/Core/State/Weights.swift:219 — Sources/GrAIdient/Core/State/Weights.swift:219-229 | Sources/GrAIdient/Core/State/Weights.swift:258-268 | Sources/GrAIdient/Core/State/Weights.swift:297-307 | Sources/GrAIdient/Core/State/Weights.swift:336-346 | Sources/GrAIdient/Core/State/Weights.swift:375-385 — These 5 members are one piece of code written 5 times and then edited apart: every two of them correspond over at least 11 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 5 times and the copies will drift further apart.
  • Edited copies of one member (5 members, 11+ corresponding lines) Sources/GrAIdient/Core/State/Weights.swift:200 — Sources/GrAIdient/Core/State/Weights.swift:200-210 | Sources/GrAIdient/Core/State/Weights.swift:239-249 | Sources/GrAIdient/Core/State/Weights.swift:278-288 | Sources/GrAIdient/Core/State/Weights.swift:317-327 | Sources/GrAIdient/Core/State/Weights.swift:356-366 — These 5 members are one piece of code written 5 times and then edited apart: every two of them correspond over at least 11 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 5 times and the copies will drift further apart.
D4 · Code Duplication · Edited copy of a member (19 corresponding lines) · ×2
  • Edited copy of a member (19 corresponding lines) Sources/GrAIdient/Layer2D/VQ2D.swift:861 — Sources/GrAIdient/Layer2D/VQ2D.swift:861-880 | Sources/GrAIdient/LayerSeq/VQSeq.swift:782-800 — 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.
  • Edited copy of a member (19 corresponding lines) Sources/GrAIdient/Core/Layer/LayerNormalization.swift:2770 — Sources/GrAIdient/Core/Layer/LayerNormalization.swift:2770-2788 | Sources/GrAIdient/Layer2D/Constant2D.swift:281-300 — 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 (3 members, 19+ corresponding lines) · ×2
  • Edited copies of one member (3 members, 19+ corresponding lines) Sources/GrAIdient/Layer2D/BN2D.swift:396 — Sources/GrAIdient/Layer2D/BN2D.swift:396-414 | Sources/GrAIdient/LayerSeq/LayerNormSeq.swift:319-337 | Sources/GrAIdient/LayerSeq/RMSNormSeq.swift:333-351 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 19 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, 19+ corresponding lines) Sources/GrAIdient/Layer2D/VQ2D.swift:305 — Sources/GrAIdient/Layer2D/VQ2D.swift:305-323 | Sources/GrAIdient/LayerSeq/EmbeddingSeq.swift:291-309 | Sources/GrAIdient/LayerSeq/VQSeq.swift:295-313 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 19 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, 13+ corresponding lines) · ×2
  • Edited copies of one member (3 members, 13+ corresponding lines) Sources/GrAIdient/Layer1D/Base/Layer1D.swift:137 — Sources/GrAIdient/Layer1D/Base/Layer1D.swift:137-149 | Sources/GrAIdient/Layer2D/Base/Layer2D.swift:216-230 | Sources/GrAIdient/LayerSeq/Base/LayerSeq.swift:147-160 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 13 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, 13+ corresponding lines) Sources/GrAIdient/Layer1D/Base/LayerOutput1D.swift:211 — Sources/GrAIdient/Layer1D/Base/LayerOutput1D.swift:211-223 | Sources/GrAIdient/Layer2D/SimilarityBatchError2D.swift:143-157 | Sources/GrAIdient/Layer2D/SimilarityError2D.swift:150-164 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 13 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 · Duplicated block (41 lines × 2) · ×2
  • Duplicated block (41 lines × 2) Sources/GrAIdient/Layer2D/Convolution2D.swift:548 — Sources/GrAIdient/Layer2D/Convolution2D.swift:548-588 | Sources/GrAIdient/Layer2D/Deconvolution2D.swift:144-184 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Convolution2D.swift` and `Sources/GrAIdient/Layer2D/Deconvolution2D.swift` as WHOLE FILES: this scan already matched 26 separate duplicated blocks between them, totalling at least 499 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/GrAIdient/Layer2D/Convolution2D.swift:548` 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 (41 lines × 2) Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:417 — Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:417-457 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:530-570 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:414` calls `Double` and `Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:528` 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.
D4 · Code Duplication · Duplicated block (38 lines × 2) · ×2
  • Duplicated block (38 lines × 2) Sources/GrAIdient/Layer2D/Concat2D.swift:84 — Sources/GrAIdient/Layer2D/Concat2D.swift:84-121 | Sources/GrAIdient/Layer2D/Concat2D.swift:177-214 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (38 lines × 2) Sources/GrAIdient/Layer2D/SimilarityError2D.swift:175 — Sources/GrAIdient/Layer2D/SimilarityError2D.swift:175-212 | Sources/GrAIdient/Layer2D/SimilarityError2D.swift:265-302 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (32 lines × 2) · ×2
  • Duplicated block (32 lines × 2) Sources/GrAIdient/Layer1D/Concat1D.swift:74 — Sources/GrAIdient/Layer1D/Concat1D.swift:74-105 | Sources/GrAIdient/Layer1D/Concat1D.swift:155-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. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/Layer1D/Concat1D.swift:74` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (32 lines × 2) Sources/GrAIdient/Layer2D/Convolution2D.swift:1163 — Sources/GrAIdient/Layer2D/Convolution2D.swift:1163-1194 | Sources/GrAIdient/Layer2D/Deconvolution2D.swift:610-641 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Convolution2D.swift` and `Sources/GrAIdient/Layer2D/Deconvolution2D.swift` as WHOLE FILES: this scan already matched 26 separate duplicated blocks between them, totalling at least 499 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/GrAIdient/Layer2D/Convolution2D.swift:1163` 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.
D4 · Code Duplication · Duplicated block (43 lines × 2) · ×2
  • Duplicated block (43 lines × 2) Sources/GrAIdient/LayerSeq/ConcatSeq.swift:86 — Sources/GrAIdient/LayerSeq/ConcatSeq.swift:86-128 | Sources/GrAIdient/LayerSeq/ConcatSeq.swift:173-215 — both copies are in the same file, so extract the 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/GrAIdient/LayerSeq/ConcatSeq.swift:86` 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 (43 lines × 2) Sources/GrAIdient/LayerSeq/ConcatSeq.swift:518 — Sources/GrAIdient/LayerSeq/ConcatSeq.swift:518-560 | Sources/GrAIdient/LayerSeq/ConcatSeq.swift:605-647 — both copies are in the same file, so extract the 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/GrAIdient/LayerSeq/ConcatSeq.swift:518` 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.
D4 · Code Duplication · Duplicated block (31 lines × 2) · ×2
  • Duplicated block (31 lines × 2) Sources/GrAIdient/Layer1D/Dropout1D.swift:171 — Sources/GrAIdient/Layer1D/Dropout1D.swift:171-201 | Sources/GrAIdient/Layer1D/Dropout1D.swift:217-247 — both copies are in the same file, so extract the 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/GrAIdient/Layer1D/Dropout1D.swift:171` 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 (31 lines × 2) Sources/GrAIdient/Layer2D/Convolution2D.swift:609 — Sources/GrAIdient/Layer2D/Convolution2D.swift:609-639 | Sources/GrAIdient/Layer2D/Deconvolution2D.swift:205-235 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Convolution2D.swift` and `Sources/GrAIdient/Layer2D/Deconvolution2D.swift` as WHOLE FILES: this scan already matched 26 separate duplicated blocks between them, totalling at least 499 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/GrAIdient/Layer2D/Convolution2D.swift:609` 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.
D4 · Code Duplication · Duplicated block (30 lines × 2) · ×2
  • Duplicated block (30 lines × 2) Sources/GrAIdient/Layer2D/BN2D.swift:529 — Sources/GrAIdient/Layer2D/BN2D.swift:529-558 | Sources/GrAIdient/Layer2D/InstanceNorm2D.swift:453-482 — before extracting anything, compare `Sources/GrAIdient/Layer2D/BN2D.swift` and `Sources/GrAIdient/Layer2D/InstanceNorm2D.swift` as WHOLE FILES: this scan already matched 21 separate duplicated blocks between them, totalling at least 320 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/GrAIdient/Layer2D/BN2D.swift:529` 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 (30 lines × 2) Sources/GrAIdient/Layer2D/Convolution2D.swift:946 — Sources/GrAIdient/Layer2D/Convolution2D.swift:946-975 | Sources/GrAIdient/Layer2D/Deconvolution2D.swift:383-412 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Convolution2D.swift` and `Sources/GrAIdient/Layer2D/Deconvolution2D.swift` as WHOLE FILES: this scan already matched 26 separate duplicated blocks between them, totalling at least 499 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/GrAIdient/Layer2D/Convolution2D.swift:946` 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.
D4 · Code Duplication · Duplicated block (29 lines × 2) · ×2
  • Duplicated block (29 lines × 2) Sources/GrAIdient/Layer1D/FullyConnected.swift:368 — Sources/GrAIdient/Layer1D/FullyConnected.swift:368-396 | Sources/GrAIdient/Layer1D/FullyConnected.swift:420-448 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/Layer1D/FullyConnected.swift:368` 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 (29 lines × 2) Sources/GrAIdient/Layer2D/BCE2D.swift:360 — Sources/GrAIdient/Layer2D/BCE2D.swift:360-388 | Sources/GrAIdient/Layer2D/BCE2D.swift:402-430 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/Layer2D/BCE2D.swift:360` 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.
D4 · Code Duplication · Duplicated block (26 lines × 2) · ×2
  • Duplicated block (26 lines × 2) Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1704 — Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1704-1729 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1737-1762 — both copies are in the same file, so extract the 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/GrAIdient/Core/Layer/LayerNormalization.swift:1704` 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 (26 lines × 2) Sources/GrAIdient/Layer2D/VQ2D.swift:883 — Sources/GrAIdient/Layer2D/VQ2D.swift:883-908 | Sources/GrAIdient/LayerSeq/VQSeq.swift:803-828 — before extracting anything, compare `Sources/GrAIdient/Layer2D/VQ2D.swift` and `Sources/GrAIdient/LayerSeq/VQSeq.swift` as WHOLE FILES: this scan already matched 30 separate duplicated blocks between them, totalling at least 378 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.
D4 · Code Duplication · Duplicated block (16 lines × 4) · ×2
  • Duplicated block (16 lines × 4) Sources/GrAIdient/Layer2D/BCESigmoid2D.swift:131 — Sources/GrAIdient/Layer2D/BCESigmoid2D.swift:131-146 | Sources/GrAIdient/Layer2D/BCESigmoid2D.swift:160-175 | Sources/GrAIdient/Layer2D/BCESigmoid2D.swift:221-236 | Sources/GrAIdient/Layer2D/BCESigmoid2D.swift:250-265 — 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/GrAIdient/Layer2D/BCESigmoid2D.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.
  • Duplicated block (16 lines × 4) Sources/GrAIdient/Layer2D/Multiply2D.swift:209 — Sources/GrAIdient/Layer2D/Multiply2D.swift:209-224 | Sources/GrAIdient/Layer2D/Multiply2D.swift:299-314 | Sources/GrAIdient/Layer2D/Sum2D.swift:131-146 | Sources/GrAIdient/Layer2D/Sum2D.swift:221-236 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Multiply2D.swift` and `Sources/GrAIdient/Layer2D/Sum2D.swift` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 100 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/GrAIdient/Layer2D/Multiply2D.swift:209` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (14 lines × 6) · ×2
  • Duplicated block (14 lines × 6) Sources/GrAIdient/Layer1D/SelectNeurons1D.swift:310 — Sources/GrAIdient/Layer1D/SelectNeurons1D.swift:310-323 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:677-690 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift:602-615 | Sources/GrAIdient/Layer2D/Transform/Rotate2D.swift:455-468 | Sources/GrAIdient/LayerSeq/SelectSeq.swift:245-258 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1085-1098 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift` and `Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 252 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (14 lines × 6) Sources/GrAIdient/LayerSeq/ValueSeq.swift:202 — Sources/GrAIdient/LayerSeq/ValueSeq.swift:202-215 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:304-317 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:769-782 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:877-890 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1476-1489 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1586-1599 — 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/GrAIdient/LayerSeq/ValueSeq.swift:202` 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.
D4 · Code Duplication · Duplicated block (13–14 lines × 2) · ×2
  • Duplicated block (13–14 lines × 2) Sources/GrAIdient/Layer2D/Transform/DecorrelateRGB.swift:188 — Sources/GrAIdient/Layer2D/Transform/DecorrelateRGB.swift:188-201 | Sources/GrAIdient/Layer2D/Transform/DecorrelateRGB.swift:250-262 — both copies are in the same file, so extract the 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/GrAIdient/Layer2D/Transform/DecorrelateRGB.swift:188` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (13–14 lines × 2) Sources/GrAIdient/LayerSeq/ValueSeq.swift:435 — Sources/GrAIdient/LayerSeq/ValueSeq.swift:435-447 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1019-1032 — both copies are in the same file, so extract the 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/GrAIdient/LayerSeq/ValueSeq.swift:435` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. 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.
D4 · Code Duplication · Duplicated block (12–13 lines × 2) · ×2
  • Duplicated block (12–13 lines × 2) Sources/GrAIdient/Core/Layer/LayerNormalization.swift:969 — Sources/GrAIdient/Core/Layer/LayerNormalization.swift:969-981 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1085-1096 — both copies are in the same file, so extract the 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/GrAIdient/Core/Layer/LayerNormalization.swift:983` calls `setBuffer` and `Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1098` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (12–13 lines × 2) Sources/GrAIdient/Layer2D/Transform/DecorrelateRGB.swift:145 — Sources/GrAIdient/Layer2D/Transform/DecorrelateRGB.swift:145-157 | Sources/GrAIdient/Layer2D/Transform/DecorrelateRGB.swift:190-201 — both copies are in the same file, so extract the 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/GrAIdient/Layer2D/Transform/DecorrelateRGB.swift:145` 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.
D4 · Code Duplication · Duplicated block (11 lines × 8) · ×2
  • Duplicated block (11 lines × 8) Sources/GrAIdient/Layer1D/DotProduct1D.swift:330 — Sources/GrAIdient/Layer1D/DotProduct1D.swift:330-340 | Sources/GrAIdient/Layer1D/Dropout1D.swift:344-354 | Sources/GrAIdient/Layer1D/FullyConnected.swift:915-925 | Sources/GrAIdient/Layer1D/Softmax1D.swift:244-254 | Sources/GrAIdient/Layer2D/AvgPool2D.swift:176-186 | Sources/GrAIdient/Layer2D/SelectNeurons2D.swift:276-286 | Sources/GrAIdient/LayerSeq/AvgPoolSeq.swift:166-176 | Sources/GrAIdient/LayerSeq/SelectSeq.swift:189-199 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 8 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 8 times. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/Layer1D/DotProduct1D.swift:330` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Sources/GrAIdient/Layer1D/Dropout1D.swift:342` calls `setBuffer`, `setBytes` and `Sources/GrAIdient/Layer1D/Softmax1D.swift:243` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (11 lines × 8) Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:531 — Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:531-542 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:691-702 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:505-516 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:631-642 | Sources/GrAIdient/LayerSeq/LayerNormSeq.swift:379-389 | Sources/GrAIdient/LayerSeq/LayerNormSeq.swift:438-448 | Sources/GrAIdient/LayerSeq/RMSNormSeq.swift:393-403 | Sources/GrAIdient/LayerSeq/RMSNormSeq.swift:452-462 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift` and `Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift` as WHOLE FILES: this scan already matched 54 separate duplicated blocks between them, totalling at least 760 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:704` calls `download` and `Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:544` 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.
D4 · Code Duplication · Duplicated block (11 lines × 5) · ×2
  • Duplicated block (11 lines × 5) Sources/GrAIdient/Layer1D/Activation1D.swift:184 — Sources/GrAIdient/Layer1D/Activation1D.swift:184-195 | Sources/GrAIdient/Layer1D/Base/LayerOutput1D.swift:236-246 | Sources/GrAIdient/Layer1D/Dropout1D.swift:217-228 | Sources/GrAIdient/Layer1D/SelectNeurons1D.swift:179-190 | Sources/GrAIdient/Layer2D/SelectNeurons2D.swift:197-208 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Activation1D.swift` and `Sources/GrAIdient/Layer1D/Base/LayerOutput1D.swift` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 130 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/GrAIdient/Layer1D/Activation1D.swift:184` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Sources/GrAIdient/Layer1D/Dropout1D.swift:215` calls `download` and `Sources/GrAIdient/Layer1D/Activation1D.swift:182` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (11 lines × 5) Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:940 — Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:940-950 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:379-389 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:828-838 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:1307-1317 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:1882-1892 — there are 5 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 5 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:940` 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.
D4 · Code Duplication · Duplicated block (10–11 lines × 2) · ×2
  • Duplicated block (10–11 lines × 2) Sources/GrAIdient/Layer2D/Normalize2D.swift:116 — Sources/GrAIdient/Layer2D/Normalize2D.swift:116-126 | Sources/GrAIdient/Layer2D/Normalize2D.swift:474-483 — both copies are in the same file, so extract the 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/GrAIdient/Layer2D/Normalize2D.swift:116` 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 (10–11 lines × 2) Sources/GrAIdient/Layer2D/SimilarityError2D.swift:399 — Sources/GrAIdient/Layer2D/SimilarityError2D.swift:399-408 | Sources/GrAIdient/Layer2D/Transform/FTFrequences2D.swift:239-249 — 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/GrAIdient/Layer2D/Transform/FTFrequences2D.swift:239` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (9 lines × 8) · ×2
  • Duplicated block (9 lines × 8) Sources/GrAIdient/Layer1D/Activation1D.swift:133 — Sources/GrAIdient/Layer1D/Activation1D.swift:133-141 | Sources/GrAIdient/Layer1D/BCE1D.swift:25-33 | Sources/GrAIdient/Layer1D/BCESigmoid1D.swift:28-36 | Sources/GrAIdient/Layer1D/Dropout1D.swift:92-100 | Sources/GrAIdient/Layer1D/LinearError1D.swift:23-31 | Sources/GrAIdient/Layer1D/MSE1D.swift:23-31 | Sources/GrAIdient/Layer1D/SelectNeurons1D.swift:105-113 | Sources/GrAIdient/Layer1D/Softmax1D.swift:96-104 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Activation1D.swift` and `Sources/GrAIdient/Layer1D/SelectNeurons1D.swift` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 72 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/GrAIdient/Layer1D/Activation1D.swift:133` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 8) Sources/GrAIdient/Layer2D/Activation2D.swift:197 — Sources/GrAIdient/Layer2D/Activation2D.swift:197-205 | Sources/GrAIdient/Layer2D/BN2D.swift:465-473 | Sources/GrAIdient/Layer2D/BN2D.swift:523-531 | Sources/GrAIdient/Layer2D/Base/LayerOutput2D.swift:289-297 | Sources/GrAIdient/Layer2D/InstanceNorm2D.swift:389-397 | Sources/GrAIdient/Layer2D/InstanceNorm2D.swift:447-455 | Sources/GrAIdient/Layer2D/Transform/Crop2D.swift:223-231 | Sources/GrAIdient/Layer2D/Transform/LinearScale2D.swift:137-145 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Activation2D.swift` and `Sources/GrAIdient/Layer2D/BN2D.swift` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 171 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/GrAIdient/Layer2D/Activation2D.swift:197` 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.
D4 · Code Duplication · Duplicated block (8–9 lines × 3) · ×2
  • Duplicated block (8–9 lines × 3) Sources/GrAIdient/Layer1D/Concat1D.swift:280 — Sources/GrAIdient/Layer1D/Concat1D.swift:280-288 | Sources/GrAIdient/LayerSeq/ConcatSeq.swift:740-747 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:1698-1706 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Concat1D.swift` and `Sources/GrAIdient/LayerSeq/ConcatSeq.swift` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 84 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/GrAIdient/Layer1D/Concat1D.swift:280` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (8–9 lines × 3) Sources/GrAIdient/Layer2D/Transform/Pad2D.swift:232 — Sources/GrAIdient/Layer2D/Transform/Pad2D.swift:232-239 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift:505-513 | Sources/GrAIdient/Layer2D/Transform/Rotate2D.swift:373-380 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Transform/Pad2D.swift` and `Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 117 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/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift:505` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (8 lines × 6) · ×2
  • Duplicated block (8 lines × 6) Sources/GrAIdient/Core/Layer/LayerNormalization.swift:855 — Sources/GrAIdient/Core/Layer/LayerNormalization.swift:855-862 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:888-895 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1702-1709 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1735-1742 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1767-1774 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1801-1808 — all 6 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
  • Duplicated block (8 lines × 6) Sources/GrAIdient/LayerSeq/ConcatSeq.swift:313 — Sources/GrAIdient/LayerSeq/ConcatSeq.swift:313-320 | Sources/GrAIdient/LayerSeq/SoftmaxSeq.swift:258-265 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:381-388 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:960-967 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1692-1699 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1876-1883 — there are 6 copies across 3 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 6 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/LayerSeq/ConcatSeq.swift:313` 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/GrAIdient/LayerSeq/ConcatSeq.swift:312` calls `setBytes` and `Sources/GrAIdient/LayerSeq/SoftmaxSeq.swift:257` 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.
D4 · Code Duplication · Duplicated block (7 lines × 18) · ×2
  • Duplicated block (7 lines × 18) Sources/GrAIdient/Layer1D/Concat1D.swift:376 — Sources/GrAIdient/Layer1D/Concat1D.swift:376-382 | Sources/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:779-785 | Sources/GrAIdient/Layer2D/AvgPool2D.swift:245-251 | Sources/GrAIdient/Layer2D/Concat2D.swift:420-426 | Sources/GrAIdient/Layer2D/Constant2D.swift:532-538 | Sources/GrAIdient/Layer2D/SelectNeurons2D.swift:347-353 | Sources/GrAIdient/Layer2D/SimilarityError2D.swift:500-506 | Sources/GrAIdient/Layer2D/Transform/Crop2D.swift:382-388 | Sources/GrAIdient/Layer2D/Transform/DecorrelateRGB.swift:299-305 | Sources/GrAIdient/Layer2D/Transform/IRDFT2RGB.swift:285-291 | Sources/GrAIdient/Layer2D/Transform/LinearScale2D.swift:271-277 | Sources/GrAIdient/Layer2D/Transform/Pad2D.swift:304-310 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:707-713 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift:640-646 | Sources/GrAIdient/Layer2D/Transform/Rotate2D.swift:476-482 | Sources/GrAIdient/LayerSeq/AvgPoolSeq.swift:229-235 | Sources/GrAIdient/LayerSeq/ConcatSeq.swift:839-845 | Sources/GrAIdient/LayerSeq/SelectSeq.swift:266-272 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Concat1D.swift` and `Sources/GrAIdient/Layer2D/Concat2D.swift` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 87 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. 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/GrAIdient/Layer1D/Concat1D.swift:376` it begins part-way through the construct above it, so those 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/GrAIdient/Layer1D/Concat1D.swift:383` calls `setBytes` and `Sources/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:786` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (7 lines × 18) Sources/GrAIdient/Layer1D/Softmax1D.swift:240 — Sources/GrAIdient/Layer1D/Softmax1D.swift:240-246 | Sources/GrAIdient/Layer2D/AvgPool2D.swift:172-178 | Sources/GrAIdient/Layer2D/MaxPool2D.swift:373-379 | Sources/GrAIdient/Layer2D/Normalize2D.swift:189-195 | Sources/GrAIdient/Layer2D/Normalize2D.swift:551-557 | Sources/GrAIdient/Layer2D/SelectNeurons2D.swift:271-277 | Sources/GrAIdient/Layer2D/SelfCorrelate2D.swift:188-194 | Sources/GrAIdient/Layer2D/Transform/ColorJitterHSV.swift:316-322 | Sources/GrAIdient/Layer2D/Transform/Crop2D.swift:304-310 | Sources/GrAIdient/Layer2D/Transform/DecorrelateRGB.swift:227-233 | Sources/GrAIdient/Layer2D/Transform/IRDFT2RGB.swift:202-208 | Sources/GrAIdient/Layer2D/Transform/LinearScale2D.swift:205-211 | Sources/GrAIdient/Layer2D/Transform/Pad2D.swift:234-240 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:583-589 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift:508-514 | Sources/GrAIdient/Layer2D/Transform/Rotate2D.swift:375-381 | Sources/GrAIdient/LayerSeq/AvgPoolSeq.swift:162-168 | Sources/GrAIdient/LayerSeq/SelectSeq.swift:184-190 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Softmax1D.swift` and `Sources/GrAIdient/Layer2D/AvgPool2D.swift` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 34 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/GrAIdient/Layer2D/AvgPool2D.swift:169` calls `UInt32` and `Sources/GrAIdient/Layer1D/Softmax1D.swift:238` 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.
D4 · Code Duplication · Duplicated block (7 lines × 14) · ×2
  • Duplicated block (7 lines × 14) Sources/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:573 — Sources/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:573-579 | Sources/GrAIdient/Layer2D/Constant2D.swift:471-477 | Sources/GrAIdient/Layer2D/Normalize2D.swift:193-199 | Sources/GrAIdient/Layer2D/Normalize2D.swift:610-616 | Sources/GrAIdient/Layer2D/SimilarityError2D.swift:399-405 | Sources/GrAIdient/Layer2D/Transform/Crop2D.swift:310-316 | Sources/GrAIdient/Layer2D/Transform/DecorrelateRGB.swift:232-238 | Sources/GrAIdient/Layer2D/Transform/Flip2D.swift:243-249 | Sources/GrAIdient/Layer2D/Transform/IRDFT2RGB.swift:206-212 | Sources/GrAIdient/Layer2D/Transform/LinearScale2D.swift:210-216 | Sources/GrAIdient/Layer2D/Transform/Pad2D.swift:240-246 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:590-596 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift:516-522 | Sources/GrAIdient/Layer2D/Transform/Rotate2D.swift:381-387 — there are 14 copies across 13 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 14 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:573` 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/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:572` calls `setBytes` and `Sources/GrAIdient/Layer2D/Constant2D.swift:470` 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 (7 lines × 14) Sources/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:569 — Sources/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:569-575 | Sources/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:609-615 | Sources/GrAIdient/Layer2D/MaxPool2D.swift:374-380 | Sources/GrAIdient/Layer2D/Normalize2D.swift:552-558 | Sources/GrAIdient/Layer2D/SelectNeurons2D.swift:272-278 | Sources/GrAIdient/Layer2D/Transform/Crop2D.swift:305-311 | Sources/GrAIdient/Layer2D/Transform/DecorrelateRGB.swift:228-234 | Sources/GrAIdient/Layer2D/Transform/LinearScale2D.swift:206-212 | Sources/GrAIdient/Layer2D/Transform/Pad2D.swift:235-241 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:584-590 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift:509-515 | Sources/GrAIdient/Layer2D/Transform/Rotate2D.swift:376-382 | Sources/GrAIdient/LayerSeq/ConcatSeq.swift:736-742 | Sources/GrAIdient/LayerSeq/SelectSeq.swift:185-191 — before extracting anything, compare `Sources/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift` and `Sources/GrAIdient/Layer2D/MaxPool2D.swift` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 44 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. 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/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:569` it begins part-way through the construct above it, so those 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/GrAIdient/Layer2D/MaxPool2D.swift:381` calls `setBytes`, `setBuffer` and `Sources/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:576` 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.
D4 · Code Duplication · Duplicated block (7 lines × 13) · ×2
  • Duplicated block (7 lines × 13) Sources/GrAIdient/Layer1D/Activation1D.swift:251 — Sources/GrAIdient/Layer1D/Activation1D.swift:251-257 | Sources/GrAIdient/Layer1D/Base/LayerOutput1D.swift:295-301 | Sources/GrAIdient/Layer1D/Input1D.swift:349-355 | Sources/GrAIdient/Layer2D/Activation2D.swift:262-268 | Sources/GrAIdient/Layer2D/BN2D.swift:600-606 | Sources/GrAIdient/Layer2D/Base/LayerOutput2D.swift:351-357 | Sources/GrAIdient/Layer2D/Input2D.swift:451-457 | Sources/GrAIdient/Layer2D/InstanceNorm2D.swift:524-530 | Sources/GrAIdient/LayerSeq/ActivationSeq.swift:260-266 | Sources/GrAIdient/LayerSeq/LayerNormSeq.swift:520-526 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:1330-1336 | Sources/GrAIdient/LayerSeq/RMSNormSeq.swift:534-540 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1380-1386 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Activation1D.swift` and `Sources/GrAIdient/Layer1D/Base/LayerOutput1D.swift` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 130 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (7 lines × 13) Sources/GrAIdient/Layer1D/BCE1D.swift:224 — Sources/GrAIdient/Layer1D/BCE1D.swift:224-230 | Sources/GrAIdient/Layer1D/BCE1D.swift:388-394 | Sources/GrAIdient/Layer1D/BCESigmoid1D.swift:247-253 | Sources/GrAIdient/Layer1D/BCESigmoid1D.swift:407-413 | Sources/GrAIdient/Layer1D/LinearError1D.swift:216-222 | Sources/GrAIdient/Layer1D/MSE1D.swift:220-226 | Sources/GrAIdient/Layer1D/MSE1D.swift:371-377 | Sources/GrAIdient/Layer2D/BCE2D.swift:290-296 | Sources/GrAIdient/Layer2D/BCE2D.swift:513-519 | Sources/GrAIdient/Layer2D/BCESigmoid2D.swift:333-339 | Sources/GrAIdient/Layer2D/BCESigmoid2D.swift:548-554 | Sources/GrAIdient/Layer2D/MSE2D.swift:286-292 | Sources/GrAIdient/Layer2D/MSE2D.swift:483-489 — before extracting anything, compare `Sources/GrAIdient/Layer1D/BCE1D.swift` and `Sources/GrAIdient/Layer1D/BCESigmoid1D.swift` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 218 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Sources/GrAIdient/Layer2D/BCE2D.swift:522` calls `setBytes` and `Sources/GrAIdient/Layer1D/BCE1D.swift:397` 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.
D4 · Code Duplication · Duplicated block (7 lines × 7) · ×2
  • Duplicated block (7 lines × 7) Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:182 — Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:182-188 | Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:236-242 | Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:304-310 | Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:376-382 | Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:459-465 | Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:595-601 | Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:679-685 — all 7 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:244` calls `setBuffer` and `Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:191` 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 (7 lines × 7) Sources/GrAIdient/Layer1D/Constant1D.swift:460 — Sources/GrAIdient/Layer1D/Constant1D.swift:460-466 | Sources/GrAIdient/Layer1D/FullyConnected.swift:1100-1106 | Sources/GrAIdient/Layer2D/Constant2D.swift:531-537 | Sources/GrAIdient/Layer2D/Constant2D.swift:549-555 | Sources/GrAIdient/LayerSeq/ConstantSeq.swift:984-990 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:1212-1218 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:1097-1103 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Constant1D.swift` and `Sources/GrAIdient/Layer1D/FullyConnected.swift` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 51 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Sources/GrAIdient/Layer2D/Constant2D.swift:538` calls `setBytes` and `Sources/GrAIdient/Layer1D/Constant1D.swift:467` 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.
D4 · Code Duplication · Duplicated block (6 lines × 12) · ×2
  • Duplicated block (6 lines × 12) Sources/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:780 — Sources/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:780-785 | Sources/GrAIdient/Layer2D/AvgPool2D.swift:246-251 | Sources/GrAIdient/Layer2D/Constant2D.swift:533-538 | Sources/GrAIdient/Layer2D/Convolution2D.swift:1664-1669 | Sources/GrAIdient/Layer2D/Transform/IRDFT2RGB.swift:286-291 | Sources/GrAIdient/Layer2D/Transform/Rotate2D.swift:477-482 | Sources/GrAIdient/LayerSeq/AvgPoolSeq.swift:230-235 | Sources/GrAIdient/LayerSeq/ConstantSeq.swift:459-464 | Sources/GrAIdient/LayerSeq/ConstantSeq.swift:968-973 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:1174-1179 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:1061-1066 | Sources/GrAIdient/LayerSeq/SelectSeq.swift:267-272 — there are 12 copies across 11 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 12 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:780` it begins part-way through the construct above it, so those exact lines 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 × 12) Sources/GrAIdient/Layer2D/Normalize2D.swift:289 — Sources/GrAIdient/Layer2D/Normalize2D.swift:289-294 | Sources/GrAIdient/Layer2D/SelfCorrelate2D.swift:272-277 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:504-509 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:532-537 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:2023-2028 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:2053-2058 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:504-509 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:531-536 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1105-1110 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1133-1138 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:2015-2020 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:2044-2049 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Normalize2D.swift` and `Sources/GrAIdient/Layer2D/SelfCorrelate2D.swift` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 74 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/GrAIdient/Layer2D/Normalize2D.swift:289` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Sources/GrAIdient/LayerSeq/QuerySeq.swift:511` calls `setBytes` and `Sources/GrAIdient/Layer2D/Normalize2D.swift:296` 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.
D4 · Code Duplication · Duplicated block (5 lines × 19) · ×2
  • Duplicated block (5 lines × 19) Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1971 — Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1971-1975 | Sources/GrAIdient/Layer2D/Normalize2D.swift:291-295 | Sources/GrAIdient/Layer2D/SelfCorrelate2D.swift:274-278 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:376-380 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:506-510 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:534-538 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:1877-1881 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:2025-2029 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:2055-2059 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:379-383 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:506-510 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:533-537 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:956-960 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1107-1111 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1135-1139 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1688-1692 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1872-1876 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:2017-2021 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:2046-2050 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Normalize2D.swift` and `Sources/GrAIdient/Layer2D/SelfCorrelate2D.swift` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 74 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/GrAIdient/Core/Layer/LayerNormalization.swift:1969` calls `setBuffer` and `Sources/GrAIdient/Layer2D/Normalize2D.swift:289` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (5 lines × 19) Sources/GrAIdient/Layer1D/Concat1D.swift:279 — Sources/GrAIdient/Layer1D/Concat1D.swift:279-284 | Sources/GrAIdient/Layer1D/DotProduct1D.swift:329-333 | Sources/GrAIdient/Layer1D/Dropout1D.swift:343-347 | Sources/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:572-576 | Sources/GrAIdient/Layer2D/LayerCAM2D.swift:188-192 | Sources/GrAIdient/Layer2D/Normalize2D.swift:609-613 | Sources/GrAIdient/Layer2D/SelectNeurons2D.swift:275-279 | Sources/GrAIdient/Layer2D/SimilarityError2D.swift:397-402 | Sources/GrAIdient/Layer2D/Transform/DecorrelateRGB.swift:231-235 | Sources/GrAIdient/Layer2D/Transform/Flip2D.swift:242-246 | Sources/GrAIdient/Layer2D/Transform/LinearScale2D.swift:209-213 | Sources/GrAIdient/Layer2D/VQ2D.swift:526-530 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:841-845 | Sources/GrAIdient/LayerSeq/LayerCAMSeq.swift:184-188 | Sources/GrAIdient/LayerSeq/RoPESeq.swift:370-374 | Sources/GrAIdient/LayerSeq/SelectSeq.swift:188-192 | Sources/GrAIdient/LayerSeq/SoftmaxSeq.swift:258-262 | Sources/GrAIdient/LayerSeq/SoftmaxSeq.swift:532-536 | Sources/GrAIdient/LayerSeq/VQSeq.swift:454-458 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Concat1D.swift` and `Sources/GrAIdient/Layer1D/DotProduct1D.swift` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 46 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/Layer1D/Concat1D.swift:279` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Sources/GrAIdient/LayerSeq/VQSeq.swift:459` calls `setBuffer` and `Sources/GrAIdient/Layer1D/Concat1D.swift:286` 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.
D4 · Code Duplication · Duplicated block (5 lines × 6) · ×2
  • Duplicated block (5 lines × 6) Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:240 — Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:240-244 | Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:309-313 | Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:381-385 | Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:464-468 | Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:602-606 | Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:686-690 — 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. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:387` calls `setBuffer` and `Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:316` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (5 lines × 6) Sources/GrAIdient/Layer2D/Normalize2D.swift:544 — Sources/GrAIdient/Layer2D/Normalize2D.swift:544-548 | Sources/GrAIdient/Layer2D/Normalize2D.swift:597-601 | Sources/GrAIdient/Layer2D/Transform/Pad2D.swift:226-230 | Sources/GrAIdient/Layer2D/VQ2D.swift:514-518 | Sources/GrAIdient/Layer2D/VQ2D.swift:1276-1280 | Sources/GrAIdient/Layer2D/VQ2D.swift:1334-1338 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Normalize2D.swift` and `Sources/GrAIdient/Layer2D/Transform/Pad2D.swift` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 125 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Sources/GrAIdient/Layer2D/Transform/Pad2D.swift:232` calls `Float` and `Sources/GrAIdient/Layer2D/Normalize2D.swift:551` 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.
D1 · Cyclomatic Complexity · Deconvolution2D._forwardGCGPU (cyclomatic 72) · ×1
  • Deconvolution2D._forwardGCGPU (cyclomatic 72) Sources/GrAIdient/Layer2D/Deconvolution2D.swift:473 — Deconvolution2D._forwardGCGPU has cyclomatic complexity 72 (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.
D1 · Cyclomatic Complexity · Convolution2D._forwardGCGPU (cyclomatic 64) · ×1
  • Convolution2D._forwardGCGPU (cyclomatic 64) Sources/GrAIdient/Layer2D/Convolution2D.swift:1038 — Convolution2D._forwardGCGPU has cyclomatic complexity 64 (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.
D1 · Cyclomatic Complexity · Deconvolution2D._forwardGCCPU (cyclomatic 63) · ×1
  • Deconvolution2D._forwardGCCPU (cyclomatic 63) Sources/GrAIdient/Layer2D/Deconvolution2D.swift:268 — Deconvolution2D._forwardGCCPU has cyclomatic complexity 63 (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.
D1 · Cyclomatic Complexity · Convolution2D._forwardGCCPU (cyclomatic 55) · ×1
  • Convolution2D._forwardGCCPU (cyclomatic 55) Sources/GrAIdient/Layer2D/Convolution2D.swift:842 — Convolution2D._forwardGCCPU has cyclomatic complexity 55 (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.
D1 · Cyclomatic Complexity · FullyConnectedPatch._forwardGCCPU (cyclomatic 34) · ×1
  • FullyConnectedPatch._forwardGCCPU (cyclomatic 34) Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:527 — FullyConnectedPatch._forwardGCCPU has cyclomatic complexity 34 (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. This shape REPEATS in the file: one other method here (FullyConnectedPatch._forwardGCGPU) 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.
D1 · Cyclomatic Complexity · FullyConnectedPatch._forwardGCGPU (cyclomatic 34) · ×1
  • FullyConnectedPatch._forwardGCGPU (cyclomatic 34) Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:687 — FullyConnectedPatch._forwardGCGPU has cyclomatic complexity 34 (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. This shape REPEATS in the file: one other method here (FullyConnectedPatch._forwardGCCPU) 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.
D1 · Cyclomatic Complexity · FullyConnectedSeq._forwardGCCPU (cyclomatic 28) · ×1
  • FullyConnectedSeq._forwardGCCPU (cyclomatic 28) Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:501 — FullyConnectedSeq._forwardGCCPU has cyclomatic complexity 28 (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. This shape REPEATS in the file: one other method here (FullyConnectedSeq._forwardGCGPU) 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.
D1 · Cyclomatic Complexity · FullyConnectedSeq._forwardGCGPU (cyclomatic 28) · ×1
  • FullyConnectedSeq._forwardGCGPU (cyclomatic 28) Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:627 — FullyConnectedSeq._forwardGCGPU has cyclomatic complexity 28 (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. This shape REPEATS in the file: one other method here (FullyConnectedSeq._forwardGCCPU) 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.
D1 · Cyclomatic Complexity · AdaptiveAvgPool2D.forwardGCCPU (cyclomatic 27) · ×1
  • AdaptiveAvgPool2D.forwardGCCPU (cyclomatic 27) Sources/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:254 — AdaptiveAvgPool2D.forwardGCCPU has cyclomatic complexity 27 (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.
D1 · Cyclomatic Complexity · FullyConnected._forwardGCCPU (cyclomatic 24) · ×1
  • FullyConnected._forwardGCCPU (cyclomatic 24) Sources/GrAIdient/Layer1D/FullyConnected.swift:634 — FullyConnected._forwardGCCPU has cyclomatic complexity 24 (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. This shape REPEATS in the file: one other method here (FullyConnected._forwardGCGPU) 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.
D1 · Cyclomatic Complexity · FullyConnected._forwardGCGPU (cyclomatic 24) · ×1
  • FullyConnected._forwardGCGPU (cyclomatic 24) Sources/GrAIdient/Layer1D/FullyConnected.swift:745 — FullyConnected._forwardGCGPU has cyclomatic complexity 24 (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. This shape REPEATS in the file: one other method here (FullyConnected._forwardGCCPU) 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.
D1 · Cyclomatic Complexity · AdaptiveAvgPool2D.forwardCPU (cyclomatic 23) · ×1
  • AdaptiveAvgPool2D.forwardCPU (cyclomatic 23) Sources/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:408 — AdaptiveAvgPool2D.forwardCPU has cyclomatic complexity 23 (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.
D1 · Cyclomatic Complexity · AdaptiveAvgPool2D.backwardCPU (cyclomatic 21) · ×1
  • AdaptiveAvgPool2D.backwardCPU (cyclomatic 21) Sources/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:629 — AdaptiveAvgPool2D.backwardCPU has cyclomatic complexity 21 (threshold 15). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D1 · Cyclomatic Complexity · Concat2D.forwardGCGPU (cyclomatic 20) · ×1
  • Concat2D.forwardGCGPU (cyclomatic 20) Sources/GrAIdient/Layer2D/Concat2D.swift:167 — Concat2D.forwardGCGPU has cyclomatic complexity 20 (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.
D1 · Cyclomatic Complexity · Multiply2D.forwardGCGPU (cyclomatic 20) · ×1
  • Multiply2D.forwardGCGPU (cyclomatic 20) Sources/GrAIdient/Layer2D/Multiply2D.swift:253 — Multiply2D.forwardGCGPU has cyclomatic complexity 20 (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.
D1 · Cyclomatic Complexity · Sum2D.forwardGCGPU (cyclomatic 20) · ×1
  • Sum2D.forwardGCGPU (cyclomatic 20) Sources/GrAIdient/Layer2D/Sum2D.swift:175 — Sum2D.forwardGCGPU has cyclomatic complexity 20 (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.
D1 · Cyclomatic Complexity · QueryCausalSeq.forwardGCCPU (cyclomatic 20) · ×1
  • QueryCausalSeq.forwardGCCPU (cyclomatic 20) Sources/GrAIdient/LayerSeq/QuerySeq.swift:1350 — QueryCausalSeq.forwardGCCPU has cyclomatic complexity 20 (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. This shape REPEATS in the file: one other method here (QueryCausalSeq.forwardGCGPU) 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.
D1 · Cyclomatic Complexity · QueryCausalSeq.forwardGCGPU (cyclomatic 20) · ×1
  • QueryCausalSeq.forwardGCGPU (cyclomatic 20) Sources/GrAIdient/LayerSeq/QuerySeq.swift:1473 — QueryCausalSeq.forwardGCGPU has cyclomatic complexity 20 (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. This shape REPEATS in the file: one other method here (QueryCausalSeq.forwardGCCPU) 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.
D1 · Cyclomatic Complexity · BCE2D.lossDerivativeCPU (cyclomatic 19) · ×1
  • BCE2D.lossDerivativeCPU (cyclomatic 19) Sources/GrAIdient/Layer2D/BCE2D.swift:332 — BCE2D.lossDerivativeCPU has cyclomatic complexity 19 (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.
D1 · Cyclomatic Complexity · Concat2D.forwardGCCPU (cyclomatic 19) · ×1
  • Concat2D.forwardGCCPU (cyclomatic 19) Sources/GrAIdient/Layer2D/Concat2D.swift:80 — Concat2D.forwardGCCPU has cyclomatic complexity 19 (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.
D1 · Cyclomatic Complexity · Deconvolution2D._backwardWeightsCPU (cyclomatic 19) · ×1
  • Deconvolution2D._backwardWeightsCPU (cyclomatic 19) Sources/GrAIdient/Layer2D/Deconvolution2D.swift:812 — Deconvolution2D._backwardWeightsCPU has cyclomatic complexity 19 (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.
D1 · Cyclomatic Complexity · Multiply2D.forwardGCCPU (cyclomatic 19) · ×1
  • Multiply2D.forwardGCCPU (cyclomatic 19) Sources/GrAIdient/Layer2D/Multiply2D.swift:169 — Multiply2D.forwardGCCPU has cyclomatic complexity 19 (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.
D1 · Cyclomatic Complexity · Sum2D.forwardGCCPU (cyclomatic 19) · ×1
  • Sum2D.forwardGCCPU (cyclomatic 19) Sources/GrAIdient/Layer2D/Sum2D.swift:91 — Sum2D.forwardGCCPU has cyclomatic complexity 19 (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.
D1 · Cyclomatic Complexity · ValueSelfSeq.backwardCPU (cyclomatic 19) · ×1
  • ValueSelfSeq.backwardCPU (cyclomatic 19) Sources/GrAIdient/LayerSeq/ValueSeq.swift:974 — ValueSelfSeq.backwardCPU has cyclomatic complexity 19 (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.
D1 · Cyclomatic Complexity · LayerNormalization.forwardGC (cyclomatic 19) · ×1
  • LayerNormalization.forwardGC (cyclomatic 19) Sources/GrAIdient/Core/Layer/LayerNormalization.swift:2103 — LayerNormalization.forwardGC has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · LayerOutput2D.checkGroundTruthGPU (cyclomatic 19) · ×1
  • LayerOutput2D.checkGroundTruthGPU (cyclomatic 19) Sources/GrAIdient/Layer2D/Base/LayerOutput2D.swift:140 — LayerOutput2D.checkGroundTruthGPU has cyclomatic complexity 19 (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.
D1 · Cyclomatic Complexity · ResizeBilinearCrop.forwardCPU (cyclomatic 19) · ×1
  • ResizeBilinearCrop.forwardCPU (cyclomatic 19) Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:386 — ResizeBilinearCrop.forwardCPU has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · QuerySeq.forwardGCCPU (cyclomatic 18) · ×1
  • QuerySeq.forwardGCCPU (cyclomatic 18) Sources/GrAIdient/LayerSeq/QuerySeq.swift:128 — QuerySeq.forwardGCCPU has cyclomatic complexity 18 (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. This shape REPEATS in the file: one other method here (QuerySeq.forwardGCGPU) 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.
D1 · Cyclomatic Complexity · QuerySeq.forwardGCGPU (cyclomatic 18) · ×1
  • QuerySeq.forwardGCGPU (cyclomatic 18) Sources/GrAIdient/LayerSeq/QuerySeq.swift:219 — QuerySeq.forwardGCGPU has cyclomatic complexity 18 (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. This shape REPEATS in the file: one other method here (QuerySeq.forwardGCCPU) 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.
D1 · Cyclomatic Complexity · ValueSeq.forwardGCCPU (cyclomatic 18) · ×1
  • ValueSeq.forwardGCCPU (cyclomatic 18) Sources/GrAIdient/LayerSeq/ValueSeq.swift:132 — ValueSeq.forwardGCCPU has cyclomatic complexity 18 (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. This shape REPEATS in the file: 5 other methods here (ValueSeq.forwardGCGPU, ValueSelfSeq.forwardGCCPU, ValueSelfSeq.forwardGCGPU, …) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 6 times rather than 6 independent problems. Splitting this body alone leaves the other 5 exactly as they are. Where these are variations on one operation, the change that clears all 6 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.
D1 · Cyclomatic Complexity · ValueSeq.forwardGCGPU (cyclomatic 18) · ×1
  • ValueSeq.forwardGCGPU (cyclomatic 18) Sources/GrAIdient/LayerSeq/ValueSeq.swift:222 — ValueSeq.forwardGCGPU has cyclomatic complexity 18 (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. This shape REPEATS in the file: 5 other methods here (ValueSeq.forwardGCCPU, ValueSelfSeq.forwardGCCPU, ValueSelfSeq.forwardGCGPU, …) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 6 times rather than 6 independent problems. Splitting this body alone leaves the other 5 exactly as they are. Where these are variations on one operation, the change that clears all 6 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.
D1 · Cyclomatic Complexity · ValueSelfSeq.forwardGCCPU (cyclomatic 18) · ×1
  • ValueSelfSeq.forwardGCCPU (cyclomatic 18) Sources/GrAIdient/LayerSeq/ValueSeq.swift:694 — ValueSelfSeq.forwardGCCPU has cyclomatic complexity 18 (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. This shape REPEATS in the file: 5 other methods here (ValueSeq.forwardGCCPU, ValueSeq.forwardGCGPU, ValueSelfSeq.forwardGCGPU, …) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 6 times rather than 6 independent problems. Splitting this body alone leaves the other 5 exactly as they are. Where these are variations on one operation, the change that clears all 6 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.
D1 · Cyclomatic Complexity · ValueSelfSeq.forwardGCGPU (cyclomatic 18) · ×1
  • ValueSelfSeq.forwardGCGPU (cyclomatic 18) Sources/GrAIdient/LayerSeq/ValueSeq.swift:789 — ValueSelfSeq.forwardGCGPU has cyclomatic complexity 18 (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. This shape REPEATS in the file: 5 other methods here (ValueSeq.forwardGCCPU, ValueSeq.forwardGCGPU, ValueSelfSeq.forwardGCCPU, …) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 6 times rather than 6 independent problems. Splitting this body alone leaves the other 5 exactly as they are. Where these are variations on one operation, the change that clears all 6 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.
D1 · Cyclomatic Complexity · ValueCausalSeq.forwardGCCPU (cyclomatic 18) · ×1
  • ValueCausalSeq.forwardGCCPU (cyclomatic 18) Sources/GrAIdient/LayerSeq/ValueSeq.swift:1400 — ValueCausalSeq.forwardGCCPU has cyclomatic complexity 18 (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. This shape REPEATS in the file: 5 other methods here (ValueSeq.forwardGCCPU, ValueSeq.forwardGCGPU, ValueSelfSeq.forwardGCCPU, …) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 6 times rather than 6 independent problems. Splitting this body alone leaves the other 5 exactly as they are. Where these are variations on one operation, the change that clears all 6 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.
D1 · Cyclomatic Complexity · ValueCausalSeq.forwardGCGPU (cyclomatic 18) · ×1
  • ValueCausalSeq.forwardGCGPU (cyclomatic 18) Sources/GrAIdient/LayerSeq/ValueSeq.swift:1496 — ValueCausalSeq.forwardGCGPU has cyclomatic complexity 18 (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. This shape REPEATS in the file: 5 other methods here (ValueSeq.forwardGCCPU, ValueSeq.forwardGCGPU, ValueSelfSeq.forwardGCCPU, …) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 6 times rather than 6 independent problems. Splitting this body alone leaves the other 5 exactly as they are. Where these are variations on one operation, the change that clears all 6 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.
D1 · Cyclomatic Complexity · BCESigmoid2D.lossDerivativeCPU (cyclomatic 17) · ×1
  • BCESigmoid2D.lossDerivativeCPU (cyclomatic 17) Sources/GrAIdient/Layer2D/BCESigmoid2D.swift:375 — BCESigmoid2D.lossDerivativeCPU has cyclomatic complexity 17 (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.
D1 · Cyclomatic Complexity · Convolution2D._backwardWeightsCPU (cyclomatic 17) · ×1
  • Convolution2D._backwardWeightsCPU (cyclomatic 17) Sources/GrAIdient/Layer2D/Convolution2D.swift:1444 — Convolution2D._backwardWeightsCPU has cyclomatic complexity 17 (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.
D1 · Cyclomatic Complexity · SimilarityError2D.forwardGCGPU (cyclomatic 17) · ×1
  • SimilarityError2D.forwardGCGPU (cyclomatic 17) Sources/GrAIdient/Layer2D/SimilarityError2D.swift:255 — SimilarityError2D.forwardGCGPU has cyclomatic complexity 17 (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.
D1 · Cyclomatic Complexity · Concat1Seq.forwardGCGPU (cyclomatic 17) · ×1
  • Concat1Seq.forwardGCGPU (cyclomatic 17) Sources/GrAIdient/LayerSeq/ConcatSeq.swift:163 — Concat1Seq.forwardGCGPU has cyclomatic complexity 17 (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. This shape REPEATS in the file: one other method here (Concat2Seq.forwardGCGPU) 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.
D1 · Cyclomatic Complexity · Concat2Seq.forwardGCGPU (cyclomatic 17) · ×1
  • Concat2Seq.forwardGCGPU (cyclomatic 17) Sources/GrAIdient/LayerSeq/ConcatSeq.swift:595 — Concat2Seq.forwardGCGPU has cyclomatic complexity 17 (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. This shape REPEATS in the file: one other method here (Concat1Seq.forwardGCGPU) 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.
D1 · Cyclomatic Complexity · MultiplySeq.forwardGCGPU (cyclomatic 17) · ×1
  • MultiplySeq.forwardGCGPU (cyclomatic 17) Sources/GrAIdient/LayerSeq/MutiplySeq.swift:238 — MultiplySeq.forwardGCGPU has cyclomatic complexity 17 (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.
D1 · Cyclomatic Complexity · QueryCausalSeq.backwardCPU (cyclomatic 17) · ×1
  • QueryCausalSeq.backwardCPU (cyclomatic 17) Sources/GrAIdient/LayerSeq/QuerySeq.swift:1895 — QueryCausalSeq.backwardCPU has cyclomatic complexity 17 (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.
D1 · Cyclomatic Complexity · SumSeq.forwardGCGPU (cyclomatic 17) · ×1
  • SumSeq.forwardGCGPU (cyclomatic 17) Sources/GrAIdient/LayerSeq/SumSeq.swift:160 — SumSeq.forwardGCGPU has cyclomatic complexity 17 (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.
D1 · Cyclomatic Complexity · ValueCausalSeq.backwardCPU (cyclomatic 17) · ×1
  • ValueCausalSeq.backwardCPU (cyclomatic 17) Sources/GrAIdient/LayerSeq/ValueSeq.swift:1890 — ValueCausalSeq.backwardCPU has cyclomatic complexity 17 (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.
D1 · Cyclomatic Complexity · Crop2D.backwardCPU (cyclomatic 17) · ×1
  • Crop2D.backwardCPU (cyclomatic 17) Sources/GrAIdient/Layer2D/Transform/Crop2D.swift:324 — Crop2D.backwardCPU has cyclomatic complexity 17 (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.
D1 · Cyclomatic Complexity · FTFrequences2D.setDataCPU (cyclomatic 17) · ×1
  • FTFrequences2D.setDataCPU (cyclomatic 17) Sources/GrAIdient/Layer2D/Transform/FTFrequences2D.swift:135 — FTFrequences2D.setDataCPU has cyclomatic complexity 17 (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.
D1 · Cyclomatic Complexity · Convolution2D._backwardWeightsGPU (cyclomatic 16) · ×1
  • Convolution2D._backwardWeightsGPU (cyclomatic 16) Sources/GrAIdient/Layer2D/Convolution2D.swift:1582 — Convolution2D._backwardWeightsGPU 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.
D1 · Cyclomatic Complexity · SimilarityError2D.forwardGCCPU (cyclomatic 16) · ×1
  • SimilarityError2D.forwardGCCPU (cyclomatic 16) Sources/GrAIdient/Layer2D/SimilarityError2D.swift:171 — SimilarityError2D.forwardGCCPU 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.
D1 · Cyclomatic Complexity · Concat1Seq.forwardGCCPU (cyclomatic 16) · ×1
  • Concat1Seq.forwardGCCPU (cyclomatic 16) Sources/GrAIdient/LayerSeq/ConcatSeq.swift:82 — Concat1Seq.forwardGCCPU 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. This shape REPEATS in the file: one other method here (Concat2Seq.forwardGCCPU) 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.
D1 · Cyclomatic Complexity · Concat2Seq.forwardGCCPU (cyclomatic 16) · ×1
  • Concat2Seq.forwardGCCPU (cyclomatic 16) Sources/GrAIdient/LayerSeq/ConcatSeq.swift:514 — Concat2Seq.forwardGCCPU 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. This shape REPEATS in the file: one other method here (Concat1Seq.forwardGCCPU) 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.
D1 · Cyclomatic Complexity · MultiplySeq.forwardGCCPU (cyclomatic 16) · ×1
  • MultiplySeq.forwardGCCPU (cyclomatic 16) Sources/GrAIdient/LayerSeq/MutiplySeq.swift:168 — MultiplySeq.forwardGCCPU 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.
D1 · Cyclomatic Complexity · QuerySeq.backwardCPU (cyclomatic 16) · ×1
  • QuerySeq.backwardCPU (cyclomatic 16) Sources/GrAIdient/LayerSeq/QuerySeq.swift:392 — QuerySeq.backwardCPU 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.
D1 · Cyclomatic Complexity · SumSeq.forwardGCCPU (cyclomatic 16) · ×1
  • SumSeq.forwardGCCPU (cyclomatic 16) Sources/GrAIdient/LayerSeq/SumSeq.swift:90 — SumSeq.forwardGCCPU 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.
D1 · Cyclomatic Complexity · ValueSeq.backwardCPU (cyclomatic 16) · ×1
  • ValueSeq.backwardCPU (cyclomatic 16) Sources/GrAIdient/LayerSeq/ValueSeq.swift:395 — ValueSeq.backwardCPU 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.
D1 · Cyclomatic Complexity · Rotate2D.backwardCPU (cyclomatic 16) · ×1
  • Rotate2D.backwardCPU (cyclomatic 16) Sources/GrAIdient/Layer2D/Transform/Rotate2D.swift:395 — Rotate2D.backwardCPU 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.
D12 · Dependency Hygiene · Floating branch dependency · ×1
  • Floating branch dependency: pythonkit — Dependency `pythonkit` is declared in Package.swift against branch `master` — the declaration pins no immutable point, so `swift package update` moves this dependency to whatever that branch holds at the time, which is code nobody reviewed. Pin it to a version requirement (`from:`, `.upToNextMajor(from:)`, `exact:`) or to a `revision:` commit SHA.
D2 · Cognitive Complexity · Deconvolution2D._forwardGCGPU (cognitive 431) · ×1
  • Deconvolution2D._forwardGCGPU (cognitive 431) Sources/GrAIdient/Layer2D/Deconvolution2D.swift:473 — Deconvolution2D._forwardGCGPU has cognitive complexity 431 (threshold 15). Drivers by points: loops 40 (258 pts), if/else 17 (157 pts), boolean chains 16 (nesting depth added 358). 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.
D2 · Cognitive Complexity · Deconvolution2D._forwardGCCPU (cognitive 422) · ×1
  • Deconvolution2D._forwardGCCPU (cognitive 422) Sources/GrAIdient/Layer2D/Deconvolution2D.swift:268 — Deconvolution2D._forwardGCCPU has cognitive complexity 422 (threshold 15). Drivers by points: loops 40 (258 pts), if/else 17 (157 pts), boolean chains 7 (nesting depth added 358). 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.
D2 · Cognitive Complexity · Convolution2D._forwardGCGPU (cognitive 374) · ×1
  • Convolution2D._forwardGCGPU (cognitive 374) Sources/GrAIdient/Layer2D/Convolution2D.swift:1038 — Convolution2D._forwardGCGPU has cognitive complexity 374 (threshold 15). Drivers by points: loops 40 (258 pts), if/else 13 (104 pts), boolean chains 12 (nesting depth added 309). 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.
D2 · Cognitive Complexity · Convolution2D._forwardGCCPU (cognitive 365) · ×1
  • Convolution2D._forwardGCCPU (cognitive 365) Sources/GrAIdient/Layer2D/Convolution2D.swift:842 — Convolution2D._forwardGCCPU has cognitive complexity 365 (threshold 15). Drivers by points: loops 40 (258 pts), if/else 13 (104 pts), boolean chains 3 (nesting depth added 309). 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.
D2 · Cognitive Complexity · FullyConnectedPatch._forwardGCCPU (cognitive 192) · ×1
  • FullyConnectedPatch._forwardGCCPU (cognitive 192) Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:527 — FullyConnectedPatch._forwardGCCPU has cognitive complexity 192 (threshold 15). Drivers by points: loops 26 (146 pts), if/else 8 (45 pts), boolean chains 1 (nesting depth added 157). 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. This shape REPEATS in the file: one other method here (FullyConnectedPatch._forwardGCGPU) 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.
D2 · Cognitive Complexity · FullyConnectedPatch._forwardGCGPU (cognitive 192) · ×1
  • FullyConnectedPatch._forwardGCGPU (cognitive 192) Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:687 — FullyConnectedPatch._forwardGCGPU has cognitive complexity 192 (threshold 15). Drivers by points: loops 26 (146 pts), if/else 8 (45 pts), boolean chains 1 (nesting depth added 157). 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. This shape REPEATS in the file: one other method here (FullyConnectedPatch._forwardGCCPU) 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.
D2 · Cognitive Complexity · FullyConnectedSeq._forwardGCCPU (cognitive 135) · ×1
  • FullyConnectedSeq._forwardGCCPU (cognitive 135) Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:501 — FullyConnectedSeq._forwardGCCPU has cognitive complexity 135 (threshold 15). Drivers by points: loops 20 (93 pts), if/else 8 (41 pts), boolean chains 1 (nesting depth added 106). 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. This shape REPEATS in the file: one other method here (FullyConnectedSeq._forwardGCGPU) 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.
D2 · Cognitive Complexity · FullyConnectedSeq._forwardGCGPU (cognitive 135) · ×1
  • FullyConnectedSeq._forwardGCGPU (cognitive 135) Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:627 — FullyConnectedSeq._forwardGCGPU has cognitive complexity 135 (threshold 15). Drivers by points: loops 20 (93 pts), if/else 8 (41 pts), boolean chains 1 (nesting depth added 106). 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. This shape REPEATS in the file: one other method here (FullyConnectedSeq._forwardGCCPU) 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.
D2 · Cognitive Complexity · AdaptiveAvgPool2D.forwardGCCPU (cognitive 127) · ×1
  • AdaptiveAvgPool2D.forwardGCCPU (cognitive 127) Sources/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:254 — AdaptiveAvgPool2D.forwardGCCPU has cognitive complexity 127 (threshold 15). Drivers by points: loops 22 (118 pts), if/else 6 (9 pts) (nesting depth added 99). 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.
D2 · Cognitive Complexity · FullyConnected._forwardGCCPU (cognitive 106) · ×1
  • FullyConnected._forwardGCCPU (cognitive 106) Sources/GrAIdient/Layer1D/FullyConnected.swift:634 — FullyConnected._forwardGCCPU has cognitive complexity 106 (threshold 15). Drivers by points: loops 16 (68 pts), if/else 8 (37 pts), boolean chains 1 (nesting depth added 81). 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. This shape REPEATS in the file: one other method here (FullyConnected._forwardGCGPU) 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.
D2 · Cognitive Complexity · FullyConnected._forwardGCGPU (cognitive 106) · ×1
  • FullyConnected._forwardGCGPU (cognitive 106) Sources/GrAIdient/Layer1D/FullyConnected.swift:745 — FullyConnected._forwardGCGPU has cognitive complexity 106 (threshold 15). Drivers by points: loops 16 (68 pts), if/else 8 (37 pts), boolean chains 1 (nesting depth added 81). 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. This shape REPEATS in the file: one other method here (FullyConnected._forwardGCCPU) 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.
D2 · Cognitive Complexity · AdaptiveAvgPool2D.forwardCPU (cognitive 106) · ×1
  • AdaptiveAvgPool2D.forwardCPU (cognitive 106) Sources/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:408 — AdaptiveAvgPool2D.forwardCPU has cognitive complexity 106 (threshold 15). Drivers by points: loops 20 (102 pts), if/else 3 (4 pts) (nesting depth added 83). 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.
D2 · Cognitive Complexity · AdaptiveAvgPool2D.backwardCPU (cognitive 91) · ×1
  • AdaptiveAvgPool2D.backwardCPU (cognitive 91) Sources/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:629 — AdaptiveAvgPool2D.backwardCPU has cognitive complexity 91 (threshold 15). Drivers by points: loops 16 (84 pts), if/else 4 (6 pts), boolean chains 1 (nesting depth added 70). 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.
D2 · Cognitive Complexity · Deconvolution2D._backwardWeightsCPU (cognitive 85) · ×1
  • Deconvolution2D._backwardWeightsCPU (cognitive 85) Sources/GrAIdient/Layer2D/Deconvolution2D.swift:812 — Deconvolution2D._backwardWeightsCPU has cognitive complexity 85 (threshold 15). Drivers by points: loops 10 (50 pts), if/else 6 (33 pts), boolean chains 2 (nesting depth added 67). 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.
D2 · Cognitive Complexity · QueryCausalSeq.forwardGCCPU (cognitive 80) · ×1
  • QueryCausalSeq.forwardGCCPU (cognitive 80) Sources/GrAIdient/LayerSeq/QuerySeq.swift:1350 — QueryCausalSeq.forwardGCCPU has cognitive complexity 80 (threshold 15). Drivers by points: loops 16 (55 pts), if/else 6 (25 pts) (nesting depth added 58). 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. This shape REPEATS in the file: one other method here (QueryCausalSeq.forwardGCGPU) 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.
D2 · Cognitive Complexity · QueryCausalSeq.forwardGCGPU (cognitive 80) · ×1
  • QueryCausalSeq.forwardGCGPU (cognitive 80) Sources/GrAIdient/LayerSeq/QuerySeq.swift:1473 — QueryCausalSeq.forwardGCGPU has cognitive complexity 80 (threshold 15). Drivers by points: loops 16 (55 pts), if/else 6 (25 pts) (nesting depth added 58). 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. This shape REPEATS in the file: one other method here (QueryCausalSeq.forwardGCCPU) 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.
D2 · Cognitive Complexity · LayerNormalization.forwardGC (cognitive 79) · ×1
  • LayerNormalization.forwardGC (cognitive 79) Sources/GrAIdient/Core/Layer/LayerNormalization.swift:2103 — LayerNormalization.forwardGC has cognitive complexity 79 (threshold 15). Drivers by points: if/else 15 (43 pts), loops 9 (35 pts), boolean chains 1 (nesting depth added 54). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · BCE2D.lossDerivativeCPU (cognitive 74) · ×1
  • BCE2D.lossDerivativeCPU (cognitive 74) Sources/GrAIdient/Layer2D/BCE2D.swift:332 — BCE2D.lossDerivativeCPU has cognitive complexity 74 (threshold 15). Drivers by points: loops 8 (36 pts), if/else 11 (35 pts), match/switch 1 (2 pts), boolean chains 1 (nesting depth added 53). 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.
D2 · Cognitive Complexity · Convolution2D._backwardWeightsCPU (cognitive 74) · ×1
  • Convolution2D._backwardWeightsCPU (cognitive 74) Sources/GrAIdient/Layer2D/Convolution2D.swift:1444 — Convolution2D._backwardWeightsCPU has cognitive complexity 74 (threshold 15). Drivers by points: loops 10 (50 pts), if/else 5 (23 pts), boolean chains 1 (nesting depth added 58). 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.
D2 · Cognitive Complexity · BCESigmoid2D.lossDerivativeCPU (cognitive 72) · ×1
  • BCESigmoid2D.lossDerivativeCPU (cognitive 72) Sources/GrAIdient/Layer2D/BCESigmoid2D.swift:375 — BCESigmoid2D.lossDerivativeCPU has cognitive complexity 72 (threshold 15). Drivers by points: loops 8 (36 pts), if/else 9 (33 pts), match/switch 1 (2 pts), boolean chains 1 (nesting depth added 53). 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.
D2 · Cognitive Complexity · Concat2D.forwardGCGPU (cognitive 66) · ×1
  • Concat2D.forwardGCGPU (cognitive 66) Sources/GrAIdient/Layer2D/Concat2D.swift:167 — Concat2D.forwardGCGPU has cognitive complexity 66 (threshold 15). Drivers by points: loops 18 (57 pts), if/else 2 (9 pts) (nesting depth added 46). 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.
D2 · Cognitive Complexity · Multiply2D.forwardGCGPU (cognitive 66) · ×1
  • Multiply2D.forwardGCGPU (cognitive 66) Sources/GrAIdient/Layer2D/Multiply2D.swift:253 — Multiply2D.forwardGCGPU has cognitive complexity 66 (threshold 15). Drivers by points: loops 18 (57 pts), if/else 2 (9 pts) (nesting depth added 46). 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.
D2 · Cognitive Complexity · Normalize122D.backwardCPU (cognitive 66) · ×1
  • Normalize122D.backwardCPU (cognitive 66) Sources/GrAIdient/Layer2D/Normalize2D.swift:624 — Normalize122D.backwardCPU has cognitive complexity 66 (threshold 15). Drivers by points: loops 10 (50 pts), if/else 5 (15 pts), boolean chains 1 (nesting depth added 50). 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.
D2 · Cognitive Complexity · Sum2D.forwardGCGPU (cognitive 66) · ×1
  • Sum2D.forwardGCGPU (cognitive 66) Sources/GrAIdient/Layer2D/Sum2D.swift:175 — Sum2D.forwardGCGPU has cognitive complexity 66 (threshold 15). Drivers by points: loops 18 (57 pts), if/else 2 (9 pts) (nesting depth added 46). 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.
D2 · Cognitive Complexity · FTFrequences2D.setDataCPU (cognitive 66) · ×1
  • FTFrequences2D.setDataCPU (cognitive 66) Sources/GrAIdient/Layer2D/Transform/FTFrequences2D.swift:135 — FTFrequences2D.setDataCPU has cognitive complexity 66 (threshold 15). Drivers by points: loops 14 (59 pts), if/else 2 (4 pts), ternaries 1 (3 pts) (nesting depth added 49). 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.
D2 · Cognitive Complexity · Concat2D.forwardGCCPU (cognitive 65) · ×1
  • Concat2D.forwardGCCPU (cognitive 65) Sources/GrAIdient/Layer2D/Concat2D.swift:80 — Concat2D.forwardGCCPU has cognitive complexity 65 (threshold 15). Drivers by points: loops 17 (56 pts), if/else 2 (9 pts) (nesting depth added 46). 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.
D2 · Cognitive Complexity · Multiply2D.forwardGCCPU (cognitive 65) · ×1
  • Multiply2D.forwardGCCPU (cognitive 65) Sources/GrAIdient/Layer2D/Multiply2D.swift:169 — Multiply2D.forwardGCCPU has cognitive complexity 65 (threshold 15). Drivers by points: loops 17 (56 pts), if/else 2 (9 pts) (nesting depth added 46). 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.
D2 · Cognitive Complexity · Sum2D.forwardGCCPU (cognitive 65) · ×1
  • Sum2D.forwardGCCPU (cognitive 65) Sources/GrAIdient/Layer2D/Sum2D.swift:91 — Sum2D.forwardGCCPU has cognitive complexity 65 (threshold 15). Drivers by points: loops 17 (56 pts), if/else 2 (9 pts) (nesting depth added 46). 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.
D2 · Cognitive Complexity · Convolution2D._backwardCPU (cognitive 64) · ×1
  • Convolution2D._backwardCPU (cognitive 64) Sources/GrAIdient/Layer2D/Convolution2D.swift:1394 — Convolution2D._backwardCPU has cognitive complexity 64 (threshold 15). Drivers by points: loops 7 (35 pts), if/else 5 (27 pts), boolean chains 2 (nesting depth added 50). 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.
D2 · Cognitive Complexity · QueryCausalSeq.backwardCPU (cognitive 64) · ×1
  • QueryCausalSeq.backwardCPU (cognitive 64) Sources/GrAIdient/LayerSeq/QuerySeq.swift:1895 — QueryCausalSeq.backwardCPU has cognitive complexity 64 (threshold 15). Drivers by points: loops 11 (47 pts), if/else 7 (17 pts) (nesting depth added 46). 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.
D2 · Cognitive Complexity · ValueSelfSeq.backwardCPU (cognitive 64) · ×1
  • ValueSelfSeq.backwardCPU (cognitive 64) Sources/GrAIdient/LayerSeq/ValueSeq.swift:974 — ValueSelfSeq.backwardCPU has cognitive complexity 64 (threshold 15). Drivers by points: loops 13 (52 pts), if/else 6 (12 pts) (nesting depth added 45). 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.
D2 · Cognitive Complexity · ValueCausalSeq.backwardCPU (cognitive 64) · ×1
  • ValueCausalSeq.backwardCPU (cognitive 64) Sources/GrAIdient/LayerSeq/ValueSeq.swift:1890 — ValueCausalSeq.backwardCPU has cognitive complexity 64 (threshold 15). Drivers by points: loops 11 (47 pts), if/else 7 (17 pts) (nesting depth added 46). 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.
D2 · Cognitive Complexity · QuerySeq.forwardGCCPU (cognitive 62) · ×1
  • QuerySeq.forwardGCCPU (cognitive 62) Sources/GrAIdient/LayerSeq/QuerySeq.swift:128 — QuerySeq.forwardGCCPU has cognitive complexity 62 (threshold 15). Drivers by points: loops 16 (53 pts), if/else 2 (9 pts) (nesting depth added 44). 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. This shape REPEATS in the file: one other method here (QuerySeq.forwardGCGPU) 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.
D2 · Cognitive Complexity · QuerySeq.forwardGCGPU (cognitive 62) · ×1
  • QuerySeq.forwardGCGPU (cognitive 62) Sources/GrAIdient/LayerSeq/QuerySeq.swift:219 — QuerySeq.forwardGCGPU has cognitive complexity 62 (threshold 15). Drivers by points: loops 16 (53 pts), if/else 2 (9 pts) (nesting depth added 44). 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. This shape REPEATS in the file: one other method here (QuerySeq.forwardGCCPU) 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.
D2 · Cognitive Complexity · ValueSeq.forwardGCCPU (cognitive 62) · ×1
  • ValueSeq.forwardGCCPU (cognitive 62) Sources/GrAIdient/LayerSeq/ValueSeq.swift:132 — ValueSeq.forwardGCCPU has cognitive complexity 62 (threshold 15). Drivers by points: loops 16 (53 pts), if/else 2 (9 pts) (nesting depth added 44). 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. This shape REPEATS in the file: 5 other methods here (ValueSeq.forwardGCGPU, ValueSelfSeq.forwardGCCPU, ValueSelfSeq.forwardGCGPU, …) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 6 times rather than 6 independent problems. Splitting this body alone leaves the other 5 exactly as they are. Where these are variations on one operation, the change that clears all 6 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.
D2 · Cognitive Complexity · ValueSeq.forwardGCGPU (cognitive 62) · ×1
  • ValueSeq.forwardGCGPU (cognitive 62) Sources/GrAIdient/LayerSeq/ValueSeq.swift:222 — ValueSeq.forwardGCGPU has cognitive complexity 62 (threshold 15). Drivers by points: loops 16 (53 pts), if/else 2 (9 pts) (nesting depth added 44). 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. This shape REPEATS in the file: 5 other methods here (ValueSeq.forwardGCCPU, ValueSelfSeq.forwardGCCPU, ValueSelfSeq.forwardGCGPU, …) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 6 times rather than 6 independent problems. Splitting this body alone leaves the other 5 exactly as they are. Where these are variations on one operation, the change that clears all 6 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.
D2 · Cognitive Complexity · ValueSelfSeq.forwardGCCPU (cognitive 62) · ×1
  • ValueSelfSeq.forwardGCCPU (cognitive 62) Sources/GrAIdient/LayerSeq/ValueSeq.swift:694 — ValueSelfSeq.forwardGCCPU has cognitive complexity 62 (threshold 15). Drivers by points: loops 16 (53 pts), if/else 2 (9 pts) (nesting depth added 44). 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. This shape REPEATS in the file: 5 other methods here (ValueSeq.forwardGCCPU, ValueSeq.forwardGCGPU, ValueSelfSeq.forwardGCGPU, …) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 6 times rather than 6 independent problems. Splitting this body alone leaves the other 5 exactly as they are. Where these are variations on one operation, the change that clears all 6 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.
D2 · Cognitive Complexity · ValueSelfSeq.forwardGCGPU (cognitive 62) · ×1
  • ValueSelfSeq.forwardGCGPU (cognitive 62) Sources/GrAIdient/LayerSeq/ValueSeq.swift:789 — ValueSelfSeq.forwardGCGPU has cognitive complexity 62 (threshold 15). Drivers by points: loops 16 (53 pts), if/else 2 (9 pts) (nesting depth added 44). 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. This shape REPEATS in the file: 5 other methods here (ValueSeq.forwardGCCPU, ValueSeq.forwardGCGPU, ValueSelfSeq.forwardGCCPU, …) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 6 times rather than 6 independent problems. Splitting this body alone leaves the other 5 exactly as they are. Where these are variations on one operation, the change that clears all 6 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.
D2 · Cognitive Complexity · ValueCausalSeq.forwardGCCPU (cognitive 62) · ×1
  • ValueCausalSeq.forwardGCCPU (cognitive 62) Sources/GrAIdient/LayerSeq/ValueSeq.swift:1400 — ValueCausalSeq.forwardGCCPU has cognitive complexity 62 (threshold 15). Drivers by points: loops 16 (53 pts), if/else 2 (9 pts) (nesting depth added 44). 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. This shape REPEATS in the file: 5 other methods here (ValueSeq.forwardGCCPU, ValueSeq.forwardGCGPU, ValueSelfSeq.forwardGCCPU, …) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 6 times rather than 6 independent problems. Splitting this body alone leaves the other 5 exactly as they are. Where these are variations on one operation, the change that clears all 6 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.
D2 · Cognitive Complexity · ValueCausalSeq.forwardGCGPU (cognitive 62) · ×1
  • ValueCausalSeq.forwardGCGPU (cognitive 62) Sources/GrAIdient/LayerSeq/ValueSeq.swift:1496 — ValueCausalSeq.forwardGCGPU has cognitive complexity 62 (threshold 15). Drivers by points: loops 16 (53 pts), if/else 2 (9 pts) (nesting depth added 44). 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. This shape REPEATS in the file: 5 other methods here (ValueSeq.forwardGCCPU, ValueSeq.forwardGCGPU, ValueSelfSeq.forwardGCCPU, …) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 6 times rather than 6 independent problems. Splitting this body alone leaves the other 5 exactly as they are. Where these are variations on one operation, the change that clears all 6 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.
D2 · Cognitive Complexity · VQGrad2D.forwardCPU (cognitive 58) · ×1
  • VQGrad2D.forwardCPU (cognitive 58) Sources/GrAIdient/Layer2D/VQ2D.swift:1182 — VQGrad2D.forwardCPU has cognitive complexity 58 (threshold 15). Drivers by points: loops 8 (35 pts), if/else 6 (22 pts), boolean chains 1 (nesting depth added 43). 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.
D2 · Cognitive Complexity · QuerySeq.backwardCPU (cognitive 57) · ×1
  • QuerySeq.backwardCPU (cognitive 57) Sources/GrAIdient/LayerSeq/QuerySeq.swift:392 — QuerySeq.backwardCPU has cognitive complexity 57 (threshold 15). Drivers by points: loops 10 (40 pts), if/else 7 (17 pts) (nesting depth added 40). 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.
D2 · Cognitive Complexity · ValueSeq.backwardCPU (cognitive 57) · ×1
  • ValueSeq.backwardCPU (cognitive 57) Sources/GrAIdient/LayerSeq/ValueSeq.swift:395 — ValueSeq.backwardCPU has cognitive complexity 57 (threshold 15). Drivers by points: loops 10 (40 pts), if/else 7 (17 pts) (nesting depth added 40). 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.
D2 · Cognitive Complexity · Deconvolution2D._forwardCPU (cognitive 56) · ×1
  • Deconvolution2D._forwardCPU (cognitive 56) Sources/GrAIdient/Layer2D/Deconvolution2D.swift:722 — Deconvolution2D._forwardCPU has cognitive complexity 56 (threshold 15). Drivers by points: loops 7 (35 pts), if/else 3 (20 pts), boolean chains 1 (nesting depth added 45). 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.
D2 · Cognitive Complexity · MSE2D.lossDerivativeCPU (cognitive 56) · ×1
  • MSE2D.lossDerivativeCPU (cognitive 56) Sources/GrAIdient/Layer2D/MSE2D.swift:328 — MSE2D.lossDerivativeCPU has cognitive complexity 56 (threshold 15). Drivers by points: loops 8 (36 pts), if/else 5 (17 pts), match/switch 1 (2 pts), boolean chains 1 (nesting depth added 41). 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.
D2 · Cognitive Complexity · QuerySelfSeq.backwardCPU (cognitive 56) · ×1
  • QuerySelfSeq.backwardCPU (cognitive 56) Sources/GrAIdient/LayerSeq/QuerySeq.swift:842 — QuerySelfSeq.backwardCPU has cognitive complexity 56 (threshold 15). Drivers by points: loops 10 (40 pts), if/else 5 (15 pts), boolean chains 1 (nesting depth added 40). 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.
D2 · Cognitive Complexity · MaxPool2D.forwardGCCPU (cognitive 55) · ×1
  • MaxPool2D.forwardGCCPU (cognitive 55) Sources/GrAIdient/Layer2D/MaxPool2D.swift:237 — MaxPool2D.forwardGCCPU has cognitive complexity 55 (threshold 15). Drivers by points: loops 10 (44 pts), if/else 2 (10 pts), boolean chains 1 (nesting depth added 42). 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.
D2 · Cognitive Complexity · Deconvolution2D._backwardCPU (cognitive 53) · ×1
  • Deconvolution2D._backwardCPU (cognitive 53) Sources/GrAIdient/Layer2D/Deconvolution2D.swift:766 — Deconvolution2D._backwardCPU has cognitive complexity 53 (threshold 15). Drivers by points: loops 7 (35 pts), if/else 4 (17 pts), boolean chains 1 (nesting depth added 41). 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.
D2 · Cognitive Complexity · SimilarityError2D.forwardGCGPU (cognitive 49) · ×1
  • SimilarityError2D.forwardGCGPU (cognitive 49) Sources/GrAIdient/Layer2D/SimilarityError2D.swift:255 — SimilarityError2D.forwardGCGPU has cognitive complexity 49 (threshold 15). Drivers by points: loops 15 (41 pts), if/else 2 (8 pts) (nesting depth added 32). 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.
D2 · Cognitive Complexity · Concat1Seq.forwardGCGPU (cognitive 49) · ×1
  • Concat1Seq.forwardGCGPU (cognitive 49) Sources/GrAIdient/LayerSeq/ConcatSeq.swift:163 — Concat1Seq.forwardGCGPU has cognitive complexity 49 (threshold 15). Drivers by points: loops 15 (41 pts), if/else 2 (8 pts) (nesting depth added 32). 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. This shape REPEATS in the file: one other method here (Concat2Seq.forwardGCGPU) 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.
D2 · Cognitive Complexity · Concat2Seq.forwardGCGPU (cognitive 49) · ×1
  • Concat2Seq.forwardGCGPU (cognitive 49) Sources/GrAIdient/LayerSeq/ConcatSeq.swift:595 — Concat2Seq.forwardGCGPU has cognitive complexity 49 (threshold 15). Drivers by points: loops 15 (41 pts), if/else 2 (8 pts) (nesting depth added 32). 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. This shape REPEATS in the file: one other method here (Concat1Seq.forwardGCGPU) 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.
D2 · Cognitive Complexity · MultiplySeq.forwardGCGPU (cognitive 49) · ×1
  • MultiplySeq.forwardGCGPU (cognitive 49) Sources/GrAIdient/LayerSeq/MutiplySeq.swift:238 — MultiplySeq.forwardGCGPU has cognitive complexity 49 (threshold 15). Drivers by points: loops 15 (41 pts), if/else 2 (8 pts) (nesting depth added 32). 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.
D2 · Cognitive Complexity · SumSeq.forwardGCGPU (cognitive 49) · ×1
  • SumSeq.forwardGCGPU (cognitive 49) Sources/GrAIdient/LayerSeq/SumSeq.swift:160 — SumSeq.forwardGCGPU has cognitive complexity 49 (threshold 15). Drivers by points: loops 15 (41 pts), if/else 2 (8 pts) (nesting depth added 32). 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.
D2 · Cognitive Complexity · SimilarityError2D.forwardGCCPU (cognitive 48) · ×1
  • SimilarityError2D.forwardGCCPU (cognitive 48) Sources/GrAIdient/Layer2D/SimilarityError2D.swift:171 — SimilarityError2D.forwardGCCPU has cognitive complexity 48 (threshold 15). Drivers by points: loops 14 (40 pts), if/else 2 (8 pts) (nesting depth added 32). 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.
D2 · Cognitive Complexity · Concat1Seq.forwardGCCPU (cognitive 48) · ×1
  • Concat1Seq.forwardGCCPU (cognitive 48) Sources/GrAIdient/LayerSeq/ConcatSeq.swift:82 — Concat1Seq.forwardGCCPU has cognitive complexity 48 (threshold 15). Drivers by points: loops 14 (40 pts), if/else 2 (8 pts) (nesting depth added 32). 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. This shape REPEATS in the file: one other method here (Concat2Seq.forwardGCCPU) 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.
D2 · Cognitive Complexity · Concat2Seq.forwardGCCPU (cognitive 48) · ×1
  • Concat2Seq.forwardGCCPU (cognitive 48) Sources/GrAIdient/LayerSeq/ConcatSeq.swift:514 — Concat2Seq.forwardGCCPU has cognitive complexity 48 (threshold 15). Drivers by points: loops 14 (40 pts), if/else 2 (8 pts) (nesting depth added 32). 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. This shape REPEATS in the file: one other method here (Concat1Seq.forwardGCCPU) 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.
D2 · Cognitive Complexity · MultiplySeq.forwardGCCPU (cognitive 48) · ×1
  • MultiplySeq.forwardGCCPU (cognitive 48) Sources/GrAIdient/LayerSeq/MutiplySeq.swift:168 — MultiplySeq.forwardGCCPU has cognitive complexity 48 (threshold 15). Drivers by points: loops 14 (40 pts), if/else 2 (8 pts) (nesting depth added 32). 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.
D2 · Cognitive Complexity · SumSeq.forwardGCCPU (cognitive 48) · ×1
  • SumSeq.forwardGCCPU (cognitive 48) Sources/GrAIdient/LayerSeq/SumSeq.swift:90 — SumSeq.forwardGCCPU has cognitive complexity 48 (threshold 15). Drivers by points: loops 14 (40 pts), if/else 2 (8 pts) (nesting depth added 32). 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.
D2 · Cognitive Complexity · Convolution2D._forwardCPU (cognitive 45) · ×1
  • Convolution2D._forwardCPU (cognitive 45) Sources/GrAIdient/Layer2D/Convolution2D.swift:1275 — Convolution2D._forwardCPU has cognitive complexity 45 (threshold 15). Drivers by points: loops 7 (35 pts), if/else 2 (10 pts) (nesting depth added 36). 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.
D2 · Cognitive Complexity · MaxPool2D.forwardCPU (cognitive 45) · ×1
  • MaxPool2D.forwardCPU (cognitive 45) Sources/GrAIdient/Layer2D/MaxPool2D.swift:298 — MaxPool2D.forwardCPU has cognitive complexity 45 (threshold 15). Drivers by points: loops 6 (27 pts), if/else 4 (16 pts), boolean chains 2 (nesting depth added 33). 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.
D2 · Cognitive Complexity · Normalize122D.forwardGCCPU (cognitive 45) · ×1
  • Normalize122D.forwardGCCPU (cognitive 45) Sources/GrAIdient/Layer2D/Normalize2D.swift:438 — Normalize122D.forwardGCCPU has cognitive complexity 45 (threshold 15). Drivers by points: loops 11 (44 pts), if/else 1 (nesting depth added 33). 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.
D2 · Cognitive Complexity · SoftmaxSeq.forwardGCCPU (cognitive 45) · ×1
  • SoftmaxSeq.forwardGCCPU (cognitive 45) Sources/GrAIdient/LayerSeq/SoftmaxSeq.swift:121 — SoftmaxSeq.forwardGCCPU has cognitive complexity 45 (threshold 15). Drivers by points: loops 9 (37 pts), if/else 2 (8 pts) (nesting depth added 34). 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.
D2 · Cognitive Complexity · IRDFT2RGB.forwardGCCPU (cognitive 45) · ×1
  • IRDFT2RGB.forwardGCCPU (cognitive 45) Sources/GrAIdient/Layer2D/Transform/IRDFT2RGB.swift:90 — IRDFT2RGB.forwardGCCPU has cognitive complexity 45 (threshold 15). Drivers by points: loops 10 (44 pts), if/else 1 (nesting depth added 34). 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.
D2 · Cognitive Complexity · Rotate2D.backwardCPU (cognitive 45) · ×1
  • Rotate2D.backwardCPU (cognitive 45) Sources/GrAIdient/Layer2D/Transform/Rotate2D.swift:395 — Rotate2D.backwardCPU has cognitive complexity 45 (threshold 15). Drivers by points: loops 8 (32 pts), if/else 3 (9 pts), boolean chains 4 (nesting depth added 30). 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.
D2 · Cognitive Complexity · VQGradSeq.forwardCPU (cognitive 44) · ×1
  • VQGradSeq.forwardCPU (cognitive 44) Sources/GrAIdient/LayerSeq/VQSeq.swift:1102 — VQGradSeq.forwardCPU has cognitive complexity 44 (threshold 15). Drivers by points: loops 6 (24 pts), if/else 6 (19 pts), boolean chains 1 (nesting depth added 31). 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.
D2 · Cognitive Complexity · BCESigmoid2D.getLossGC (cognitive 43) · ×1
  • BCESigmoid2D.getLossGC (cognitive 43) Sources/GrAIdient/Layer2D/BCESigmoid2D.swift:104 — BCESigmoid2D.getLossGC has cognitive complexity 43 (threshold 15). Drivers by points: loops 8 (28 pts), if/else 4 (14 pts), match/switch 1 (nesting depth added 30). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident. This shape REPEATS in the file: one other method here (BCESigmoid2D.getLossCPU) 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.
D2 · Cognitive Complexity · BCESigmoid2D.getLossCPU (cognitive 43) · ×1
  • BCESigmoid2D.getLossCPU (cognitive 43) Sources/GrAIdient/Layer2D/BCESigmoid2D.swift:195 — BCESigmoid2D.getLossCPU has cognitive complexity 43 (threshold 15). Drivers by points: loops 8 (28 pts), if/else 4 (14 pts), match/switch 1 (nesting depth added 30). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident. This shape REPEATS in the file: one other method here (BCESigmoid2D.getLossGC) 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.
D2 · Cognitive Complexity · BN2D._forwardGCCPU (cognitive 43) · ×1
  • BN2D._forwardGCCPU (cognitive 43) Sources/GrAIdient/Layer2D/BN2D.swift:452 — BN2D._forwardGCCPU has cognitive complexity 43 (threshold 15). Drivers by points: loops 11 (42 pts), if/else 1 (nesting depth added 31). 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. This shape REPEATS in the file: one other method here (BN2D._forwardGCGPU) 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.
D2 · Cognitive Complexity · BN2D._forwardGCGPU (cognitive 43) · ×1
  • BN2D._forwardGCGPU (cognitive 43) Sources/GrAIdient/Layer2D/BN2D.swift:510 — BN2D._forwardGCGPU has cognitive complexity 43 (threshold 15). Drivers by points: loops 11 (42 pts), if/else 1 (nesting depth added 31). 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. This shape REPEATS in the file: one other method here (BN2D._forwardGCCPU) 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.
D2 · Cognitive Complexity · Constant2D.forwardGCCPU (cognitive 43) · ×1
  • Constant2D.forwardGCCPU (cognitive 43) Sources/GrAIdient/Layer2D/Constant2D.swift:351 — Constant2D.forwardGCCPU has cognitive complexity 43 (threshold 15). Drivers by points: loops 9 (27 pts), if/else 3 (16 pts) (nesting depth added 31). 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. This shape REPEATS in the file: one other method here (Constant2D.forwardGCGPU) 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.
D2 · Cognitive Complexity · Constant2D.forwardGCGPU (cognitive 43) · ×1
  • Constant2D.forwardGCGPU (cognitive 43) Sources/GrAIdient/Layer2D/Constant2D.swift:395 — Constant2D.forwardGCGPU has cognitive complexity 43 (threshold 15). Drivers by points: loops 9 (27 pts), if/else 3 (16 pts) (nesting depth added 31). 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. This shape REPEATS in the file: one other method here (Constant2D.forwardGCCPU) 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.
D2 · Cognitive Complexity · InstanceNorm2D._forwardGCCPU (cognitive 43) · ×1
  • InstanceNorm2D._forwardGCCPU (cognitive 43) Sources/GrAIdient/Layer2D/InstanceNorm2D.swift:376 — InstanceNorm2D._forwardGCCPU has cognitive complexity 43 (threshold 15). Drivers by points: loops 11 (42 pts), if/else 1 (nesting depth added 31). 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. This shape REPEATS in the file: one other method here (InstanceNorm2D._forwardGCGPU) 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.
D2 · Cognitive Complexity · InstanceNorm2D._forwardGCGPU (cognitive 43) · ×1
  • InstanceNorm2D._forwardGCGPU (cognitive 43) Sources/GrAIdient/Layer2D/InstanceNorm2D.swift:434 — InstanceNorm2D._forwardGCGPU has cognitive complexity 43 (threshold 15). Drivers by points: loops 11 (42 pts), if/else 1 (nesting depth added 31). 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. This shape REPEATS in the file: one other method here (InstanceNorm2D._forwardGCCPU) 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.
D2 · Cognitive Complexity · Multiply2D.forwardCPU (cognitive 43) · ×1
  • Multiply2D.forwardCPU (cognitive 43) Sources/GrAIdient/Layer2D/Multiply2D.swift:347 — Multiply2D.forwardCPU has cognitive complexity 43 (threshold 15). Drivers by points: loops 7 (28 pts), if/else 2 (13 pts), boolean chains 2 (nesting depth added 32). 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.
D2 · Cognitive Complexity · Normalize12D.backwardCPU (cognitive 42) · ×1
  • Normalize12D.backwardCPU (cognitive 42) Sources/GrAIdient/Layer2D/Normalize2D.swift:207 — Normalize12D.backwardCPU has cognitive complexity 42 (threshold 15). Drivers by points: loops 6 (26 pts), if/else 5 (15 pts), boolean chains 1 (nesting depth added 30). 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.
D2 · Cognitive Complexity · Constant12Seq.forwardGCCPU (cognitive 41) · ×1
  • Constant12Seq.forwardGCCPU (cognitive 41) Sources/GrAIdient/LayerSeq/ConstantSeq.swift:275 — Constant12Seq.forwardGCCPU has cognitive complexity 41 (threshold 15). Drivers by points: loops 8 (24 pts), if/else 3 (16 pts), boolean chains 1 (nesting depth added 29). 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. This shape REPEATS in the file: one other method here (Constant12Seq.forwardGCGPU) 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.
D2 · Cognitive Complexity · Constant12Seq.forwardGCGPU (cognitive 41) · ×1
  • Constant12Seq.forwardGCGPU (cognitive 41) Sources/GrAIdient/LayerSeq/ConstantSeq.swift:320 — Constant12Seq.forwardGCGPU has cognitive complexity 41 (threshold 15). Drivers by points: loops 8 (24 pts), if/else 3 (16 pts), boolean chains 1 (nesting depth added 29). 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. This shape REPEATS in the file: one other method here (Constant12Seq.forwardGCCPU) 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.
D2 · Cognitive Complexity · EmbeddingSeq.forwardGCCPU (cognitive 41) · ×1
  • EmbeddingSeq.forwardGCCPU (cognitive 41) Sources/GrAIdient/LayerSeq/EmbeddingSeq.swift:465 — EmbeddingSeq.forwardGCCPU has cognitive complexity 41 (threshold 15). Drivers by points: loops 8 (24 pts), if/else 3 (16 pts), boolean chains 1 (nesting depth added 29). 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. This shape REPEATS in the file: one other method here (EmbeddingSeq.forwardGCGPU) 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.
D2 · Cognitive Complexity · EmbeddingSeq.forwardGCGPU (cognitive 41) · ×1
  • EmbeddingSeq.forwardGCGPU (cognitive 41) Sources/GrAIdient/LayerSeq/EmbeddingSeq.swift:511 — EmbeddingSeq.forwardGCGPU has cognitive complexity 41 (threshold 15). Drivers by points: loops 8 (24 pts), if/else 3 (16 pts), boolean chains 1 (nesting depth added 29). 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. This shape REPEATS in the file: one other method here (EmbeddingSeq.forwardGCCPU) 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.
D2 · Cognitive Complexity · MetalKernel.get (cognitive 41) · ×1
  • MetalKernel.get (cognitive 41) Sources/GrAIdient/Metal/MetalKernel.swift:23 — MetalKernel.get has cognitive complexity 41 (threshold 15). Drivers by points: if/else 10 (28 pts), loops 4 (13 pts) (nesting depth added 27). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Pad2D.forwardGCCPU (cognitive 41) · ×1
  • Pad2D.forwardGCCPU (cognitive 41) Sources/GrAIdient/Layer2D/Transform/Pad2D.swift:127 — Pad2D.forwardGCCPU has cognitive complexity 41 (threshold 15). Drivers by points: loops 8 (29 pts), if/else 3 (9 pts), boolean chains 3 (nesting depth added 27). 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.
D2 · Cognitive Complexity · ResizeBilinearPad.forwardGCCPU (cognitive 41) · ×1
  • ResizeBilinearPad.forwardGCCPU (cognitive 41) Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift:269 — ResizeBilinearPad.forwardGCCPU has cognitive complexity 41 (threshold 15). Drivers by points: loops 8 (29 pts), if/else 3 (9 pts), boolean chains 3 (nesting depth added 27). 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.
D2 · Cognitive Complexity · Rotate2D.forwardGCCPU (cognitive 41) · ×1
  • Rotate2D.forwardGCCPU (cognitive 41) Sources/GrAIdient/Layer2D/Transform/Rotate2D.swift:214 — Rotate2D.forwardGCCPU has cognitive complexity 41 (threshold 15). Drivers by points: loops 8 (29 pts), if/else 3 (9 pts), boolean chains 3 (nesting depth added 27). 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.
D2 · Cognitive Complexity · RMSNormalization.forwardGC (cognitive 40) · ×1
  • RMSNormalization.forwardGC (cognitive 40) Sources/GrAIdient/Core/Layer/LayerNormalization.swift:2791 — RMSNormalization.forwardGC has cognitive complexity 40 (threshold 15). Drivers by points: if/else 8 (23 pts), loops 5 (17 pts) (nesting depth added 27). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ResizeBilinearCrop.forwardCPU (cognitive 40) · ×1
  • ResizeBilinearCrop.forwardCPU (cognitive 40) Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:386 — ResizeBilinearCrop.forwardCPU has cognitive complexity 40 (threshold 15). Drivers by points: if/else 13 (21 pts), loops 4 (14 pts), boolean chains 5 (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · VQ2D.forwardCPU (cognitive 38) · ×1
  • VQ2D.forwardCPU (cognitive 38) Sources/GrAIdient/Layer2D/VQ2D.swift:457 — VQ2D.forwardCPU has cognitive complexity 38 (threshold 15). Drivers by points: loops 6 (25 pts), if/else 3 (12 pts), boolean chains 1 (nesting depth added 28). 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.
D2 · Cognitive Complexity · FullyConnectedPatch._backwardWeightsCPU (cognitive 38) · ×1
  • FullyConnectedPatch._backwardWeightsCPU (cognitive 38) Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:1011 — FullyConnectedPatch._backwardWeightsCPU has cognitive complexity 38 (threshold 15). Drivers by points: loops 7 (26 pts), if/else 4 (11 pts), boolean chains 1 (nesting depth added 26). 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.
D2 · Cognitive Complexity · FullyConnectedSeq._backwardWeightsCPU (cognitive 38) · ×1
  • FullyConnectedSeq._backwardWeightsCPU (cognitive 38) Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:898 — FullyConnectedSeq._backwardWeightsCPU has cognitive complexity 38 (threshold 15). Drivers by points: loops 7 (26 pts), if/else 4 (11 pts), boolean chains 1 (nesting depth added 26). 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.
D2 · Cognitive Complexity · FlipHorizontal2D.forwardGCCPU (cognitive 38) · ×1
  • FlipHorizontal2D.forwardGCCPU (cognitive 38) Sources/GrAIdient/Layer2D/Transform/Flip2D.swift:130 — FlipHorizontal2D.forwardGCCPU has cognitive complexity 38 (threshold 15). Drivers by points: loops 8 (29 pts), if/else 3 (9 pts) (nesting depth added 27). 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. This shape REPEATS in the file: one other method here (FlipVertical2D.forwardGCCPU) 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.
D2 · Cognitive Complexity · FlipVertical2D.forwardGCCPU (cognitive 38) · ×1
  • FlipVertical2D.forwardGCCPU (cognitive 38) Sources/GrAIdient/Layer2D/Transform/Flip2D.swift:387 — FlipVertical2D.forwardGCCPU has cognitive complexity 38 (threshold 15). Drivers by points: loops 8 (29 pts), if/else 3 (9 pts) (nesting depth added 27). 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. This shape REPEATS in the file: one other method here (FlipHorizontal2D.forwardGCCPU) 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.
D2 · Cognitive Complexity · VQ2D._backwardCPU (cognitive 37) · ×1
  • VQ2D._backwardCPU (cognitive 37) Sources/GrAIdient/Layer2D/VQ2D.swift:548 — VQ2D._backwardCPU has cognitive complexity 37 (threshold 15). Drivers by points: loops 5 (21 pts), if/else 5 (15 pts), boolean chains 1 (nesting depth added 26). 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.
D2 · Cognitive Complexity · LayerOutput2D.checkGroundTruthGPU (cognitive 37) · ×1
  • LayerOutput2D.checkGroundTruthGPU (cognitive 37) Sources/GrAIdient/Layer2D/Base/LayerOutput2D.swift:140 — LayerOutput2D.checkGroundTruthGPU has cognitive complexity 37 (threshold 15). Drivers by points: loops 8 (28 pts), boolean chains 4, if/else 4, match/switch 1 (nesting depth added 20). 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.
D2 · Cognitive Complexity · DecorrelateRGB.forwardGCCPU (cognitive 37) · ×1
  • DecorrelateRGB.forwardGCCPU (cognitive 37) Sources/GrAIdient/Layer2D/Transform/DecorrelateRGB.swift:123 — DecorrelateRGB.forwardGCCPU has cognitive complexity 37 (threshold 15). Drivers by points: loops 9 (36 pts), if/else 1 (nesting depth added 27). 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.
D2 · Cognitive Complexity · MaxPool2D.backwardCPU (cognitive 36) · ×1
  • MaxPool2D.backwardCPU (cognitive 36) Sources/GrAIdient/Layer2D/MaxPool2D.swift:395 — MaxPool2D.backwardCPU has cognitive complexity 36 (threshold 15). Drivers by points: loops 8 (32 pts), if/else 2 (3 pts), boolean chains 1 (nesting depth added 25). 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.
D2 · Cognitive Complexity · Normalize12D.forwardGCCPU (cognitive 36) · ×1
  • Normalize12D.forwardGCCPU (cognitive 36) Sources/GrAIdient/Layer2D/Normalize2D.swift:81 — Normalize12D.forwardGCCPU has cognitive complexity 36 (threshold 15). Drivers by points: loops 9 (35 pts), if/else 1 (nesting depth added 26). 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.
D2 · Cognitive Complexity · IRDFT2RGB.backwardCPU (cognitive 36) · ×1
  • IRDFT2RGB.backwardCPU (cognitive 36) Sources/GrAIdient/Layer2D/Transform/IRDFT2RGB.swift:220 — IRDFT2RGB.backwardCPU has cognitive complexity 36 (threshold 15). Drivers by points: loops 6 (27 pts), if/else 3 (8 pts), boolean chains 1 (nesting depth added 26). 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.
D2 · Cognitive Complexity · ResizeBilinearCrop.backwardCPU (cognitive 36) · ×1
  • ResizeBilinearCrop.backwardCPU (cognitive 36) Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:604 — ResizeBilinearCrop.backwardCPU has cognitive complexity 36 (threshold 15). Drivers by points: loops 8 (32 pts), if/else 2 (3 pts), boolean chains 1 (nesting depth added 25). 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.
D2 · Cognitive Complexity · ResizeBilinearPad.backwardCPU (cognitive 36) · ×1
  • ResizeBilinearPad.backwardCPU (cognitive 36) Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift:530 — ResizeBilinearPad.backwardCPU has cognitive complexity 36 (threshold 15). Drivers by points: loops 8 (32 pts), if/else 2 (3 pts), boolean chains 1 (nesting depth added 25). 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.
D2 · Cognitive Complexity · Concat1D.forwardGCGPU (cognitive 35) · ×1
  • Concat1D.forwardGCGPU (cognitive 35) Sources/GrAIdient/Layer1D/Concat1D.swift:145 — Concat1D.forwardGCGPU has cognitive complexity 35 (threshold 15). Drivers by points: loops 12 (28 pts), if/else 2 (7 pts) (nesting depth added 21). 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.
D2 · Cognitive Complexity · Sum1D.forwardGCGPU (cognitive 35) · ×1
  • Sum1D.forwardGCGPU (cognitive 35) Sources/GrAIdient/Layer1D/Sum1D.swift:154 — Sum1D.forwardGCGPU has cognitive complexity 35 (threshold 15). Drivers by points: loops 12 (28 pts), if/else 2 (7 pts) (nesting depth added 21). 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.
D2 · Cognitive Complexity · SelfCorrelate2D.backwardCPU (cognitive 35) · ×1
  • SelfCorrelate2D.backwardCPU (cognitive 35) Sources/GrAIdient/Layer2D/SelfCorrelate2D.swift:206 — SelfCorrelate2D.backwardCPU has cognitive complexity 35 (threshold 15). Drivers by points: loops 6 (26 pts), if/else 3 (8 pts), boolean chains 1 (nesting depth added 25). 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.
D2 · Cognitive Complexity · Concat1D.forwardGCCPU (cognitive 34) · ×1
  • Concat1D.forwardGCCPU (cognitive 34) Sources/GrAIdient/Layer1D/Concat1D.swift:70 — Concat1D.forwardGCCPU has cognitive complexity 34 (threshold 15). Drivers by points: loops 11 (27 pts), if/else 2 (7 pts) (nesting depth added 21). 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.
D2 · Cognitive Complexity · DotProduct1D.forwardGCCPU (cognitive 34) · ×1
  • DotProduct1D.forwardGCCPU (cognitive 34) Sources/GrAIdient/Layer1D/DotProduct1D.swift:120 — DotProduct1D.forwardGCCPU has cognitive complexity 34 (threshold 15). Drivers by points: loops 11 (27 pts), if/else 2 (7 pts) (nesting depth added 21). 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. This shape REPEATS in the file: one other method here (DotProduct1D.forwardGCGPU) 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.
D2 · Cognitive Complexity · DotProduct1D.forwardGCGPU (cognitive 34) · ×1
  • DotProduct1D.forwardGCGPU (cognitive 34) Sources/GrAIdient/Layer1D/DotProduct1D.swift:200 — DotProduct1D.forwardGCGPU has cognitive complexity 34 (threshold 15). Drivers by points: loops 11 (27 pts), if/else 2 (7 pts) (nesting depth added 21). 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. This shape REPEATS in the file: one other method here (DotProduct1D.forwardGCCPU) 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.
D2 · Cognitive Complexity · Sum1D.forwardGCCPU (cognitive 34) · ×1
  • Sum1D.forwardGCCPU (cognitive 34) Sources/GrAIdient/Layer1D/Sum1D.swift:87 — Sum1D.forwardGCCPU has cognitive complexity 34 (threshold 15). Drivers by points: loops 11 (27 pts), if/else 2 (7 pts) (nesting depth added 21). 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.
D2 · Cognitive Complexity · LayerNormSeq._forwardGCCPU (cognitive 34) · ×1
  • LayerNormSeq._forwardGCCPU (cognitive 34) Sources/GrAIdient/LayerSeq/LayerNormSeq.swift:375 — LayerNormSeq._forwardGCCPU has cognitive complexity 34 (threshold 15). Drivers by points: loops 10 (33 pts), if/else 1 (nesting depth added 23). 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. This shape REPEATS in the file: one other method here (LayerNormSeq._forwardGCGPU) 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.
D2 · Cognitive Complexity · LayerNormSeq._forwardGCGPU (cognitive 34) · ×1
  • LayerNormSeq._forwardGCGPU (cognitive 34) Sources/GrAIdient/LayerSeq/LayerNormSeq.swift:434 — LayerNormSeq._forwardGCGPU has cognitive complexity 34 (threshold 15). Drivers by points: loops 10 (33 pts), if/else 1 (nesting depth added 23). 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. This shape REPEATS in the file: one other method here (LayerNormSeq._forwardGCCPU) 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.
D2 · Cognitive Complexity · MultiplySeq.forwardCPU (cognitive 34) · ×1
  • MultiplySeq.forwardCPU (cognitive 34) Sources/GrAIdient/LayerSeq/MutiplySeq.swift:318 — MultiplySeq.forwardCPU has cognitive complexity 34 (threshold 15). Drivers by points: loops 6 (21 pts), if/else 2 (11 pts), boolean chains 2 (nesting depth added 24). 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.
D2 · Cognitive Complexity · RMSNormSeq._forwardGCCPU (cognitive 34) · ×1
  • RMSNormSeq._forwardGCCPU (cognitive 34) Sources/GrAIdient/LayerSeq/RMSNormSeq.swift:389 — RMSNormSeq._forwardGCCPU has cognitive complexity 34 (threshold 15). Drivers by points: loops 10 (33 pts), if/else 1 (nesting depth added 23). 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. This shape REPEATS in the file: one other method here (RMSNormSeq._forwardGCGPU) 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.
D2 · Cognitive Complexity · RMSNormSeq._forwardGCGPU (cognitive 34) · ×1
  • RMSNormSeq._forwardGCGPU (cognitive 34) Sources/GrAIdient/LayerSeq/RMSNormSeq.swift:448 — RMSNormSeq._forwardGCGPU has cognitive complexity 34 (threshold 15). Drivers by points: loops 10 (33 pts), if/else 1 (nesting depth added 23). 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. This shape REPEATS in the file: one other method here (RMSNormSeq._forwardGCCPU) 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.
D2 · Cognitive Complexity · ColorJitterHSV.forwardCPU (cognitive 34) · ×1
  • ColorJitterHSV.forwardCPU (cognitive 34) Sources/GrAIdient/Layer2D/Transform/ColorJitterHSV.swift:205 — ColorJitterHSV.forwardCPU has cognitive complexity 34 (threshold 15). Drivers by points: if/else 8 (20 pts), loops 3 (9 pts), match/switch 1 (5 pts) (nesting depth added 22). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Softmax1D.forwardGCCPU (cognitive 33) · ×1
  • Softmax1D.forwardGCCPU (cognitive 33) Sources/GrAIdient/Layer1D/Softmax1D.swift:119 — Softmax1D.forwardGCCPU has cognitive complexity 33 (threshold 15). Drivers by points: loops 7 (26 pts), if/else 2 (7 pts) (nesting depth added 24). 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.
D2 · Cognitive Complexity · SelfCorrelate2D.forwardGCCPU (cognitive 33) · ×1
  • SelfCorrelate2D.forwardGCCPU (cognitive 33) Sources/GrAIdient/Layer2D/SelfCorrelate2D.swift:79 — SelfCorrelate2D.forwardGCCPU has cognitive complexity 33 (threshold 15). Drivers by points: loops 8 (32 pts), if/else 1 (nesting depth added 24). 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.
D2 · Cognitive Complexity · QuerySelfSeq.forwardGCCPU (cognitive 33) · ×1
  • QuerySelfSeq.forwardGCCPU (cognitive 33) Sources/GrAIdient/LayerSeq/QuerySeq.swift:697 — QuerySelfSeq.forwardGCCPU has cognitive complexity 33 (threshold 15). Drivers by points: loops 8 (32 pts), if/else 1 (nesting depth added 24). 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.
D2 · Cognitive Complexity · LayerInput2D.checkInputCPU (cognitive 33) · ×1
  • LayerInput2D.checkInputCPU (cognitive 33) Sources/GrAIdient/Layer2D/Base/LayerInput2D.swift:55 — LayerInput2D.checkInputCPU has cognitive complexity 33 (threshold 15). Drivers by points: loops 8 (28 pts), boolean chains 2, if/else 2, match/switch 1 (nesting depth added 20). 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. This shape REPEATS in the file: one other method here (LayerInput2D.checkInputGPU) 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.
D2 · Cognitive Complexity · LayerInput2D.checkInputGPU (cognitive 33) · ×1
  • LayerInput2D.checkInputGPU (cognitive 33) Sources/GrAIdient/Layer2D/Base/LayerInput2D.swift:121 — LayerInput2D.checkInputGPU has cognitive complexity 33 (threshold 15). Drivers by points: loops 8 (28 pts), boolean chains 2, if/else 2, match/switch 1 (nesting depth added 20). 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. This shape REPEATS in the file: one other method here (LayerInput2D.checkInputCPU) 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.
D2 · Cognitive Complexity · Constant2Seq.forwardGCCPU (cognitive 32) · ×1
  • Constant2Seq.forwardGCCPU (cognitive 32) Sources/GrAIdient/LayerSeq/ConstantSeq.swift:780 — Constant2Seq.forwardGCCPU has cognitive complexity 32 (threshold 15). Drivers by points: loops 7 (18 pts), if/else 3 (14 pts) (nesting depth added 22). 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. This shape REPEATS in the file: one other method here (Constant2Seq.forwardGCGPU) 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.
D2 · Cognitive Complexity · Constant2Seq.forwardGCGPU (cognitive 32) · ×1
  • Constant2Seq.forwardGCGPU (cognitive 32) Sources/GrAIdient/LayerSeq/ConstantSeq.swift:824 — Constant2Seq.forwardGCGPU has cognitive complexity 32 (threshold 15). Drivers by points: loops 7 (18 pts), if/else 3 (14 pts) (nesting depth added 22). 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. This shape REPEATS in the file: one other method here (Constant2Seq.forwardGCCPU) 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.
D2 · Cognitive Complexity · VQ2D._backwardWeightsCPU (cognitive 31) · ×1
  • VQ2D._backwardWeightsCPU (cognitive 31) Sources/GrAIdient/Layer2D/VQ2D.swift:593 — VQ2D._backwardWeightsCPU has cognitive complexity 31 (threshold 15). Drivers by points: loops 6 (22 pts), if/else 3 (8 pts), boolean chains 1 (nesting depth added 21). 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.
D2 · Cognitive Complexity · SoftmaxSeq.forwardCPU (cognitive 31) · ×1
  • SoftmaxSeq.forwardCPU (cognitive 31) Sources/GrAIdient/LayerSeq/SoftmaxSeq.swift:192 — SoftmaxSeq.forwardCPU has cognitive complexity 31 (threshold 15). Drivers by points: loops 6 (24 pts), if/else 2 (7 pts) (nesting depth added 23). 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.
D2 · Cognitive Complexity · Crop2D.backwardCPU (cognitive 31) · ×1
  • Crop2D.backwardCPU (cognitive 31) Sources/GrAIdient/Layer2D/Transform/Crop2D.swift:324 — Crop2D.backwardCPU has cognitive complexity 31 (threshold 15). Drivers by points: loops 4 (14 pts), if/else 4 (9 pts), boolean chains 8 (nesting depth added 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.
D2 · Cognitive Complexity · ResizeBilinearPad.forwardCPU (cognitive 31) · ×1
  • ResizeBilinearPad.forwardCPU (cognitive 31) Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift:363 — ResizeBilinearPad.forwardCPU has cognitive complexity 31 (threshold 15). Drivers by points: loops 4 (14 pts), if/else 6 (12 pts), boolean chains 5 (nesting depth added 16). 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.
D2 · Cognitive Complexity · Rotate2D.forwardCPU (cognitive 31) · ×1
  • Rotate2D.forwardCPU (cognitive 31) Sources/GrAIdient/Layer2D/Transform/Rotate2D.swift:284 — Rotate2D.forwardCPU has cognitive complexity 31 (threshold 15). Drivers by points: loops 4 (14 pts), if/else 6 (12 pts), boolean chains 5 (nesting depth added 16). 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.
D2 · Cognitive Complexity · SimilarityError2D.lossDerivativeCPU (cognitive 30) · ×1
  • SimilarityError2D.lossDerivativeCPU (cognitive 30) Sources/GrAIdient/Layer2D/SimilarityError2D.swift:648 — SimilarityError2D.lossDerivativeCPU has cognitive complexity 30 (threshold 15). Drivers by points: if/else 5 (15 pts), loops 5 (15 pts) (nesting depth added 20). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LayerOutput2D.forwardGCCPU (cognitive 30) · ×1
  • LayerOutput2D.forwardGCCPU (cognitive 30) Sources/GrAIdient/Layer2D/Base/LayerOutput2D.swift:270 — LayerOutput2D.forwardGCCPU has cognitive complexity 30 (threshold 15). Drivers by points: loops 8 (29 pts), if/else 1 (nesting depth added 21). 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.
D2 · Cognitive Complexity · Crop2D.forwardGCCPU (cognitive 30) · ×1
  • Crop2D.forwardGCCPU (cognitive 30) Sources/GrAIdient/Layer2D/Transform/Crop2D.swift:204 — Crop2D.forwardGCCPU has cognitive complexity 30 (threshold 15). Drivers by points: loops 8 (29 pts), if/else 1 (nesting depth added 21). 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.
D2 · Cognitive Complexity · FlipHorizontal2D.backwardCPU (cognitive 30) · ×1
  • FlipHorizontal2D.backwardCPU (cognitive 30) Sources/GrAIdient/Layer2D/Transform/Flip2D.swift:257 — FlipHorizontal2D.backwardCPU has cognitive complexity 30 (threshold 15). Drivers by points: if/else 5 (15 pts), loops 4 (14 pts), boolean chains 1 (nesting depth added 20). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: one other method here (FlipVertical2D.backwardCPU) 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.
D2 · Cognitive Complexity · FlipVertical2D.backwardCPU (cognitive 30) · ×1
  • FlipVertical2D.backwardCPU (cognitive 30) Sources/GrAIdient/Layer2D/Transform/Flip2D.swift:468 — FlipVertical2D.backwardCPU has cognitive complexity 30 (threshold 15). Drivers by points: if/else 5 (15 pts), loops 4 (14 pts), boolean chains 1 (nesting depth added 20). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: one other method here (FlipHorizontal2D.backwardCPU) 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.
D2 · Cognitive Complexity · LinearScale2D.forwardGCCPU (cognitive 30) · ×1
  • LinearScale2D.forwardGCCPU (cognitive 30) Sources/GrAIdient/Layer2D/Transform/LinearScale2D.swift:118 — LinearScale2D.forwardGCCPU has cognitive complexity 30 (threshold 15). Drivers by points: loops 8 (29 pts), if/else 1 (nesting depth added 21). 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.
D2 · Cognitive Complexity · ResizeBilinearCrop.forwardGCCPU (cognitive 30) · ×1
  • ResizeBilinearCrop.forwardGCCPU (cognitive 30) Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:306 — ResizeBilinearCrop.forwardGCCPU has cognitive complexity 30 (threshold 15). Drivers by points: loops 8 (29 pts), if/else 1 (nesting depth added 21). 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.
D2 · Cognitive Complexity · AdaIN.forwardGCCPU (cognitive 29) · ×1
  • AdaIN.forwardGCCPU (cognitive 29) Sources/GrAIdient/Layer2D/AdaIN.swift:247 — AdaIN.forwardGCCPU has cognitive complexity 29 (threshold 15). Drivers by points: loops 11 (23 pts), if/else 2 (6 pts) (nesting depth added 16). 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. This shape REPEATS in the file: one other method here (AdaIN.forwardGCGPU) 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.
D2 · Cognitive Complexity · AdaIN.forwardGCGPU (cognitive 29) · ×1
  • AdaIN.forwardGCGPU (cognitive 29) Sources/GrAIdient/Layer2D/AdaIN.swift:359 — AdaIN.forwardGCGPU has cognitive complexity 29 (threshold 15). Drivers by points: loops 11 (23 pts), if/else 2 (6 pts) (nesting depth added 16). 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. This shape REPEATS in the file: one other method here (AdaIN.forwardGCCPU) 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.
D2 · Cognitive Complexity · BCE2D.getLossGC (cognitive 29) · ×1
  • BCE2D.getLossGC (cognitive 29) Sources/GrAIdient/Layer2D/BCE2D.swift:101 — BCE2D.getLossGC has cognitive complexity 29 (threshold 15). Drivers by points: loops 8 (28 pts), match/switch 1 (nesting depth added 20). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident. This shape REPEATS in the file: one other method here (BCE2D.getLossCPU) 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.
D2 · Cognitive Complexity · BCE2D.getLossCPU (cognitive 29) · ×1
  • BCE2D.getLossCPU (cognitive 29) Sources/GrAIdient/Layer2D/BCE2D.swift:172 — BCE2D.getLossCPU has cognitive complexity 29 (threshold 15). Drivers by points: loops 8 (28 pts), match/switch 1 (nesting depth added 20). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident. This shape REPEATS in the file: one other method here (BCE2D.getLossGC) 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.
D2 · Cognitive Complexity · MSE2D.getLossGC (cognitive 29) · ×1
  • MSE2D.getLossGC (cognitive 29) Sources/GrAIdient/Layer2D/MSE2D.swift:99 — MSE2D.getLossGC has cognitive complexity 29 (threshold 15). Drivers by points: loops 8 (28 pts), match/switch 1 (nesting depth added 20). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident. This shape REPEATS in the file: one other method here (MSE2D.getLossCPU) 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.
D2 · Cognitive Complexity · MSE2D.getLossCPU (cognitive 29) · ×1
  • MSE2D.getLossCPU (cognitive 29) Sources/GrAIdient/Layer2D/MSE2D.swift:170 — MSE2D.getLossCPU has cognitive complexity 29 (threshold 15). Drivers by points: loops 8 (28 pts), match/switch 1 (nesting depth added 20). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident. This shape REPEATS in the file: one other method here (MSE2D.getLossGC) 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.
D2 · Cognitive Complexity · SoftmaxSeq.backwardCPU (cognitive 29) · ×1
  • SoftmaxSeq.backwardCPU (cognitive 29) Sources/GrAIdient/LayerSeq/SoftmaxSeq.swift:273 — SoftmaxSeq.backwardCPU has cognitive complexity 29 (threshold 15). Drivers by points: loops 5 (20 pts), if/else 3 (8 pts), boolean chains 1 (nesting depth added 20). 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.
D2 · Cognitive Complexity · VQSeq.forwardCPU (cognitive 29) · ×1
  • VQSeq.forwardCPU (cognitive 29) Sources/GrAIdient/LayerSeq/VQSeq.swift:386 — VQSeq.forwardCPU has cognitive complexity 29 (threshold 15). Drivers by points: loops 5 (18 pts), if/else 3 (10 pts), boolean chains 1 (nesting depth added 20). 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.
D2 · Cognitive Complexity · VQSeq._backwardCPU (cognitive 29) · ×1
  • VQSeq._backwardCPU (cognitive 29) Sources/GrAIdient/LayerSeq/VQSeq.swift:476 — VQSeq._backwardCPU has cognitive complexity 29 (threshold 15). Drivers by points: loops 4 (15 pts), if/else 5 (13 pts), boolean chains 1 (nesting depth added 19). 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.
D2 · Cognitive Complexity · DecorrelateRGB.backwardCPU (cognitive 29) · ×1
  • DecorrelateRGB.backwardCPU (cognitive 29) Sources/GrAIdient/Layer2D/Transform/DecorrelateRGB.swift:246 — DecorrelateRGB.backwardCPU has cognitive complexity 29 (threshold 15). Drivers by points: loops 5 (20 pts), if/else 3 (8 pts), boolean chains 1 (nesting depth added 20). 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.
D2 · Cognitive Complexity · SimilarityBatchError2D.lossDerivativeCPU (cognitive 28) · ×1
  • SimilarityBatchError2D.lossDerivativeCPU (cognitive 28) Sources/GrAIdient/Layer2D/SimilarityBatchError2D.swift:283 — SimilarityBatchError2D.lossDerivativeCPU has cognitive complexity 28 (threshold 15). Drivers by points: loops 4 (14 pts), if/else 4 (13 pts), boolean chains 1 (nesting depth added 19). 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.
D2 · Cognitive Complexity · FullyConnectedPatch._forwardCPU (cognitive 28) · ×1
  • FullyConnectedPatch._forwardCPU (cognitive 28) Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:865 — FullyConnectedPatch._forwardCPU has cognitive complexity 28 (threshold 15). Drivers by points: loops 6 (27 pts), if/else 1 (nesting depth added 21). 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.
D2 · Cognitive Complexity · IRDFT2RGB.forwardCPU (cognitive 28) · ×1
  • IRDFT2RGB.forwardCPU (cognitive 28) Sources/GrAIdient/Layer2D/Transform/IRDFT2RGB.swift:153 — IRDFT2RGB.forwardCPU has cognitive complexity 28 (threshold 15). Drivers by points: loops 6 (27 pts), if/else 1 (nesting depth added 21). 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.
D2 · Cognitive Complexity · FullyConnected._backwardWeightsCPU (cognitive 27) · ×1
  • FullyConnected._backwardWeightsCPU (cognitive 27) Sources/GrAIdient/Layer1D/FullyConnected.swift:967 — FullyConnected._backwardWeightsCPU has cognitive complexity 27 (threshold 15). Drivers by points: loops 5 (16 pts), if/else 4 (11 pts) (nesting depth added 18). 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.
D2 · Cognitive Complexity · Convolution2D._backwardWeightsGPU (cognitive 27) · ×1
  • Convolution2D._backwardWeightsGPU (cognitive 27) Sources/GrAIdient/Layer2D/Convolution2D.swift:1582 — Convolution2D._backwardWeightsGPU has cognitive complexity 27 (threshold 15). Drivers by points: if/else 8 (17 pts), boolean chains 8, ternaries 1 (2 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LayerCAM2D.forwardCPU (cognitive 27) · ×1
  • LayerCAM2D.forwardCPU (cognitive 27) Sources/GrAIdient/Layer2D/LayerCAM2D.swift:129 — LayerCAM2D.forwardCPU has cognitive complexity 27 (threshold 15). Drivers by points: loops 4 (14 pts), if/else 3 (13 pts) (nesting depth added 20). 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.
D2 · Cognitive Complexity · Normalize122D.forwardCPU (cognitive 27) · ×1
  • Normalize122D.forwardCPU (cognitive 27) Sources/GrAIdient/Layer2D/Normalize2D.swift:500 — Normalize122D.forwardCPU has cognitive complexity 27 (threshold 15). Drivers by points: loops 7 (26 pts), if/else 1 (nesting depth added 19). 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.
D2 · Cognitive Complexity · SelectNeurons2D.backwardCPU (cognitive 27) · ×1
  • SelectNeurons2D.backwardCPU (cognitive 27) Sources/GrAIdient/Layer2D/SelectNeurons2D.swift:290 — SelectNeurons2D.backwardCPU has cognitive complexity 27 (threshold 15). Drivers by points: loops 6 (23 pts), if/else 2 (3 pts), boolean chains 1 (nesting depth added 18). 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.
D2 · Cognitive Complexity · Concat2D.backwardCPU (cognitive 26) · ×1
  • Concat2D.backwardCPU (cognitive 26) Sources/GrAIdient/Layer2D/Concat2D.swift:337 — Concat2D.backwardCPU has cognitive complexity 26 (threshold 15). Drivers by points: loops 5 (15 pts), if/else 4 (11 pts) (nesting depth added 17). 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.
D2 · Cognitive Complexity · FullyConnectedSeq._backwardWeightsGPU (cognitive 26) · ×1
  • FullyConnectedSeq._backwardWeightsGPU (cognitive 26) Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:1018 — FullyConnectedSeq._backwardWeightsGPU has cognitive complexity 26 (threshold 15). Drivers by points: if/else 6 (13 pts), ternaries 4 (12 pts), boolean chains 1 (nesting depth added 15). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · RoPESeq.forwardGCCPU (cognitive 26) · ×1
  • RoPESeq.forwardGCCPU (cognitive 26) Sources/GrAIdient/LayerSeq/RoPESeq.swift:239 — RoPESeq.forwardGCCPU has cognitive complexity 26 (threshold 15). Drivers by points: loops 7 (25 pts), if/else 1 (nesting depth added 18). 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.
D2 · Cognitive Complexity · ResizeBilinearCrop.forwardGPU (cognitive 26) · ×1
  • ResizeBilinearCrop.forwardGPU (cognitive 26) Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:502 — ResizeBilinearCrop.forwardGPU has cognitive complexity 26 (threshold 15). Drivers by points: if/else 13 (21 pts), boolean chains 5 (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.
D2 · Cognitive Complexity · Multiply2D.backwardCPU (cognitive 25) · ×1
  • Multiply2D.backwardCPU (cognitive 25) Sources/GrAIdient/Layer2D/Multiply2D.swift:460 — Multiply2D.backwardCPU has cognitive complexity 25 (threshold 15). Drivers by points: loops 5 (15 pts), if/else 4 (10 pts) (nesting depth added 16). 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.
D2 · Cognitive Complexity · Sum2D.backwardCPU (cognitive 25) · ×1
  • Sum2D.backwardCPU (cognitive 25) Sources/GrAIdient/Layer2D/Sum2D.swift:334 — Sum2D.backwardCPU has cognitive complexity 25 (threshold 15). Drivers by points: loops 5 (15 pts), if/else 4 (10 pts) (nesting depth added 16). 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.
D2 · Cognitive Complexity · VQSeq._backwardWeightsCPU (cognitive 25) · ×1
  • VQSeq._backwardWeightsCPU (cognitive 25) Sources/GrAIdient/LayerSeq/VQSeq.swift:518 — VQSeq._backwardWeightsCPU has cognitive complexity 25 (threshold 15). Drivers by points: loops 5 (17 pts), if/else 3 (7 pts), boolean chains 1 (nesting depth added 16). 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.
D2 · Cognitive Complexity · Pad2D.forwardCPU (cognitive 25) · ×1
  • Pad2D.forwardCPU (cognitive 25) Sources/GrAIdient/Layer2D/Transform/Pad2D.swift:187 — Pad2D.forwardCPU has cognitive complexity 25 (threshold 15). Drivers by points: loops 4 (14 pts), if/else 3 (8 pts), boolean chains 3 (nesting depth added 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.
D2 · Cognitive Complexity · Dropout1D.forwardCPU (cognitive 24) · ×1
  • Dropout1D.forwardCPU (cognitive 24) Sources/GrAIdient/Layer1D/Dropout1D.swift:254 — Dropout1D.forwardCPU has cognitive complexity 24 (threshold 15). Drivers by points: if/else 6 (12 pts), loops 4 (10 pts), boolean chains 2 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · FullyConnectedPatch._backwardWeightsGPU (cognitive 24) · ×1
  • FullyConnectedPatch._backwardWeightsGPU (cognitive 24) Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:1128 — FullyConnectedPatch._backwardWeightsGPU has cognitive complexity 24 (threshold 15). Drivers by points: if/else 6 (13 pts), ternaries 3 (10 pts), boolean chains 1 (nesting depth added 14). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · Constant1D.forwardGCCPU (cognitive 23) · ×1
  • Constant1D.forwardGCCPU (cognitive 23) Sources/GrAIdient/Layer1D/Constant1D.swift:293 — Constant1D.forwardGCCPU has cognitive complexity 23 (threshold 15). Drivers by points: if/else 3 (12 pts), loops 5 (11 pts) (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: one other method here (Constant1D.forwardGCGPU) 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.
D2 · Cognitive Complexity · Constant1D.forwardGCGPU (cognitive 23) · ×1
  • Constant1D.forwardGCGPU (cognitive 23) Sources/GrAIdient/Layer1D/Constant1D.swift:333 — Constant1D.forwardGCGPU has cognitive complexity 23 (threshold 15). Drivers by points: if/else 3 (12 pts), loops 5 (11 pts) (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: one other method here (Constant1D.forwardGCCPU) 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.
D2 · Cognitive Complexity · Softmax1D.forwardCPU (cognitive 23) · ×1
  • Softmax1D.forwardCPU (cognitive 23) Sources/GrAIdient/Layer1D/Softmax1D.swift:186 — Softmax1D.forwardCPU has cognitive complexity 23 (threshold 15). Drivers by points: loops 5 (17 pts), if/else 2 (6 pts) (nesting depth added 16). 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.
D2 · Cognitive Complexity · Activation2D._forwardGC (cognitive 23) · ×1
  • Activation2D._forwardGC (cognitive 23) Sources/GrAIdient/Layer2D/Activation2D.swift:185 — Activation2D._forwardGC has cognitive complexity 23 (threshold 15). Drivers by points: loops 6 (22 pts), if/else 1 (nesting depth added 16). 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.
D2 · Cognitive Complexity · Activation2D.backwardCPU (cognitive 23) · ×1
  • Activation2D.backwardCPU (cognitive 23) Sources/GrAIdient/Layer2D/Activation2D.swift:281 — Activation2D.backwardCPU has cognitive complexity 23 (threshold 15). Drivers by points: loops 4 (14 pts), if/else 3 (8 pts), boolean chains 1 (nesting depth added 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.
D2 · Cognitive Complexity · AvgPool2D.forwardGCCPU (cognitive 23) · ×1
  • AvgPool2D.forwardGCCPU (cognitive 23) Sources/GrAIdient/Layer2D/AvgPool2D.swift:73 — AvgPool2D.forwardGCCPU has cognitive complexity 23 (threshold 15). Drivers by points: loops 6 (22 pts), if/else 1 (nesting depth added 16). 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.
D2 · Cognitive Complexity · AvgPool2D.backwardCPU (cognitive 23) · ×1
  • AvgPool2D.backwardCPU (cognitive 23) Sources/GrAIdient/Layer2D/AvgPool2D.swift:190 — AvgPool2D.backwardCPU has cognitive complexity 23 (threshold 15). Drivers by points: loops 4 (14 pts), if/else 3 (8 pts), boolean chains 1 (nesting depth added 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.
D2 · Cognitive Complexity · BN2D.backwardCPU (cognitive 23) · ×1
  • BN2D.backwardCPU (cognitive 23) Sources/GrAIdient/Layer2D/BN2D.swift:620 — BN2D.backwardCPU has cognitive complexity 23 (threshold 15). Drivers by points: loops 4 (14 pts), if/else 3 (8 pts), boolean chains 1 (nesting depth added 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.
D2 · Cognitive Complexity · Input2D.backwardCPU (cognitive 23) · ×1
  • Input2D.backwardCPU (cognitive 23) Sources/GrAIdient/Layer2D/Input2D.swift:468 — Input2D.backwardCPU has cognitive complexity 23 (threshold 15). Drivers by points: loops 4 (14 pts), if/else 3 (8 pts), boolean chains 1 (nesting depth added 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.
D2 · Cognitive Complexity · InstanceNorm2D.backwardCPU (cognitive 23) · ×1
  • InstanceNorm2D.backwardCPU (cognitive 23) Sources/GrAIdient/Layer2D/InstanceNorm2D.swift:544 — InstanceNorm2D.backwardCPU has cognitive complexity 23 (threshold 15). Drivers by points: loops 4 (14 pts), if/else 3 (8 pts), boolean chains 1 (nesting depth added 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.
D2 · Cognitive Complexity · RoPESeq.backwardCPU (cognitive 23) · ×1
  • RoPESeq.backwardCPU (cognitive 23) Sources/GrAIdient/LayerSeq/RoPESeq.swift:385 — RoPESeq.backwardCPU has cognitive complexity 23 (threshold 15). Drivers by points: loops 4 (14 pts), if/else 3 (8 pts), boolean chains 1 (nesting depth added 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.
D2 · Cognitive Complexity · LayerOutput2D.backwardCPU (cognitive 23) · ×1
  • LayerOutput2D.backwardCPU (cognitive 23) Sources/GrAIdient/Layer2D/Base/LayerOutput2D.swift:368 — LayerOutput2D.backwardCPU has cognitive complexity 23 (threshold 15). Drivers by points: loops 4 (14 pts), if/else 3 (8 pts), boolean chains 1 (nesting depth added 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.
D2 · Cognitive Complexity · LinearScale2D.backwardCPU (cognitive 23) · ×1
  • LinearScale2D.backwardCPU (cognitive 23) Sources/GrAIdient/Layer2D/Transform/LinearScale2D.swift:224 — LinearScale2D.backwardCPU has cognitive complexity 23 (threshold 15). Drivers by points: loops 4 (14 pts), if/else 3 (8 pts), boolean chains 1 (nesting depth added 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.
D2 · Cognitive Complexity · Pad2D.backwardCPU (cognitive 23) · ×1
  • Pad2D.backwardCPU (cognitive 23) Sources/GrAIdient/Layer2D/Transform/Pad2D.swift:254 — Pad2D.backwardCPU has cognitive complexity 23 (threshold 15). Drivers by points: loops 4 (14 pts), if/else 3 (8 pts), boolean chains 1 (nesting depth added 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.
D2 · Cognitive Complexity · Softmax1D.backwardCPU (cognitive 22) · ×1
  • Softmax1D.backwardCPU (cognitive 22) Sources/GrAIdient/Layer1D/Softmax1D.swift:258 — Softmax1D.backwardCPU has cognitive complexity 22 (threshold 15). Drivers by points: loops 4 (14 pts), if/else 3 (7 pts), boolean chains 1 (nesting depth added 14). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D2 · Cognitive Complexity · FullyConnectedPatch._backwardCPU (cognitive 22) · ×1
  • FullyConnectedPatch._backwardCPU (cognitive 22) Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:962 — FullyConnectedPatch._backwardCPU has cognitive complexity 22 (threshold 15). Drivers by points: loops 4 (14 pts), if/else 3 (7 pts), boolean chains 1 (nesting depth added 14). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D2 · Cognitive Complexity · FullyConnectedSeq._backwardCPU (cognitive 22) · ×1
  • FullyConnectedSeq._backwardCPU (cognitive 22) Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:864 — FullyConnectedSeq._backwardCPU has cognitive complexity 22 (threshold 15). Drivers by points: loops 4 (14 pts), if/else 3 (7 pts), boolean chains 1 (nesting depth added 14). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D2 · Cognitive Complexity · FlipHorizontal2D.forwardCPU (cognitive 22) · ×1
  • FlipHorizontal2D.forwardCPU (cognitive 22) Sources/GrAIdient/Layer2D/Transform/Flip2D.swift:189 — FlipHorizontal2D.forwardCPU has cognitive complexity 22 (threshold 15). Drivers by points: loops 4 (14 pts), if/else 3 (8 pts) (nesting depth added 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. This shape REPEATS in the file: one other method here (FlipVertical2D.forwardCPU) 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.
D2 · Cognitive Complexity · FlipVertical2D.forwardCPU (cognitive 22) · ×1
  • FlipVertical2D.forwardCPU (cognitive 22) Sources/GrAIdient/Layer2D/Transform/Flip2D.swift:436 — FlipVertical2D.forwardCPU has cognitive complexity 22 (threshold 15). Drivers by points: loops 4 (14 pts), if/else 3 (8 pts) (nesting depth added 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. This shape REPEATS in the file: one other method here (FlipHorizontal2D.forwardCPU) 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.
D2 · Cognitive Complexity · BCE1D.lossDerivativeCPU (cognitive 21) · ×1
  • BCE1D.lossDerivativeCPU (cognitive 21) Sources/GrAIdient/Layer1D/BCE1D.swift:261 — BCE1D.lossDerivativeCPU has cognitive complexity 21 (threshold 15). Drivers by points: if/else 7 (15 pts), loops 2 (5 pts), boolean chains 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Dropout1D.forwardGCCPU (cognitive 21) · ×1
  • Dropout1D.forwardGCCPU (cognitive 21) Sources/GrAIdient/Layer1D/Dropout1D.swift:162 — Dropout1D.forwardGCCPU has cognitive complexity 21 (threshold 15). Drivers by points: loops 4 (11 pts), if/else 4 (8 pts), boolean chains 2 (nesting depth added 11). 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. This shape REPEATS in the file: one other method here (Dropout1D.forwardGCGPU) 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.
D2 · Cognitive Complexity · Dropout1D.forwardGCGPU (cognitive 21) · ×1
  • Dropout1D.forwardGCGPU (cognitive 21) Sources/GrAIdient/Layer1D/Dropout1D.swift:208 — Dropout1D.forwardGCGPU has cognitive complexity 21 (threshold 15). Drivers by points: loops 4 (11 pts), if/else 4 (8 pts), boolean chains 2 (nesting depth added 11). 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. This shape REPEATS in the file: one other method here (Dropout1D.forwardGCCPU) 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.
D2 · Cognitive Complexity · Multiply2D.forwardGPU (cognitive 21) · ×1
  • Multiply2D.forwardGPU (cognitive 21) Sources/GrAIdient/Layer2D/Multiply2D.swift:393 — Multiply2D.forwardGPU has cognitive complexity 21 (threshold 15). Drivers by points: if/else 6 (15 pts), loops 2 (4 pts), boolean chains 2 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SelfCorrelate2D.forwardCPU (cognitive 21) · ×1
  • SelfCorrelate2D.forwardCPU (cognitive 21) Sources/GrAIdient/Layer2D/SelfCorrelate2D.swift:137 — SelfCorrelate2D.forwardCPU has cognitive complexity 21 (threshold 15). Drivers by points: loops 5 (20 pts), if/else 1 (nesting depth added 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.
D2 · Cognitive Complexity · VQ2D.getLossCPU (cognitive 21) · ×1
  • VQ2D.getLossCPU (cognitive 21) Sources/GrAIdient/Layer2D/VQ2D.swift:789 — VQ2D.getLossCPU has cognitive complexity 21 (threshold 15). Drivers by points: loops 4 (15 pts), if/else 2 (6 pts) (nesting depth added 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.
D2 · Cognitive Complexity · Concat1Seq.backwardCPU (cognitive 21) · ×1
  • Concat1Seq.backwardCPU (cognitive 21) Sources/GrAIdient/LayerSeq/ConcatSeq.swift:330 — Concat1Seq.backwardCPU has cognitive complexity 21 (threshold 15). Drivers by points: if/else 4 (11 pts), loops 4 (10 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: one other method here (Concat2Seq.backwardCPU) 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.
D2 · Cognitive Complexity · Concat2Seq.backwardCPU (cognitive 21) · ×1
  • Concat2Seq.backwardCPU (cognitive 21) Sources/GrAIdient/LayerSeq/ConcatSeq.swift:757 — Concat2Seq.backwardCPU has cognitive complexity 21 (threshold 15). Drivers by points: if/else 4 (11 pts), loops 4 (10 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: one other method here (Concat1Seq.backwardCPU) 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.
D2 · Cognitive Complexity · MultiplySeq.forwardGPU (cognitive 21) · ×1
  • MultiplySeq.forwardGPU (cognitive 21) Sources/GrAIdient/LayerSeq/MutiplySeq.swift:358 — MultiplySeq.forwardGPU has cognitive complexity 21 (threshold 15). Drivers by points: if/else 6 (15 pts), loops 2 (4 pts), boolean chains 2 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · QuerySelfSeq.forwardCPU (cognitive 21) · ×1
  • QuerySelfSeq.forwardCPU (cognitive 21) Sources/GrAIdient/LayerSeq/QuerySeq.swift:758 — QuerySelfSeq.forwardCPU has cognitive complexity 21 (threshold 15). Drivers by points: loops 5 (20 pts), if/else 1 (nesting depth added 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.
D2 · Cognitive Complexity · SelectSeq.backwardCPU (cognitive 21) · ×1
  • SelectSeq.backwardCPU (cognitive 21) Sources/GrAIdient/LayerSeq/SelectSeq.swift:203 — SelectSeq.backwardCPU has cognitive complexity 21 (threshold 15). Drivers by points: loops 5 (17 pts), if/else 2 (3 pts), boolean chains 1 (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.
D2 · Cognitive Complexity · InstanceNormalization.forwardGC (cognitive 21) · ×1
  • InstanceNormalization.forwardGC (cognitive 21) Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1231 — InstanceNormalization.forwardGC has cognitive complexity 21 (threshold 15). Drivers by points: if/else 7 (15 pts), boolean chains 3, loops 2 (3 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Model.synchronizeWeights (cognitive 21) · ×1
  • Model.synchronizeWeights (cognitive 21) Sources/GrAIdient/Core/Model/Model.swift:1121 — Model.synchronizeWeights has cognitive complexity 21 (threshold 15). Drivers by points: loops 7 (15 pts), if/else 2 (6 pts) (nesting depth added 12). 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.
D2 · Cognitive Complexity · DecorrelateRGB.forwardCPU (cognitive 21) · ×1
  • DecorrelateRGB.forwardCPU (cognitive 21) Sources/GrAIdient/Layer2D/Transform/DecorrelateRGB.swift:182 — DecorrelateRGB.forwardCPU has cognitive complexity 21 (threshold 15). Drivers by points: loops 5 (20 pts), if/else 1 (nesting depth added 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.
D2 · Cognitive Complexity · BCESigmoid1D.lossDerivativeCPU (cognitive 20) · ×1
  • BCESigmoid1D.lossDerivativeCPU (cognitive 20) Sources/GrAIdient/Layer1D/BCESigmoid1D.swift:284 — BCESigmoid1D.lossDerivativeCPU has cognitive complexity 20 (threshold 15). Drivers by points: if/else 6 (14 pts), loops 2 (5 pts), boolean chains 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Dropout1D.backwardCPU (cognitive 20) · ×1
  • Dropout1D.backwardCPU (cognitive 20) Sources/GrAIdient/Layer1D/Dropout1D.swift:358 — Dropout1D.backwardCPU has cognitive complexity 20 (threshold 15). Drivers by points: if/else 6 (12 pts), loops 2 (5 pts), boolean chains 3 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Normalize12D.forwardCPU (cognitive 20) · ×1
  • Normalize12D.forwardCPU (cognitive 20) Sources/GrAIdient/Layer2D/Normalize2D.swift:143 — Normalize12D.forwardCPU has cognitive complexity 20 (threshold 15). Drivers by points: loops 5 (19 pts), if/else 1 (nesting depth added 14). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D2 · Cognitive Complexity · ActivationSeq._forwardGC (cognitive 20) · ×1
  • ActivationSeq._forwardGC (cognitive 20) Sources/GrAIdient/LayerSeq/ActivationSeq.swift:182 — ActivationSeq._forwardGC has cognitive complexity 20 (threshold 15). Drivers by points: loops 6 (19 pts), if/else 1 (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.
D2 · Cognitive Complexity · LayerCAMSeq.forwardCPU (cognitive 20) · ×1
  • LayerCAMSeq.forwardCPU (cognitive 20) Sources/GrAIdient/LayerSeq/LayerCAMSeq.swift:128 — LayerCAMSeq.forwardCPU has cognitive complexity 20 (threshold 15). Drivers by points: if/else 3 (11 pts), loops 3 (9 pts) (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · OptimizerAlgorithm.clipGradientCPU (cognitive 20) · ×1
  • OptimizerAlgorithm.clipGradientCPU (cognitive 20) Sources/GrAIdient/Core/Optimizer/OptimizerAlgorithm.swift:405 — OptimizerAlgorithm.clipGradientCPU has cognitive complexity 20 (threshold 15). Drivers by points: loops 3 (11 pts), if/else 3 (8 pts), boolean chains 1 (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.
D2 · Cognitive Complexity · DotProduct1D.backwardCPU (cognitive 19) · ×1
  • DotProduct1D.backwardCPU (cognitive 19) Sources/GrAIdient/Layer1D/DotProduct1D.swift:343 — DotProduct1D.backwardCPU has cognitive complexity 19 (threshold 15). Drivers by points: if/else 5 (11 pts), loops 3 (6 pts), boolean chains 2 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SimilarityError2D.backwardCPU (cognitive 19) · ×1
  • SimilarityError2D.backwardCPU (cognitive 19) Sources/GrAIdient/Layer2D/SimilarityError2D.swift:415 — SimilarityError2D.backwardCPU has cognitive complexity 19 (threshold 15). Drivers by points: loops 4 (10 pts), if/else 4 (9 pts) (nesting depth added 11). 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.
D2 · Cognitive Complexity · MultiplySeq.backwardCPU (cognitive 19) · ×1
  • MultiplySeq.backwardCPU (cognitive 19) Sources/GrAIdient/LayerSeq/MutiplySeq.swift:425 — MultiplySeq.backwardCPU has cognitive complexity 19 (threshold 15). Drivers by points: loops 4 (10 pts), if/else 4 (9 pts) (nesting depth added 11). 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.
D2 · Cognitive Complexity · SumSeq.backwardCPU (cognitive 19) · ×1
  • SumSeq.backwardCPU (cognitive 19) Sources/GrAIdient/LayerSeq/SumSeq.swift:300 — SumSeq.backwardCPU has cognitive complexity 19 (threshold 15). Drivers by points: loops 4 (10 pts), if/else 4 (9 pts) (nesting depth added 11). 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.
D2 · Cognitive Complexity · Constant2D.backwardCPU (cognitive 18) · ×1
  • Constant2D.backwardCPU (cognitive 18) Sources/GrAIdient/Layer2D/Constant2D.swift:484 — Constant2D.backwardCPU has cognitive complexity 18 (threshold 15). Drivers by points: loops 4 (14 pts), if/else 2 (4 pts) (nesting depth added 12). 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.
D2 · Cognitive Complexity · Dropout1D.forwardGPU (cognitive 17) · ×1
  • Dropout1D.forwardGPU (cognitive 17) Sources/GrAIdient/Layer1D/Dropout1D.swift:307 — Dropout1D.forwardGPU has cognitive complexity 17 (threshold 15). Drivers by points: if/else 4 (9 pts), loops 2 (7 pts), boolean chains 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ActivationSeq.backwardCPU (cognitive 17) · ×1
  • ActivationSeq.backwardCPU (cognitive 17) Sources/GrAIdient/LayerSeq/ActivationSeq.swift:279 — ActivationSeq.backwardCPU has cognitive complexity 17 (threshold 15). Drivers by points: loops 3 (9 pts), if/else 3 (7 pts), boolean chains 1 (nesting depth added 10). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D2 · Cognitive Complexity · AvgPoolSeq.forwardGCCPU (cognitive 17) · ×1
  • AvgPoolSeq.forwardGCCPU (cognitive 17) Sources/GrAIdient/LayerSeq/AvgPoolSeq.swift:73 — AvgPoolSeq.forwardGCCPU has cognitive complexity 17 (threshold 15). Drivers by points: loops 5 (16 pts), if/else 1 (nesting depth added 11). 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.
D2 · Cognitive Complexity · AvgPoolSeq.backwardCPU (cognitive 17) · ×1
  • AvgPoolSeq.backwardCPU (cognitive 17) Sources/GrAIdient/LayerSeq/AvgPoolSeq.swift:180 — AvgPoolSeq.backwardCPU has cognitive complexity 17 (threshold 15). Drivers by points: loops 3 (9 pts), if/else 3 (7 pts), boolean chains 1 (nesting depth added 10). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D2 · Cognitive Complexity · LayerNormSeq.backwardCPU (cognitive 17) · ×1
  • LayerNormSeq.backwardCPU (cognitive 17) Sources/GrAIdient/LayerSeq/LayerNormSeq.swift:540 — LayerNormSeq.backwardCPU has cognitive complexity 17 (threshold 15). Drivers by points: loops 3 (9 pts), if/else 3 (7 pts), boolean chains 1 (nesting depth added 10). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D2 · Cognitive Complexity · RMSNormSeq.backwardCPU (cognitive 17) · ×1
  • RMSNormSeq.backwardCPU (cognitive 17) Sources/GrAIdient/LayerSeq/RMSNormSeq.swift:554 — RMSNormSeq.backwardCPU has cognitive complexity 17 (threshold 15). Drivers by points: loops 3 (9 pts), if/else 3 (7 pts), boolean chains 1 (nesting depth added 10). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D2 · Cognitive Complexity · Crop2D.forwardCPU (cognitive 17) · ×1
  • Crop2D.forwardCPU (cognitive 17) Sources/GrAIdient/Layer2D/Transform/Crop2D.swift:254 — Crop2D.forwardCPU has cognitive complexity 17 (threshold 15). Drivers by points: loops 4 (14 pts), if/else 2 (3 pts) (nesting depth added 11). 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.
D2 · Cognitive Complexity · FullyConnected._backwardCPU (cognitive 16) · ×1
  • FullyConnected._backwardCPU (cognitive 16) Sources/GrAIdient/Layer1D/FullyConnected.swift:936 — FullyConnected._backwardCPU has cognitive complexity 16 (threshold 15). Drivers by points: loops 3 (9 pts), if/else 3 (6 pts), boolean chains 1 (nesting depth added 9). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D2 · Cognitive Complexity · SelectNeurons1D.backwardCPU (cognitive 16) · ×1
  • SelectNeurons1D.backwardCPU (cognitive 16) Sources/GrAIdient/Layer1D/SelectNeurons1D.swift:268 — SelectNeurons1D.backwardCPU has cognitive complexity 16 (threshold 15). Drivers by points: loops 4 (12 pts), if/else 2 (3 pts), boolean chains 1 (nesting depth added 9). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D2 · Cognitive Complexity · Input2D.forwardCPU (cognitive 16) · ×1
  • Input2D.forwardCPU (cognitive 16) Sources/GrAIdient/Layer2D/Input2D.swift:419 — Input2D.forwardCPU has cognitive complexity 16 (threshold 15). Drivers by points: loops 4 (14 pts), boolean chains 1, if/else 1 (nesting depth added 10). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D2 · Cognitive Complexity · VQ2D.lossDerivativeCPU (cognitive 16) · ×1
  • VQ2D.lossDerivativeCPU (cognitive 16) Sources/GrAIdient/Layer2D/VQ2D.swift:861 — VQ2D.lossDerivativeCPU has cognitive complexity 16 (threshold 15). Drivers by points: loops 4 (14 pts), if/else 2 (nesting depth added 10). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D2 · Cognitive Complexity · EmbeddingSeq._backwardWeightsCPU (cognitive 16) · ×1
  • EmbeddingSeq._backwardWeightsCPU (cognitive 16) Sources/GrAIdient/LayerSeq/EmbeddingSeq.swift:614 — EmbeddingSeq._backwardWeightsCPU has cognitive complexity 16 (threshold 15). Drivers by points: loops 5 (11 pts), if/else 2 (4 pts), boolean chains 1 (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.
D2 · Cognitive Complexity · BatchNormalization.forwardGC (cognitive 16) · ×1
  • BatchNormalization.forwardGC (cognitive 16) Sources/GrAIdient/Core/Layer/LayerNormalization.swift:445 — BatchNormalization.forwardGC has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (12 pts), boolean chains 3, loops 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LayerMerge1D._getMergedGraph (cognitive 16) · ×1
  • LayerMerge1D._getMergedGraph (cognitive 16) Sources/GrAIdient/Layer1D/Base/LayerMerge1D.swift:133 — LayerMerge1D._getMergedGraph has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (11 pts), loops 4 (5 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LayerMerge2D._getMergedGraph (cognitive 16) · ×1
  • LayerMerge2D._getMergedGraph (cognitive 16) Sources/GrAIdient/Layer2D/Base/LayerMerge2D.swift:191 — LayerMerge2D._getMergedGraph has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (11 pts), loops 4 (5 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LayerMergeSeq._getMergedGraph (cognitive 16) · ×1
  • LayerMergeSeq._getMergedGraph (cognitive 16) Sources/GrAIdient/LayerSeq/Base/LayerMergeSeq.swift:136 — LayerMergeSeq._getMergedGraph has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (11 pts), loops 4 (5 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D29 · Static Analysis (SAST) · REDACTED · ×1
  • REDACTED
D3 · God Classes · TooManyMethods · ×1
  • TooManyMethods: Convolution2D Sources/GrAIdient/Layer2D/Convolution2D.swift:26 — TooManyMethods — 31 methods. The bar is 30 methods; this is 1 over it, 1.03× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
D4 · Code Duplication · Near-duplicate member family (9 members, 14 shared lines) · ×1
  • Near-duplicate member family (9 members, 14 shared lines) Sources/GrAIdient/Layer2D/Normalize2D.swift:276 — Sources/GrAIdient/Layer2D/Normalize2D.swift:276-306 | Sources/GrAIdient/Layer2D/Normalize2D.swift:745-782 | Sources/GrAIdient/Layer2D/Transform/Crop2D.swift:368-401 | Sources/GrAIdient/Layer2D/Transform/DecorrelateRGB.swift:286-317 | Sources/GrAIdient/Layer2D/Transform/Flip2D.swift:298-329 | Sources/GrAIdient/Layer2D/Transform/IRDFT2RGB.swift:273-302 | Sources/GrAIdient/Layer2D/Transform/LinearScale2D.swift:258-289 | Sources/GrAIdient/Layer2D/Transform/Pad2D.swift:291-322 | Sources/GrAIdient/Layer2D/VQ2D.swift:643-679 — These 9 members are variants of one another: a block of 14 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 9 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 9 times.
D4 · Code Duplication · Near-duplicate member family (9 members, 5 shared lines) · ×1
  • Near-duplicate member family (9 members, 5 shared lines) Sources/GrAIdient/Layer1D/FullyConnected.swift:1066 — Sources/GrAIdient/Layer1D/FullyConnected.swift:1066-1186 | Sources/GrAIdient/Layer2D/Constant2D.swift:516-580 | Sources/GrAIdient/Layer2D/Convolution2D.swift:1582-1756 | Sources/GrAIdient/Layer2D/VQ2D.swift:681-782 | Sources/GrAIdient/LayerSeq/ConstantSeq.swift:948-1015 | Sources/GrAIdient/LayerSeq/EmbeddingSeq.swift:657-754 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:1128-1264 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:1018-1148 | Sources/GrAIdient/LayerSeq/VQSeq.swift:604-705 — These 9 members are variants of one another: a block of 5 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 9 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 9 times.
D4 · Code Duplication · Near-duplicate member family (6 members, 37 shared lines) · ×1
  • Near-duplicate member family (6 members, 37 shared lines) Sources/GrAIdient/LayerSeq/ValueSeq.swift:132 — Sources/GrAIdient/LayerSeq/ValueSeq.swift:132-215 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:222-317 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:694-782 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:789-890 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1400-1489 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1496-1599 — These 6 members are variants of one another: a block of 37 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 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
D4 · Code Duplication · Near-duplicate member family (6 members, 18 shared lines) · ×1
  • Near-duplicate member family (6 members, 18 shared lines) Sources/GrAIdient/Layer2D/Normalize2D.swift:179 — Sources/GrAIdient/Layer2D/Normalize2D.swift:179-204 | Sources/GrAIdient/Layer2D/Normalize2D.swift:590-621 | Sources/GrAIdient/Layer2D/Transform/DecorrelateRGB.swift:216-243 | Sources/GrAIdient/Layer2D/Transform/IRDFT2RGB.swift:192-217 | Sources/GrAIdient/Layer2D/Transform/LinearScale2D.swift:194-221 | Sources/GrAIdient/Layer2D/Transform/Pad2D.swift:222-251 — These 6 members are variants of one another: a block of 18 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 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
D4 · Code Duplication · Near-duplicate member family (6 members, 14 shared lines) · ×1
  • Near-duplicate member family (6 members, 14 shared lines) Sources/GrAIdient/Layer2D/Normalize2D.swift:179 — Sources/GrAIdient/Layer2D/Normalize2D.swift:179-204 | Sources/GrAIdient/Layer2D/Normalize2D.swift:536-583 | Sources/GrAIdient/Layer2D/Transform/DecorrelateRGB.swift:216-243 | Sources/GrAIdient/Layer2D/Transform/IRDFT2RGB.swift:192-217 | Sources/GrAIdient/Layer2D/Transform/LinearScale2D.swift:194-221 | Sources/GrAIdient/Layer2D/Transform/Pad2D.swift:222-251 — These 6 members are variants of one another: a block of 14 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
D4 · Code Duplication · Near-duplicate member family (5 members, 28 shared lines) · ×1
  • Near-duplicate member family (5 members, 28 shared lines) Sources/GrAIdient/LayerSeq/QuerySeq.swift:473 — Sources/GrAIdient/LayerSeq/QuerySeq.swift:473-550 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:1989-2073 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:473-549 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1059-1153 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1981-2064 — These 5 members are variants of one another: a block of 28 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
D4 · Code Duplication · Near-duplicate member family (5 members, 19 shared lines) · ×1
  • Near-duplicate member family (5 members, 19 shared lines) Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:294 — Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:294-318 | Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:366-391 | Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:449-473 | Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:583-611 | Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:667-696 — These 5 members are variants of one another: a block of 19 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
D4 · Code Duplication · Near-duplicate member family (5 members, 14 shared lines) · ×1
  • Near-duplicate member family (5 members, 14 shared lines) Sources/GrAIdient/Layer1D/Concat1D.swift:344 — Sources/GrAIdient/Layer1D/Concat1D.swift:344-395 | Sources/GrAIdient/Layer2D/Concat2D.swift:387-440 | Sources/GrAIdient/Layer2D/SimilarityError2D.swift:464-519 | Sources/GrAIdient/Layer2D/SimilarityError2D.swift:706-761 | Sources/GrAIdient/LayerSeq/ConcatSeq.swift:806-859 — These 5 members are variants of one another: a block of 14 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
D4 · Code Duplication · Near-duplicate member family (4 members, 50 shared lines) · ×1
  • Near-duplicate member family (4 members, 50 shared lines) Sources/GrAIdient/Layer2D/Convolution2D.swift:842 — Sources/GrAIdient/Layer2D/Convolution2D.swift:842-1024 | Sources/GrAIdient/Layer2D/Convolution2D.swift:1038-1261 | Sources/GrAIdient/Layer2D/Deconvolution2D.swift:268-471 | Sources/GrAIdient/Layer2D/Deconvolution2D.swift:473-720 — These 4 members are variants of one another: a block of 50 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
D4 · Code Duplication · Near-duplicate member family (4 members, 40 shared lines) · ×1
  • Near-duplicate member family (4 members, 40 shared lines) Sources/GrAIdient/Layer2D/Multiply2D.swift:169 — Sources/GrAIdient/Layer2D/Multiply2D.swift:169-246 | Sources/GrAIdient/Layer2D/Multiply2D.swift:253-340 | Sources/GrAIdient/Layer2D/Sum2D.swift:91-168 | Sources/GrAIdient/Layer2D/Sum2D.swift:175-262 — These 4 members are variants of one another: a block of 40 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
D4 · Code Duplication · Near-duplicate member family (4 members, 35 shared lines) · ×1
  • Near-duplicate member family (4 members, 35 shared lines) Sources/GrAIdient/LayerSeq/QuerySeq.swift:128 — Sources/GrAIdient/LayerSeq/QuerySeq.swift:128-212 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:219-315 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:1350-1466 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:1473-1605 — These 4 members are variants of one another: a block of 35 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
D4 · Code Duplication · Near-duplicate member family (4 members, 33 shared lines) · ×1
  • Near-duplicate member family (4 members, 33 shared lines) Sources/GrAIdient/LayerSeq/MutiplySeq.swift:168 — Sources/GrAIdient/LayerSeq/MutiplySeq.swift:168-231 | Sources/GrAIdient/LayerSeq/MutiplySeq.swift:238-311 | Sources/GrAIdient/LayerSeq/SumSeq.swift:90-153 | Sources/GrAIdient/LayerSeq/SumSeq.swift:160-233 — These 4 members are variants of one another: a block of 33 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
D4 · Code Duplication · Near-duplicate member family (4 members, 20 shared lines) · ×1
  • Near-duplicate member family (4 members, 20 shared lines) Sources/GrAIdient/Layer1D/LinearError1D.swift:203 — Sources/GrAIdient/Layer1D/LinearError1D.swift:203-235 | Sources/GrAIdient/Layer2D/BCE2D.swift:274-311 | Sources/GrAIdient/Layer2D/BCESigmoid2D.swift:317-354 | Sources/GrAIdient/Layer2D/MSE2D.swift:270-307 — These 4 members are variants of one another: a block of 20 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
D4 · Code Duplication · Near-duplicate member family (4 members, 18 shared lines) · ×1
  • Near-duplicate member family (4 members, 18 shared lines) Sources/GrAIdient/LayerSeq/QuerySeq.swift:473 — Sources/GrAIdient/LayerSeq/QuerySeq.swift:473-550 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:924-997 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:1989-2073 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1981-2064 — These 4 members are variants of one another: a block of 18 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
D4 · Code Duplication · Near-duplicate member family (4 members, 12 shared lines) · ×1
  • Near-duplicate member family (4 members, 12 shared lines) Sources/GrAIdient/Layer2D/Normalize2D.swift:590 — Sources/GrAIdient/Layer2D/Normalize2D.swift:590-621 | Sources/GrAIdient/Layer2D/Transform/DecorrelateRGB.swift:216-243 | Sources/GrAIdient/Layer2D/Transform/LinearScale2D.swift:194-221 | Sources/GrAIdient/Layer2D/VQ2D.swift:510-539 — These 4 members are variants of one another: a block of 12 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
D4 · Code Duplication · Near-duplicate member family (3 members, 26 shared lines) · ×1
  • Near-duplicate member family (3 members, 26 shared lines) Sources/GrAIdient/Layer2D/Base/LayerOutput2D.swift:270 — Sources/GrAIdient/Layer2D/Base/LayerOutput2D.swift:270-302 | Sources/GrAIdient/Layer2D/Transform/Crop2D.swift:204-237 | Sources/GrAIdient/Layer2D/Transform/LinearScale2D.swift:118-151 — These 3 members are variants of one another: a block of 26 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 3 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 3 times.
D4 · Code Duplication · Near-duplicate member pair (71 shared lines) · ×1
  • Near-duplicate member pair (71 shared lines) Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:527 — Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:527-674 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:687-852 — These two members are variants of one another: 71 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 · Near-duplicate member pair (66 shared lines) · ×1
  • Near-duplicate member pair (66 shared lines) Sources/GrAIdient/Layer1D/DotProduct1D.swift:120 — Sources/GrAIdient/Layer1D/DotProduct1D.swift:120-193 | Sources/GrAIdient/Layer1D/DotProduct1D.swift:200-276 — These two members are variants of one another: 66 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (46 shared lines) · ×1
  • Near-duplicate member pair (46 shared lines) Sources/GrAIdient/LayerSeq/ValueSeq.swift:395 — Sources/GrAIdient/LayerSeq/ValueSeq.swift:395-466 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:974-1052 — These two members are variants of one another: 46 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 · Near-duplicate member pair (28 shared lines) · ×1
  • Near-duplicate member pair (28 shared lines) Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1903 — Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1903-1941 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1944-1982 — These two members are variants of one another: 28 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 (33 members, 50+ identical tokens) · ×1
  • Members sharing a duplicated core (33 members, 50+ identical tokens) Sources/GrAIdient/Layer2D/Activation2D.swift:140 — Sources/GrAIdient/Layer2D/Activation2D.swift:140-156 | Sources/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:216-237 | Sources/GrAIdient/Layer2D/AvgPool2D.swift:54-66 | Sources/GrAIdient/Layer2D/BCE2D.swift:25-39 | Sources/GrAIdient/Layer2D/BCESigmoid2D.swift:28-42 | Sources/GrAIdient/Layer2D/BN2D.swift:239-272 | Sources/GrAIdient/Layer2D/Convolution2D.swift:537-588 | Sources/GrAIdient/Layer2D/Deconvolution2D.swift:133-184 | Sources/GrAIdient/Layer2D/InstanceNorm2D.swift:164-197 | Sources/GrAIdient/Layer2D/LayerCAM2D.swift:87-102 | Sources/GrAIdient/Layer2D/MSE2D.swift:23-37 | Sources/GrAIdient/Layer2D/MaxPool2D.swift:155-172 | Sources/GrAIdient/Layer2D/Normalize2D.swift:59-74 | Sources/GrAIdient/Layer2D/Normalize2D.swift:381-396 | Sources/GrAIdient/Layer2D/SelectNeurons2D.swift:132-149 | Sources/GrAIdient/Layer2D/SelectNeurons2D.swift:165-184 | Sources/GrAIdient/Layer2D/SelfCorrelate2D.swift:57-72 | Sources/GrAIdient/Layer2D/SimilarityBatchError2D.swift:56-72 | Sources/GrAIdient/Layer2D/Transform/ColorJitterHSV.swift:160-178 | Sources/GrAIdient/Layer2D/Transform/Crop2D.swift:167-197 | Sources/GrAIdient/Layer2D/Transform/DecorrelateRGB.swift:100-116 | Sources/GrAIdient/Layer2D/Transform/Flip2D.swift:107-123 | Sources/GrAIdient/Layer2D/Transform/Flip2D.swift:364-380 | Sources/GrAIdient/Layer2D/Transform/IRDFT2RGB.swift:68-83 | Sources/GrAIdient/Layer2D/Transform/LinearScale2D.swift:94-111 | Sources/GrAIdient/Layer2D/Transform/Pad2D.swift:103-120 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinear.swift:64-81 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:256-299 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift:227-262 | Sources/GrAIdient/Layer2D/Transform/Rotate2D.swift:172-207 | Sources/GrAIdient/Layer2D/VQ2D.swift:212-245 | Sources/GrAIdient/Layer2D/VQ2D.swift:1074-1108 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:260-297 — These 33 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 33 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 33 times.
D4 · Code Duplication · Members sharing a duplicated core (17 members, 50+ identical tokens) · ×1
  • Members sharing a duplicated core (17 members, 50+ identical tokens) Sources/GrAIdient/Layer1D/Concat1D.swift:47 — Sources/GrAIdient/Layer1D/Concat1D.swift:47-63 | Sources/GrAIdient/Layer1D/DotProduct1D.swift:93-113 | Sources/GrAIdient/Layer1D/Sum1D.swift:64-80 | Sources/GrAIdient/Layer2D/AdaIN.swift:137-170 | Sources/GrAIdient/Layer2D/Concat2D.swift:57-73 | Sources/GrAIdient/Layer2D/Multiply2D.swift:79-95 | Sources/GrAIdient/Layer2D/SimilarityError2D.swift:121-141 | Sources/GrAIdient/Layer2D/Sum2D.swift:68-84 | Sources/GrAIdient/LayerSeq/ConcatSeq.swift:59-75 | Sources/GrAIdient/LayerSeq/ConcatSeq.swift:491-507 | Sources/GrAIdient/LayerSeq/MutiplySeq.swift:78-94 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:102-121 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:1163-1202 | Sources/GrAIdient/LayerSeq/SumSeq.swift:67-83 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:106-125 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:666-687 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1289-1314 — These 17 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 17 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 17 times.
D4 · Code Duplication · Members sharing a duplicated core (14 members, 50+ identical tokens) · ×1
  • Members sharing a duplicated core (14 members, 50+ identical tokens) Sources/GrAIdient/Layer1D/Activation1D.swift:302 — Sources/GrAIdient/Layer1D/Activation1D.swift:302-336 | Sources/GrAIdient/Layer1D/Base/LayerOutput1D.swift:342-377 | Sources/GrAIdient/Layer1D/Input1D.swift:395-427 | Sources/GrAIdient/Layer1D/Sum1D.swift:327-372 | Sources/GrAIdient/Layer2D/Activation2D.swift:315-349 | Sources/GrAIdient/Layer2D/BN2D.swift:655-690 | Sources/GrAIdient/Layer2D/Base/LayerOutput2D.swift:402-437 | Sources/GrAIdient/Layer2D/Input2D.swift:501-533 | Sources/GrAIdient/Layer2D/InstanceNorm2D.swift:579-614 | Sources/GrAIdient/Layer2D/Sum2D.swift:378-423 | Sources/GrAIdient/LayerSeq/ActivationSeq.swift:312-346 | Sources/GrAIdient/LayerSeq/LayerNormSeq.swift:574-609 | Sources/GrAIdient/LayerSeq/RMSNormSeq.swift:588-623 | Sources/GrAIdient/LayerSeq/SumSeq.swift:339-384 — These 14 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 14 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 14 times.
D4 · Code Duplication · Members sharing a duplicated core (11 members, 50+ identical tokens) · ×1
  • Members sharing a duplicated core (11 members, 50+ identical tokens) Sources/GrAIdient/Layer2D/Base/LayerOutput2D.swift:368 — Sources/GrAIdient/Layer2D/Base/LayerOutput2D.swift:368-395 | Sources/GrAIdient/Layer2D/Concat2D.swift:337-380 | Sources/GrAIdient/Layer2D/Convolution2D.swift:1394-1442 | Sources/GrAIdient/Layer2D/Deconvolution2D.swift:766-810 | Sources/GrAIdient/Layer2D/Input2D.swift:468-494 | Sources/GrAIdient/Layer2D/Normalize2D.swift:207-269 | Sources/GrAIdient/Layer2D/Normalize2D.swift:624-688 | Sources/GrAIdient/Layer2D/SelfCorrelate2D.swift:206-247 | Sources/GrAIdient/Layer2D/Transform/DecorrelateRGB.swift:246-279 | Sources/GrAIdient/Layer2D/Transform/Flip2D.swift:257-291 | Sources/GrAIdient/Layer2D/Transform/Flip2D.swift:468-502 — These 11 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 11 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 11 times.
D4 · Code Duplication · Members sharing a duplicated core (10 members, 50+ identical tokens) · ×1
  • Members sharing a duplicated core (10 members, 50+ identical tokens) Sources/GrAIdient/Layer2D/BCE2D.swift:101 — Sources/GrAIdient/Layer2D/BCE2D.swift:101-156 | Sources/GrAIdient/Layer2D/BCE2D.swift:172-226 | Sources/GrAIdient/Layer2D/BCE2D.swift:332-434 | Sources/GrAIdient/Layer2D/BCESigmoid2D.swift:104-179 | Sources/GrAIdient/Layer2D/BCESigmoid2D.swift:195-269 | Sources/GrAIdient/Layer2D/BCESigmoid2D.swift:375-469 | Sources/GrAIdient/Layer2D/Base/LayerOutput2D.swift:140-211 | Sources/GrAIdient/Layer2D/MSE2D.swift:99-154 | Sources/GrAIdient/Layer2D/MSE2D.swift:170-222 | Sources/GrAIdient/Layer2D/MSE2D.swift:328-404 — These 10 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 10 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 10 times.
D4 · Code Duplication · Members sharing a duplicated core (8 members, 50+ identical tokens) · ×1
  • Members sharing a duplicated core (8 members, 50+ identical tokens) Sources/GrAIdient/Layer1D/Activation1D.swift:133 — Sources/GrAIdient/Layer1D/Activation1D.swift:133-149 | Sources/GrAIdient/Layer1D/BCE1D.swift:25-39 | Sources/GrAIdient/Layer1D/BCESigmoid1D.swift:28-42 | Sources/GrAIdient/Layer1D/Dropout1D.swift:92-108 | Sources/GrAIdient/Layer1D/LinearError1D.swift:23-37 | Sources/GrAIdient/Layer1D/MSE1D.swift:23-37 | Sources/GrAIdient/Layer1D/SelectNeurons1D.swift:105-122 | Sources/GrAIdient/Layer1D/Softmax1D.swift:96-112 — These 8 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 8 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 8 times.
D4 · Code Duplication · Edited copy of a member (106 corresponding lines) · ×1
  • Edited copy of a member (106 corresponding lines) Sources/GrAIdient/Layer2D/AdaIN.swift:247 — Sources/GrAIdient/Layer2D/AdaIN.swift:247-352 | Sources/GrAIdient/Layer2D/AdaIN.swift:359-474 — These two members are one piece of code written twice and then edited apart: 106 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/GrAIdient/LayerSeq/QuerySeq.swift:1714 — Sources/GrAIdient/LayerSeq/QuerySeq.swift:1714-1792 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1708-1786 — 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 copies of one member (4 members, 99+ corresponding lines) · ×1
  • Edited copies of one member (4 members, 99+ corresponding lines) Sources/GrAIdient/Layer1D/FullyConnected.swift:634 — Sources/GrAIdient/Layer1D/FullyConnected.swift:634-732 | Sources/GrAIdient/Layer1D/FullyConnected.swift:745-856 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:501-614 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:627-753 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 99 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 (78 corresponding lines) · ×1
  • Edited copy of a member (78 corresponding lines) Sources/GrAIdient/Layer2D/SimilarityError2D.swift:171 — Sources/GrAIdient/Layer2D/SimilarityError2D.swift:171-248 | Sources/GrAIdient/Layer2D/SimilarityError2D.swift:255-342 — These two members are one piece of code written twice and then edited apart: 78 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 (57 corresponding lines) · ×1
  • Edited copy of a member (57 corresponding lines) Sources/GrAIdient/Layer2D/Convolution2D.swift:1326 — Sources/GrAIdient/Layer2D/Convolution2D.swift:1326-1382 | Sources/GrAIdient/Layer2D/Convolution2D.swift:1521-1580 — These two members are one piece of code written twice and then edited apart: 57 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 (85 corresponding lines) · ×1
  • Edited copy of a member (85 corresponding lines) Sources/GrAIdient/LayerSeq/QuerySeq.swift:1895 — Sources/GrAIdient/LayerSeq/QuerySeq.swift:1895-1982 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1890-1974 — These two members are one piece of code written twice and then edited apart: 85 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 (71 corresponding lines) · ×1
  • Edited copy of a member (71 corresponding lines) Sources/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:549 — Sources/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:549-626 | Sources/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:745-815 — These two members are one piece of code written twice and then edited apart: 71 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 (7 members, 75+ corresponding lines) · ×1
  • Edited copies of one member (7 members, 75+ corresponding lines) Sources/GrAIdient/Layer1D/Concat1D.swift:145 — Sources/GrAIdient/Layer1D/Concat1D.swift:145-221 | Sources/GrAIdient/Layer2D/Concat2D.swift:80-160 | Sources/GrAIdient/Layer2D/Concat2D.swift:167-257 | Sources/GrAIdient/LayerSeq/ConcatSeq.swift:82-156 | Sources/GrAIdient/LayerSeq/ConcatSeq.swift:163-246 | Sources/GrAIdient/LayerSeq/ConcatSeq.swift:514-588 | Sources/GrAIdient/LayerSeq/ConcatSeq.swift:595-678 — These 7 members are one piece of code written 7 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 7 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 61+ corresponding lines) · ×1
  • Edited copies of one member (3 members, 61+ corresponding lines) Sources/GrAIdient/Layer1D/Concat1D.swift:70 — Sources/GrAIdient/Layer1D/Concat1D.swift:70-138 | Sources/GrAIdient/Layer1D/Sum1D.swift:87-147 | Sources/GrAIdient/Layer1D/Sum1D.swift:154-223 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 61 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 (62 corresponding lines) · ×1
  • Edited copy of a member (62 corresponding lines) Sources/GrAIdient/Layer2D/Convolution2D.swift:1444 — Sources/GrAIdient/Layer2D/Convolution2D.swift:1444-1505 | Sources/GrAIdient/Layer2D/Deconvolution2D.swift:812-878 — These two members are one piece of code written twice and then edited apart: 62 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, 37+ corresponding lines) · ×1
  • Edited copies of one member (4 members, 37+ corresponding lines) Sources/GrAIdient/LayerSeq/QuerySeq.swift:1665 — Sources/GrAIdient/LayerSeq/QuerySeq.swift:1665-1711 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:1856-1892 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1659-1705 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1850-1887 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 37 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 (49 corresponding lines) · ×1
  • Edited copy of a member (49 corresponding lines) Sources/GrAIdient/Layer2D/BN2D.swift:510 — Sources/GrAIdient/Layer2D/BN2D.swift:510-558 | Sources/GrAIdient/Layer2D/InstanceNorm2D.swift:434-482 — These two members are one piece of code written twice and then edited apart: 49 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 (48 corresponding lines) · ×1
  • Edited copy of a member (48 corresponding lines) Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:806 — Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:806-853 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:962-1016 — These two members are one piece of code written twice and then edited apart: 48 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, 52+ corresponding lines) · ×1
  • Edited copies of one member (3 members, 52+ corresponding lines) Sources/GrAITestsUtils/Trainer.swift:314 — Sources/GrAITestsUtils/Trainer.swift:314-365 | Sources/GrAITestsUtils/Trainer.swift:457-512 | Sources/GrAITestsUtils/Trainer.swift:602-655 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 52 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 (52 corresponding lines) · ×1
  • Edited copy of a member (52 corresponding lines) Sources/GrAIdient/Layer2D/Base/LayerInput2D.swift:55 — Sources/GrAIdient/Layer2D/Base/LayerInput2D.swift:55-106 | Sources/GrAIdient/Layer2D/Base/LayerInput2D.swift:121-185 — These two members are one piece of code written twice and then edited apart: 52 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) · ×1
  • Edited copy of a member (33 corresponding lines) Sources/GrAIdient/Layer2D/Transform/IRDFT2RGB.swift:90 — Sources/GrAIdient/Layer2D/Transform/IRDFT2RGB.swift:90-136 | Sources/GrAIdient/Layer2D/Transform/IRDFT2RGB.swift:153-185 — 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 copies of one member (3 members, 48+ corresponding lines) · ×1
  • Edited copies of one member (3 members, 48+ corresponding lines) Sources/GrAIdient/Layer2D/Normalize2D.swift:691 — Sources/GrAIdient/Layer2D/Normalize2D.swift:691-738 | Sources/GrAIdient/Layer2D/VQ2D.swift:1263-1315 | Sources/GrAIdient/LayerSeq/VQSeq.swift:1180-1232 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 48 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 (50 corresponding lines) · ×1
  • Edited copy of a member (50 corresponding lines) Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:1011 — Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:1011-1074 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:898-947 — 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 (4 members, 43+ corresponding lines) · ×1
  • Edited copies of one member (4 members, 43+ corresponding lines) Sources/GrAIdient/Layer2D/Normalize2D.swift:81 — Sources/GrAIdient/Layer2D/Normalize2D.swift:81-126 | Sources/GrAIdient/Layer2D/Normalize2D.swift:438-483 | Sources/GrAIdient/Layer2D/Transform/Flip2D.swift:130-172 | Sources/GrAIdient/Layer2D/Transform/Flip2D.swift:387-429 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 43 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 copies of one member (5 members, 38+ corresponding lines) · ×1
  • Edited copies of one member (5 members, 38+ corresponding lines) Sources/GrAIdient/Layer1D/Concat1D.swift:256 — Sources/GrAIdient/Layer1D/Concat1D.swift:256-294 | Sources/GrAIdient/Layer2D/Concat2D.swift:294-334 | Sources/GrAIdient/Layer2D/SimilarityError2D.swift:375-412 | Sources/GrAIdient/LayerSeq/ConcatSeq.swift:283-327 | Sources/GrAIdient/LayerSeq/ConcatSeq.swift:715-754 — These 5 members are one piece of code written 5 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 5 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (4 members, 31+ corresponding lines) · ×1
  • Edited copies of one member (4 members, 31+ corresponding lines) Sources/GrAIdient/Core/Layer/LayerNormalization.swift:886 — Sources/GrAIdient/Core/Layer/LayerNormalization.swift:886-917 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:967-997 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1656-1697 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1865-1900 — These 4 members are one piece of code written 4 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 4 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 44+ corresponding lines) · ×1
  • Edited copies of one member (3 members, 44+ corresponding lines) Sources/GrAIdient/Layer1D/BCE1D.swift:261 — Sources/GrAIdient/Layer1D/BCE1D.swift:261-317 | Sources/GrAIdient/Layer1D/BCESigmoid1D.swift:284-336 | Sources/GrAIdient/Layer1D/MSE1D.swift:257-300 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 44 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, 33+ corresponding lines) · ×1
  • Edited copies of one member (3 members, 33+ corresponding lines) Sources/GrAIdient/Layer2D/SimilarityBatchError2D.swift:243 — Sources/GrAIdient/Layer2D/SimilarityBatchError2D.swift:243-275 | Sources/GrAIdient/Layer2D/VQ2D.swift:826-858 | Sources/GrAIdient/LayerSeq/VQSeq.swift:747-779 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 33 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 (6 members, 30+ corresponding lines) · ×1
  • Edited copies of one member (6 members, 30+ corresponding lines) Sources/GrAIdient/Layer2D/AvgPool2D.swift:158 — Sources/GrAIdient/Layer2D/AvgPool2D.swift:158-187 | Sources/GrAIdient/Layer2D/AvgPool2D.swift:229-262 | Sources/GrAIdient/Layer2D/SelectNeurons2D.swift:256-287 | Sources/GrAIdient/Layer2D/SelectNeurons2D.swift:330-365 | Sources/GrAIdient/Layer2D/SelfCorrelate2D.swift:173-203 | Sources/GrAIdient/Layer2D/SelfCorrelate2D.swift:254-289 — These 6 members are one piece of code written 6 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 6 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 34+ corresponding lines) · ×1
  • Edited copies of one member (3 members, 34+ corresponding lines) Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1318 — Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1318-1351 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:2226-2267 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:2868-2907 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 34 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 (43 corresponding lines) · ×1
  • Edited copy of a member (43 corresponding lines) Sources/GrAIdient/Layer2D/SimilarityError2D.swift:415 — Sources/GrAIdient/Layer2D/SimilarityError2D.swift:415-457 | Sources/GrAIdient/Layer2D/SimilarityError2D.swift:648-696 — These two members are one piece of code written twice and then edited apart: 43 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, 28+ corresponding lines) · ×1
  • Edited copies of one member (4 members, 28+ corresponding lines) Sources/GrAIdient/LayerSeq/QuerySeq.swift:322 — Sources/GrAIdient/LayerSeq/QuerySeq.swift:322-349 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:1612-1643 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:897-926 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1606-1637 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 28 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 copies of one member (4 members, 26+ corresponding lines) · ×1
  • Edited copies of one member (4 members, 26+ corresponding lines) Sources/GrAIdient/LayerSeq/AvgPoolSeq.swift:152 — Sources/GrAIdient/LayerSeq/AvgPoolSeq.swift:152-177 | Sources/GrAIdient/LayerSeq/LayerCAMSeq.swift:168-196 | Sources/GrAIdient/LayerSeq/SelectSeq.swift:173-200 | Sources/GrAIdient/LayerSeq/SoftmaxSeq.swift:240-270 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 26 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 copies of one member (4 members, 25+ corresponding lines) · ×1
  • Edited copies of one member (4 members, 25+ corresponding lines) Sources/GrAIdient/Layer1D/DotProduct1D.swift:313 — Sources/GrAIdient/Layer1D/DotProduct1D.swift:313-340 | Sources/GrAIdient/Layer1D/FullyConnected.swift:901-925 | Sources/GrAIdient/Layer1D/SelectNeurons1D.swift:238-265 | Sources/GrAIdient/Layer2D/LayerCAM2D.swift:172-200 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 25 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 copies of one member (5 members, 31+ corresponding lines) · ×1
  • Edited copies of one member (5 members, 31+ corresponding lines) Sources/GrAIdient/Layer1D/BCE1D.swift:92 — Sources/GrAIdient/Layer1D/BCE1D.swift:92-124 | Sources/GrAIdient/Layer1D/LinearError1D.swift:90-121 | Sources/GrAIdient/Layer1D/LinearError1D.swift:134-164 | Sources/GrAIdient/Layer1D/MSE1D.swift:90-121 | Sources/GrAIdient/Layer1D/MSE1D.swift:134-164 — These 5 members are one piece of code written 5 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 5 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/GrAIdient/Layer2D/LayerCAM2D.swift:129 — Sources/GrAIdient/Layer2D/LayerCAM2D.swift:129-165 | Sources/GrAIdient/Layer2D/Normalize2D.swift:143-172 | Sources/GrAIdient/Layer2D/SelfCorrelate2D.swift:137-166 — 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 copies of one member (4 members, 32+ corresponding lines) · ×1
  • Edited copies of one member (4 members, 32+ corresponding lines) Sources/GrAIdient/Layer1D/Sum1D.swift:289 — Sources/GrAIdient/Layer1D/Sum1D.swift:289-320 | Sources/GrAIdient/Layer2D/Sum2D.swift:334-371 | Sources/GrAIdient/LayerSeq/MutiplySeq.swift:425-463 | Sources/GrAIdient/LayerSeq/SumSeq.swift:300-332 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 32 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 copies of one member (4 members, 33+ corresponding lines) · ×1
  • Edited copies of one member (4 members, 33+ corresponding lines) Sources/GrAIdient/Layer2D/BN2D.swift:284 — Sources/GrAIdient/Layer2D/BN2D.swift:284-316 | Sources/GrAIdient/Layer2D/InstanceNorm2D.swift:209-241 | Sources/GrAIdient/LayerSeq/LayerNormSeq.swift:208-240 | Sources/GrAIdient/LayerSeq/RMSNormSeq.swift:220-253 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 33 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 (21 corresponding lines) · ×1
  • Edited copy of a member (21 corresponding lines) Sources/GrAIdient/Layer1D/Constant1D.swift:393 — Sources/GrAIdient/Layer1D/Constant1D.swift:393-413 | Sources/GrAIdient/Layer1D/Softmax1D.swift:230-255 — 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 (4 members, 22+ corresponding lines) · ×1
  • Edited copies of one member (4 members, 22+ corresponding lines) Sources/GrAIdient/Layer2D/SimilarityBatchError2D.swift:185 — Sources/GrAIdient/Layer2D/SimilarityBatchError2D.swift:185-206 | Sources/GrAIdient/Layer2D/SimilarityBatchError2D.swift:213-234 | Sources/GrAIdient/Layer2D/SimilarityError2D.swift:547-568 | Sources/GrAIdient/Layer2D/SimilarityError2D.swift:575-596 — These 4 members are one piece of code written 4 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 4 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (6 members, 22+ corresponding lines) · ×1
  • Edited copies of one member (6 members, 22+ corresponding lines) Sources/GrAIdient/Layer1D/Activation1D.swift:178 — Sources/GrAIdient/Layer1D/Activation1D.swift:178-201 | Sources/GrAIdient/Layer1D/Base/LayerOutput1D.swift:230-251 | Sources/GrAIdient/Layer1D/SelectNeurons1D.swift:173-197 | Sources/GrAIdient/LayerSeq/ActivationSeq.swift:182-209 | Sources/GrAIdient/LayerSeq/AvgPoolSeq.swift:73-104 | Sources/GrAIdient/LayerSeq/SelectSeq.swift:109-133 — These 6 members are one piece of code written 6 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 6 times and the copies will drift further apart.
D4 · Code Duplication · Edited copy of a member (24 corresponding lines) · ×1
  • Edited copy of a member (24 corresponding lines) Sources/GrAIdient/LayerSeq/ConcatSeq.swift:253 — Sources/GrAIdient/LayerSeq/ConcatSeq.swift:253-276 | Sources/GrAIdient/LayerSeq/ConcatSeq.swift:685-708 — These two members are one piece of code written twice and then edited apart: 24 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/GrAIdient/LayerSeq/FullyConnectedSeq.swift:766 — Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:766-793 | Sources/GrAIdient/LayerSeq/LayerCAMSeq.swift:128-161 — 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 copies of one member (4 members, 21+ corresponding lines) · ×1
  • Edited copies of one member (4 members, 21+ corresponding lines) Sources/GrAIdient/Layer1D/FullyConnected.swift:320 — Sources/GrAIdient/Layer1D/FullyConnected.swift:320-340 | Sources/GrAIdient/Layer2D/Convolution2D.swift:501-523 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:225-246 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:204-224 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 21 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 copies of one member (7 members, 19+ corresponding lines) · ×1
  • Edited copies of one member (7 members, 19+ corresponding lines) Sources/GrAIdient/Layer2D/Activation2D.swift:228 — Sources/GrAIdient/Layer2D/Activation2D.swift:228-248 | Sources/GrAIdient/Layer2D/BN2D.swift:565-586 | Sources/GrAIdient/Layer2D/Base/LayerOutput2D.swift:319-337 | Sources/GrAIdient/Layer2D/Input2D.swift:419-437 | Sources/GrAIdient/Layer2D/InstanceNorm2D.swift:489-510 | Sources/GrAIdient/Layer2D/Transform/Crop2D.swift:254-279 | Sources/GrAIdient/Layer2D/Transform/LinearScale2D.swift:168-187 — These 7 members are one piece of code written 7 times and then edited apart: every two of them correspond over at least 19 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 7 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 11+ corresponding lines) · ×1
  • Edited copies of one member (3 members, 11+ corresponding lines) Sources/GrAIdient/Core/Function/Normalization.swift:46 — Sources/GrAIdient/Core/Function/Normalization.swift:46-56 | Sources/GrAIdient/Core/Function/Normalization.swift:93-111 | Sources/GrAIdient/Core/Function/Normalization.swift:125-143 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 11 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, 14+ corresponding lines) · ×1
  • Edited copies of one member (3 members, 14+ corresponding lines) Sources/GrAIdient/Core/Model/Model.swift:809 — Sources/GrAIdient/Core/Model/Model.swift:809-822 | Sources/GrAIdient/Core/Model/Model.swift:836-858 | Sources/GrAIdient/Core/Model/Model.swift:871-891 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 14 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 (5 members, 14+ corresponding lines) · ×1
  • Edited copies of one member (5 members, 14+ corresponding lines) Sources/GrAIdient/Layer1D/Activation1D.swift:219 — Sources/GrAIdient/Layer1D/Activation1D.swift:219-237 | Sources/GrAIdient/Layer1D/Base/LayerOutput1D.swift:268-281 | Sources/GrAIdient/Layer1D/Input1D.swift:319-335 | Sources/GrAIdient/Layer1D/SelectNeurons1D.swift:214-231 | Sources/GrAIdient/LayerSeq/SelectSeq.swift:150-166 — These 5 members are one piece of code written 5 times and then edited apart: every two of them correspond over at least 14 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 5 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (4 members, 18+ corresponding lines) · ×1
  • Edited copies of one member (4 members, 18+ corresponding lines) Sources/GrAIdient/Layer2D/Transform/ColorJitterHSV.swift:83 — Sources/GrAIdient/Layer2D/Transform/ColorJitterHSV.swift:83-109 | Sources/GrAIdient/Layer2D/Transform/Crop2D.swift:40-61 | Sources/GrAIdient/Layer2D/Transform/DecorrelateRGB.swift:30-51 | Sources/GrAIdient/Layer2D/Transform/IRDFT2RGB.swift:24-41 — These 4 members are one piece of code written 4 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 4 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 24+ corresponding lines) · ×1
  • Edited copies of one member (3 members, 24+ corresponding lines) Sources/GrAIdient/Layer1D/Constant1D.swift:416 — Sources/GrAIdient/Layer1D/Constant1D.swift:416-439 | Sources/GrAIdient/Layer2D/Constant2D.swift:484-509 | Sources/GrAIdient/LayerSeq/ConstantSeq.swift:917-941 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 24 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 (4 members, 14+ corresponding lines) · ×1
  • Edited copies of one member (4 members, 14+ corresponding lines) Sources/GrAIdient/Layer2D/BN2D.swift:764 — Sources/GrAIdient/Layer2D/BN2D.swift:764-780 | Sources/GrAIdient/Layer2D/BN2D.swift:789-802 | Sources/GrAIdient/Layer2D/BN2D.swift:810-826 | Sources/GrAIdient/Layer2D/BN2D.swift:835-848 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 14 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 copies of one member (3 members, 17+ corresponding lines) · ×1
  • Edited copies of one member (3 members, 17+ corresponding lines) Sources/GrAIdient/Layer2D/VQ2D.swift:282 — Sources/GrAIdient/Layer2D/VQ2D.swift:282-298 | Sources/GrAIdient/LayerSeq/EmbeddingSeq.swift:268-284 | Sources/GrAIdient/LayerSeq/VQSeq.swift:272-288 — These 3 members are one piece of code written 3 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 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (4 members, 11+ corresponding lines) · ×1
  • Edited copies of one member (4 members, 11+ corresponding lines) Sources/GrAIdient/Layer2D/Input2D.swift:25 — Sources/GrAIdient/Layer2D/Input2D.swift:25-37 | Sources/GrAIdient/Layer2D/Input2D.swift:38-48 | Sources/GrAIdient/Layer2D/Input2D.swift:54-66 | Sources/GrAIdient/Layer2D/Input2D.swift:67-77 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 11 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 copies of one member (3 members, 10+ corresponding lines) · ×1
  • Edited copies of one member (3 members, 10+ corresponding lines) Sources/GrAIdient/LayerSeq/QuerySeq.swift:1138 — Sources/GrAIdient/LayerSeq/QuerySeq.swift:1138-1149 | Sources/GrAIdient/LayerSeq/SoftmaxSeq.swift:424-433 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1264-1275 — 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.
D4 · Code Duplication · Edited copies of one member (4 members, 20+ corresponding lines) · ×1
  • Edited copies of one member (4 members, 20+ corresponding lines) Sources/GrAIdient/Layer2D/Convolution2D.swift:648 — Sources/GrAIdient/Layer2D/Convolution2D.swift:648-670 | Sources/GrAIdient/Layer2D/Deconvolution2D.swift:244-266 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:353-373 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:329-348 — These 4 members are one piece of code written 4 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 4 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (4 members, 12+ corresponding lines) · ×1
  • Edited copies of one member (4 members, 12+ corresponding lines) Sources/GrAIdient/Core/Layer/LayerUpdate.swift:282 — Sources/GrAIdient/Core/Layer/LayerUpdate.swift:282-293 | Sources/GrAIdient/Core/Layer/LayerUpdate.swift:347-358 | Sources/GrAIdient/Core/Layer/LayerUpdate.swift:412-424 | Sources/GrAIdient/Core/Layer/LayerUpdate.swift:480-492 — These 4 members are one piece of code written 4 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 4 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (6 members, 12+ corresponding lines) · ×1
  • Edited copies of one member (6 members, 12+ corresponding lines) Sources/GrAIdient/Core/Function/Activation.swift:195 — Sources/GrAIdient/Core/Function/Activation.swift:195-207 | Sources/GrAIdient/Core/Function/Activation.swift:214-227 | Sources/GrAIdient/Core/Function/Activation.swift:234-246 | Sources/GrAIdient/Core/Function/Activation.swift:253-264 | Sources/GrAIdient/Core/Function/Activation.swift:271-283 | Sources/GrAIdient/Core/Function/Activation.swift:290-301 — These 6 members are one piece of code written 6 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 6 times and the copies 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/GrAIdient/Layer1D/Constant1D.swift:375 — Sources/GrAIdient/Layer1D/Constant1D.swift:375-386 | Sources/GrAIdient/Layer2D/Constant2D.swift:441-452 | Sources/GrAIdient/LayerSeq/ConstantSeq.swift:870-882 — 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 copies of one member (6 members, 8+ corresponding lines) · ×1
  • Edited copies of one member (6 members, 8+ corresponding lines) Sources/GrAIdient/Layer2D/Activation2D.swift:46 — Sources/GrAIdient/Layer2D/Activation2D.swift:46-56 | Sources/GrAIdient/Layer2D/BN2D.swift:143-154 | Sources/GrAIdient/Layer2D/Base/LayerOutput2D.swift:38-45 | Sources/GrAIdient/Layer2D/Input2D.swift:155-163 | Sources/GrAIdient/Layer2D/InstanceNorm2D.swift:97-108 | Sources/GrAIdient/Layer2D/Normalize2D.swift:25-32 — These 6 members are one piece of code written 6 times and then edited apart: every two of them correspond over at least 8 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 copies of one member (4 members, 7+ corresponding lines) · ×1
  • Edited copies of one member (4 members, 7+ corresponding lines) Sources/GrAIdient/Layer2D/Constant2D.swift:96 — Sources/GrAIdient/Layer2D/Constant2D.swift:96-106 | Sources/GrAIdient/Layer2D/Input2D.swift:137-146 | Sources/GrAIdient/LayerSeq/ConstantSeq.swift:94-100 | Sources/GrAIdient/LayerSeq/EmbeddingSeq.swift:120-130 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 7 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 (5 corresponding lines) · ×1
  • Edited copy of a member (5 corresponding lines) Sources/GrAIdient/Core/Function/Activation.swift:95 — Sources/GrAIdient/Core/Function/Activation.swift:95-99 | Sources/GrAIdient/Core/Layer/Layer.swift:172-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 copies of one member (3 members, 6+ corresponding lines) · ×1
  • Edited copies of one member (3 members, 6+ corresponding lines) Sources/GrAIdient/Layer1D/Constant1D.swift:94 — Sources/GrAIdient/Layer1D/Constant1D.swift:94-99 | Sources/GrAIdient/Layer1D/Input1D.swift:116-122 | Sources/GrAIdient/LayerSeq/ConstantSeq.swift:579-585 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 6 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 · Duplicated block (61 lines × 2) · ×1
  • Duplicated block (61 lines × 2) Sources/GrAIdient/Metal/Reduce.swift:39 — Sources/GrAIdient/Metal/Reduce.swift:39-99 | Sources/GrAIdient/Metal/Reduce.swift:111-171 — both copies are in the same file, so extract the 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/GrAIdient/Metal/Reduce.swift:39` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (55 lines × 3) · ×1
  • Duplicated block (55 lines × 3) Sources/GrAIdient/Layer1D/Base/LayerMerge1D.swift:133 — Sources/GrAIdient/Layer1D/Base/LayerMerge1D.swift:133-187 | Sources/GrAIdient/Layer2D/Base/LayerMerge2D.swift:191-245 | Sources/GrAIdient/LayerSeq/Base/LayerMergeSeq.swift:136-190 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Base/LayerMerge1D.swift` and `Sources/GrAIdient/Layer2D/Base/LayerMerge2D.swift` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 129 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.
D4 · Code Duplication · Duplicated block (51–52 lines × 2) · ×1
  • Duplicated block (51–52 lines × 2) Sources/GrAITestsUtils/FlowChecking.swift:21 — Sources/GrAITestsUtils/FlowChecking.swift:21-72 | Sources/GrAITestsUtils/GradientChecking.swift:26-76 — 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/GrAITestsUtils/GradientChecking.swift:26` 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.
D4 · Code Duplication · Duplicated block (50 lines × 2) · ×1
  • Duplicated block (50 lines × 2) Sources/GrAIdient/Layer2D/AdaIN.swift:262 — Sources/GrAIdient/Layer2D/AdaIN.swift:262-311 | Sources/GrAIdient/Layer2D/AdaIN.swift:380-429 — both copies are in the same file, so extract the 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/GrAIdient/Layer2D/AdaIN.swift:262` 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 · Duplicated block (41 lines × 3) · ×1
  • Duplicated block (41 lines × 3) Sources/GrAIdient/Layer1D/FullyConnected.swift:1220 — Sources/GrAIdient/Layer1D/FullyConnected.swift:1220-1260 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:1298-1338 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:1182-1222 — before extracting anything, compare `Sources/GrAIdient/Layer1D/FullyConnected.swift` and `Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift` as WHOLE FILES: this scan already matched 32 separate duplicated blocks between them, totalling at least 473 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.
D4 · Code Duplication · Duplicated block (39 lines × 2) · ×1
  • Duplicated block (39 lines × 2) Sources/GrAIdient/LayerSeq/QuerySeq.swift:1371 — Sources/GrAIdient/LayerSeq/QuerySeq.swift:1371-1409 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:1497-1535 — both copies are in the same file, so extract the 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/GrAIdient/LayerSeq/QuerySeq.swift:1537` calls `download` and `Sources/GrAIdient/LayerSeq/QuerySeq.swift:1411` 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.
D4 · Code Duplication · Duplicated block (38 lines × 3) · ×1
  • Duplicated block (38 lines × 3) Sources/GrAIdient/Layer2D/BCE2D.swift:274 — Sources/GrAIdient/Layer2D/BCE2D.swift:274-311 | Sources/GrAIdient/Layer2D/BCESigmoid2D.swift:317-354 | Sources/GrAIdient/Layer2D/MSE2D.swift:270-307 — before extracting anything, compare `Sources/GrAIdient/Layer2D/BCE2D.swift` and `Sources/GrAIdient/Layer2D/BCESigmoid2D.swift` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 271 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (37 lines × 2) · ×1
  • Duplicated block (37 lines × 2) Sources/GrAIdient/LayerSeq/QuerySeq.swift:1714 — Sources/GrAIdient/LayerSeq/QuerySeq.swift:1714-1750 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1708-1744 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/QuerySeq.swift` and `Sources/GrAIdient/LayerSeq/ValueSeq.swift` as WHOLE FILES: this scan already matched 39 separate duplicated blocks between them, totalling at least 427 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/GrAIdient/LayerSeq/QuerySeq.swift:1714` 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.
D4 · Code Duplication · Duplicated block (36 lines × 3) · ×1
  • Duplicated block (36 lines × 3) Sources/GrAIdient/Layer1D/FullyConnected.swift:522 — Sources/GrAIdient/Layer1D/FullyConnected.swift:522-557 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:413-448 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:388-423 — before extracting anything, compare `Sources/GrAIdient/Layer1D/FullyConnected.swift` and `Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift` as WHOLE FILES: this scan already matched 32 separate duplicated blocks between them, totalling at least 473 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.
D4 · Code Duplication · Duplicated block (35 lines × 2) · ×1
  • Duplicated block (35 lines × 2) Sources/GrAIdient/Layer1D/DotProduct1D.swift:122 — Sources/GrAIdient/Layer1D/DotProduct1D.swift:122-156 | Sources/GrAIdient/Layer1D/DotProduct1D.swift:202-236 — both copies are in the same file, so extract the 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/GrAIdient/Layer1D/DotProduct1D.swift:238` calls `download` and `Sources/GrAIdient/Layer1D/DotProduct1D.swift:158` 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.
D4 · Code Duplication · Duplicated block (30–35 lines × 2) · ×1
  • Duplicated block (30–35 lines × 2) Sources/GrAIdient/LayerSeq/QuerySeq.swift:279 — Sources/GrAIdient/LayerSeq/QuerySeq.swift:279-308 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:1557-1591 — both copies are in the same file, so extract the 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/GrAIdient/LayerSeq/QuerySeq.swift:279` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (31–34 lines × 2) · ×1
  • Duplicated block (31–34 lines × 2) Sources/GrAIdient/Layer2D/VQ2D.swift:470 — Sources/GrAIdient/Layer2D/VQ2D.swift:470-500 | Sources/GrAIdient/Layer2D/VQ2D.swift:1215-1248 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (32–33 lines × 3) · ×1
  • Duplicated block (32–33 lines × 3) Sources/GrAIdient/Layer1D/FullyConnected.swift:564 — Sources/GrAIdient/Layer1D/FullyConnected.swift:564-595 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:455-487 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:430-461 — before extracting anything, compare `Sources/GrAIdient/Layer1D/FullyConnected.swift` and `Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift` as WHOLE FILES: this scan already matched 32 separate duplicated blocks between them, totalling at least 473 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.
D4 · Code Duplication · Duplicated block (31–33 lines × 2) · ×1
  • Duplicated block (31–33 lines × 2) Sources/GrAIdient/LayerSeq/VQSeq.swift:398 — Sources/GrAIdient/LayerSeq/VQSeq.swift:398-428 | Sources/GrAIdient/LayerSeq/VQSeq.swift:1133-1165 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (31 lines × 3) · ×1
  • Duplicated block (31 lines × 3) Sources/GrAIdient/Layer1D/Base/LayerMerge1D.swift:220 — Sources/GrAIdient/Layer1D/Base/LayerMerge1D.swift:220-250 | Sources/GrAIdient/Layer2D/Base/LayerMerge2D.swift:278-308 | Sources/GrAIdient/LayerSeq/Base/LayerMergeSeq.swift:223-253 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Base/LayerMerge1D.swift` and `Sources/GrAIdient/Layer2D/Base/LayerMerge2D.swift` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 129 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.
D4 · Code Duplication · Duplicated block (30 lines × 3) · ×1
  • Duplicated block (30 lines × 3) Sources/GrAIdient/Layer2D/BCE2D.swift:55 — Sources/GrAIdient/Layer2D/BCE2D.swift:55-84 | Sources/GrAIdient/Layer2D/BCESigmoid2D.swift:58-87 | Sources/GrAIdient/Layer2D/MSE2D.swift:53-82 — before extracting anything, compare `Sources/GrAIdient/Layer2D/BCE2D.swift` and `Sources/GrAIdient/Layer2D/BCESigmoid2D.swift` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 271 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (29–30 lines × 2) · ×1
  • Duplicated block (29–30 lines × 2) Sources/GrAIdient/Core/Layer/LayerNormalization.swift:2128 — Sources/GrAIdient/Core/Layer/LayerNormalization.swift:2128-2156 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:2809-2838 — both copies are in the same file, so extract the 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/GrAIdient/Core/Layer/LayerNormalization.swift:2128` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (29 lines × 11) · ×1
  • Duplicated block (29 lines × 11) Sources/GrAIdient/Layer1D/Activation1D.swift:308 — Sources/GrAIdient/Layer1D/Activation1D.swift:308-336 | Sources/GrAIdient/Layer1D/Base/LayerOutput1D.swift:349-377 | Sources/GrAIdient/Layer1D/Input1D.swift:399-427 | Sources/GrAIdient/Layer2D/Activation2D.swift:321-349 | Sources/GrAIdient/Layer2D/BN2D.swift:662-690 | Sources/GrAIdient/Layer2D/Base/LayerOutput2D.swift:409-437 | Sources/GrAIdient/Layer2D/Input2D.swift:505-533 | Sources/GrAIdient/Layer2D/InstanceNorm2D.swift:586-614 | Sources/GrAIdient/LayerSeq/ActivationSeq.swift:318-346 | Sources/GrAIdient/LayerSeq/LayerNormSeq.swift:581-609 | Sources/GrAIdient/LayerSeq/RMSNormSeq.swift:595-623 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Activation1D.swift` and `Sources/GrAIdient/Layer1D/Base/LayerOutput1D.swift` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 130 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/GrAIdient/Layer1D/Activation1D.swift:308` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Sources/GrAIdient/Layer1D/Activation1D.swift:304` calls `backwardGPU` and `Sources/GrAIdient/Layer1D/Base/LayerOutput1D.swift:343` 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.
D4 · Code Duplication · Duplicated block (28–29 lines × 2) · ×1
  • Duplicated block (28–29 lines × 2) Sources/GrAIdient/Layer2D/Convolution2D.swift:1478 — Sources/GrAIdient/Layer2D/Convolution2D.swift:1478-1505 | Sources/GrAIdient/Layer2D/Deconvolution2D.swift:850-878 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Convolution2D.swift` and `Sources/GrAIdient/Layer2D/Deconvolution2D.swift` as WHOLE FILES: this scan already matched 26 separate duplicated blocks between them, totalling at least 499 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/GrAIdient/Layer2D/Convolution2D.swift:1478` 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.
D4 · Code Duplication · Duplicated block (27 lines × 4) · ×1
  • Duplicated block (27 lines × 4) Sources/GrAIdient/Layer1D/BCE1D.swift:52 — Sources/GrAIdient/Layer1D/BCE1D.swift:52-78 | Sources/GrAIdient/Layer1D/BCESigmoid1D.swift:55-81 | Sources/GrAIdient/Layer1D/LinearError1D.swift:50-76 | Sources/GrAIdient/Layer1D/MSE1D.swift:50-76 — before extracting anything, compare `Sources/GrAIdient/Layer1D/BCE1D.swift` and `Sources/GrAIdient/Layer1D/BCESigmoid1D.swift` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 218 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (25–27 lines × 2) · ×1
  • Duplicated block (25–27 lines × 2) Sources/GrAIdient/Layer2D/Convolution2D.swift:1038 — Sources/GrAIdient/Layer2D/Convolution2D.swift:1038-1064 | Sources/GrAIdient/Layer2D/Deconvolution2D.swift:475-499 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Convolution2D.swift` and `Sources/GrAIdient/Layer2D/Deconvolution2D.swift` as WHOLE FILES: this scan already matched 26 separate duplicated blocks between them, totalling at least 499 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/GrAIdient/Layer2D/Convolution2D.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.
D4 · Code Duplication · Duplicated block (26 lines × 3) · ×1
  • Duplicated block (26 lines × 3) Sources/GrAIdient/Layer2D/VQ2D.swift:690 — Sources/GrAIdient/Layer2D/VQ2D.swift:690-715 | Sources/GrAIdient/LayerSeq/EmbeddingSeq.swift:663-688 | Sources/GrAIdient/LayerSeq/VQSeq.swift:613-638 — before extracting anything, compare `Sources/GrAIdient/Layer2D/VQ2D.swift` and `Sources/GrAIdient/LayerSeq/EmbeddingSeq.swift` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 97 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/GrAIdient/Layer2D/VQ2D.swift:690` 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/GrAIdient/Layer2D/VQ2D.swift:687` calls `UInt32`, `Float` and `Sources/GrAIdient/LayerSeq/EmbeddingSeq.swift:662` 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.
D4 · Code Duplication · Duplicated block (24–25 lines × 4) · ×1
  • Duplicated block (24–25 lines × 4) Sources/GrAIdient/Layer1D/FullyConnected.swift:1295 — Sources/GrAIdient/Layer1D/FullyConnected.swift:1295-1319 | Sources/GrAIdient/Layer2D/Convolution2D.swift:1891-1914 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:1373-1397 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:1257-1281 — before extracting anything, compare `Sources/GrAIdient/Layer1D/FullyConnected.swift` and `Sources/GrAIdient/Layer2D/Convolution2D.swift` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 103 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.
D4 · Code Duplication · Duplicated block (25 lines × 3) · ×1
  • Duplicated block (25 lines × 3) Sources/GrAIdient/Layer2D/BCE2D.swift:332 — Sources/GrAIdient/Layer2D/BCE2D.swift:332-356 | Sources/GrAIdient/Layer2D/BCESigmoid2D.swift:375-399 | Sources/GrAIdient/Layer2D/MSE2D.swift:328-352 — before extracting anything, compare `Sources/GrAIdient/Layer2D/BCE2D.swift` and `Sources/GrAIdient/Layer2D/BCESigmoid2D.swift` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 271 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/GrAIdient/Layer2D/BCE2D.swift:332` 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.
D4 · Code Duplication · Duplicated block (23–25 lines × 2) · ×1
  • Duplicated block (23–25 lines × 2) Sources/GrAIdient/Layer2D/Convolution2D.swift:1131 — Sources/GrAIdient/Layer2D/Convolution2D.swift:1131-1153 | Sources/GrAIdient/Layer2D/Deconvolution2D.swift:575-599 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Convolution2D.swift` and `Sources/GrAIdient/Layer2D/Deconvolution2D.swift` as WHOLE FILES: this scan already matched 26 separate duplicated blocks between them, totalling at least 499 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/GrAIdient/Layer2D/Convolution2D.swift:1131` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (22–25 lines × 2) · ×1
  • Duplicated block (22–25 lines × 2) Sources/GrAIdient/LayerSeq/QuerySeq.swift:184 — Sources/GrAIdient/LayerSeq/QuerySeq.swift:184-205 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:1428-1452 — both copies are in the same file, so extract the 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/GrAIdient/LayerSeq/QuerySeq.swift:184` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (24 lines × 6) · ×1
  • Duplicated block (24 lines × 6) Sources/GrAIdient/Layer2D/AdaIN.swift:251 — Sources/GrAIdient/Layer2D/AdaIN.swift:251-274 | Sources/GrAIdient/Layer2D/AdaIN.swift:369-392 | Sources/GrAIdient/Layer2D/Multiply2D.swift:173-196 | Sources/GrAIdient/Layer2D/Multiply2D.swift:263-286 | Sources/GrAIdient/Layer2D/Sum2D.swift:95-118 | Sources/GrAIdient/Layer2D/Sum2D.swift:185-208 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Multiply2D.swift` and `Sources/GrAIdient/Layer2D/Sum2D.swift` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 100 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/GrAIdient/Layer2D/AdaIN.swift:251` 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.
D4 · Code Duplication · Duplicated block (22–24 lines × 2) · ×1
  • Duplicated block (22–24 lines × 2) Sources/GrAIdient/Layer2D/Base/LayerOutput2D.swift:373 — Sources/GrAIdient/Layer2D/Base/LayerOutput2D.swift:373-394 | Sources/GrAIdient/Layer2D/Input2D.swift:470-493 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Base/LayerOutput2D.swift` and `Sources/GrAIdient/Layer2D/Input2D.swift` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 136 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.
D4 · Code Duplication · Duplicated block (23–24 lines × 2) · ×1
  • Duplicated block (23–24 lines × 2) Sources/GrAIdient/LayerSeq/QuerySeq.swift:392 — Sources/GrAIdient/LayerSeq/QuerySeq.swift:392-415 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:395-417 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/QuerySeq.swift` and `Sources/GrAIdient/LayerSeq/ValueSeq.swift` as WHOLE FILES: this scan already matched 39 separate duplicated blocks between them, totalling at least 427 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/GrAIdient/LayerSeq/QuerySeq.swift:392` 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 after the matched lines, `Sources/GrAIdient/LayerSeq/ValueSeq.swift:418` calls `get` and `Sources/GrAIdient/LayerSeq/QuerySeq.swift:415` 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.
D4 · Code Duplication · Duplicated block (21–23 lines × 6) · ×1
  • Duplicated block (21–23 lines × 6) Sources/GrAIdient/Layer2D/BCE2D.swift:104 — Sources/GrAIdient/Layer2D/BCE2D.swift:104-124 | Sources/GrAIdient/Layer2D/BCE2D.swift:174-194 | Sources/GrAIdient/Layer2D/BCESigmoid2D.swift:107-127 | Sources/GrAIdient/Layer2D/BCESigmoid2D.swift:197-217 | Sources/GrAIdient/Layer2D/MSE2D.swift:102-124 | Sources/GrAIdient/Layer2D/MSE2D.swift:172-192 — before extracting anything, compare `Sources/GrAIdient/Layer2D/BCE2D.swift` and `Sources/GrAIdient/Layer2D/BCESigmoid2D.swift` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 271 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/GrAIdient/Layer2D/BCE2D.swift:104` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (23 lines × 4) · ×1
  • Duplicated block (23 lines × 4) Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:275 — Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:275-297 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:322-344 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:252-274 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:298-320 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift` and `Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift` as WHOLE FILES: this scan already matched 54 separate duplicated blocks between them, totalling at least 760 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/GrAIdient/LayerSeq/FullyConnectedPatch.swift:275` 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.
D4 · Code Duplication · Duplicated block (22–23 lines × 3) · ×1
  • Duplicated block (22–23 lines × 3) Sources/GrAIdient/Layer2D/VQ2D.swift:727 — Sources/GrAIdient/Layer2D/VQ2D.swift:727-748 | Sources/GrAIdient/LayerSeq/EmbeddingSeq.swift:699-721 | Sources/GrAIdient/LayerSeq/VQSeq.swift:650-671 — before extracting anything, compare `Sources/GrAIdient/Layer2D/VQ2D.swift` and `Sources/GrAIdient/LayerSeq/EmbeddingSeq.swift` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 97 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/GrAIdient/Layer2D/VQ2D.swift:727` 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 · Duplicated block (22–23 lines × 2) · ×1
  • Duplicated block (22–23 lines × 2) Sources/GrAIdient/LayerSeq/RMSNormSeq.swift:187 — Sources/GrAIdient/LayerSeq/RMSNormSeq.swift:187-208 | Sources/GrAIdient/LayerSeq/RMSNormSeq.swift:231-253 — both copies are in the same file, so extract the 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/GrAIdient/LayerSeq/RMSNormSeq.swift:187` 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.
D4 · Code Duplication · Duplicated block (20–22 lines × 2) · ×1
  • Duplicated block (20–22 lines × 2) Sources/GrAIdient/Layer2D/Convolution2D.swift:842 — Sources/GrAIdient/Layer2D/Convolution2D.swift:842-863 | Sources/GrAIdient/Layer2D/Deconvolution2D.swift:270-289 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Convolution2D.swift` and `Sources/GrAIdient/Layer2D/Deconvolution2D.swift` as WHOLE FILES: this scan already matched 26 separate duplicated blocks between them, totalling at least 499 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/GrAIdient/Layer2D/Convolution2D.swift:842` 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.
D4 · Code Duplication · Duplicated block (21–22 lines × 2) · ×1
  • Duplicated block (21–22 lines × 2) Sources/GrAIdient/Layer2D/Normalize2D.swift:246 — Sources/GrAIdient/Layer2D/Normalize2D.swift:246-267 | Sources/GrAIdient/Layer2D/Normalize2D.swift:666-686 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/Layer2D/Normalize2D.swift:246` 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 · Duplicated block (21 lines × 4) · ×1
  • Duplicated block (21 lines × 4) Sources/GrAIdient/LayerSeq/MutiplySeq.swift:174 — Sources/GrAIdient/LayerSeq/MutiplySeq.swift:174-194 | Sources/GrAIdient/LayerSeq/MutiplySeq.swift:250-270 | Sources/GrAIdient/LayerSeq/SumSeq.swift:96-116 | Sources/GrAIdient/LayerSeq/SumSeq.swift:172-192 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/MutiplySeq.swift` and `Sources/GrAIdient/LayerSeq/SumSeq.swift` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 153 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/GrAIdient/LayerSeq/MutiplySeq.swift:174` 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.
D4 · Code Duplication · Duplicated block (21 lines × 3) · ×1
  • Duplicated block (21 lines × 3) Sources/GrAIdient/Layer1D/BCE1D.swift:368 — Sources/GrAIdient/Layer1D/BCE1D.swift:368-388 | Sources/GrAIdient/Layer1D/BCESigmoid1D.swift:387-407 | Sources/GrAIdient/Layer1D/MSE1D.swift:351-371 — before extracting anything, compare `Sources/GrAIdient/Layer1D/BCE1D.swift` and `Sources/GrAIdient/Layer1D/BCESigmoid1D.swift` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 218 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/Layer1D/BCE1D.swift:368` 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.
D4 · Code Duplication · Duplicated block (38–39 lines × 3) · ×1
  • Duplicated block (38–39 lines × 3) Sources/GrAIdient/Layer1D/FullyConnected.swift:1123 — Sources/GrAIdient/Layer1D/FullyConnected.swift:1123-1160 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:1199-1237 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:1084-1122 — before extracting anything, compare `Sources/GrAIdient/Layer1D/FullyConnected.swift` and `Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift` as WHOLE FILES: this scan already matched 32 separate duplicated blocks between them, totalling at least 473 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:1239` calls `setBytes` and `Sources/GrAIdient/Layer1D/FullyConnected.swift:1162` 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.
D4 · Code Duplication · Duplicated block (19–21 lines × 2) · ×1
  • Duplicated block (19–21 lines × 2) Sources/GrAIdient/Layer1D/Base/LayerOutput1D.swift:317 — Sources/GrAIdient/Layer1D/Base/LayerOutput1D.swift:317-335 | Sources/GrAIdient/Layer1D/Input1D.swift:368-388 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Base/LayerOutput1D.swift` and `Sources/GrAIdient/Layer1D/Input1D.swift` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 86 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. 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.
D4 · Code Duplication · Duplicated block (20 lines × 8) · ×1
  • Duplicated block (20 lines × 8) Sources/GrAIdient/Layer1D/BCE1D.swift:95 — Sources/GrAIdient/Layer1D/BCE1D.swift:95-114 | Sources/GrAIdient/Layer1D/BCE1D.swift:139-158 | Sources/GrAIdient/Layer1D/BCESigmoid1D.swift:98-117 | Sources/GrAIdient/Layer1D/BCESigmoid1D.swift:152-171 | Sources/GrAIdient/Layer1D/LinearError1D.swift:93-112 | Sources/GrAIdient/Layer1D/LinearError1D.swift:136-155 | Sources/GrAIdient/Layer1D/MSE1D.swift:93-112 | Sources/GrAIdient/Layer1D/MSE1D.swift:136-155 — before extracting anything, compare `Sources/GrAIdient/Layer1D/BCE1D.swift` and `Sources/GrAIdient/Layer1D/BCESigmoid1D.swift` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 218 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/Layer1D/BCE1D.swift:95` 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 · Duplicated block (19–20 lines × 4) · ×1
  • Duplicated block (19–20 lines × 4) Sources/GrAIdient/LayerSeq/ValueSeq.swift:175 — Sources/GrAIdient/LayerSeq/ValueSeq.swift:175-193 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:269-287 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:739-758 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:841-860 — 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/GrAIdient/LayerSeq/ValueSeq.swift:175` 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/GrAIdient/LayerSeq/ValueSeq.swift:266` calls `download` and `Sources/GrAIdient/LayerSeq/ValueSeq.swift:173` 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.
D4 · Code Duplication · Duplicated block (19–20 lines × 2) · ×1
  • Duplicated block (19–20 lines × 2) Sources/GrAIdient/LayerSeq/ConstantSeq.swift:839 — Sources/GrAIdient/LayerSeq/ConstantSeq.swift:839-857 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:713-732 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/ConstantSeq.swift` and `Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 61 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/LayerSeq/ConstantSeq.swift:839` 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.
D4 · Code Duplication · Duplicated block (19 lines × 5) · ×1
  • Duplicated block (19 lines × 5) Sources/GrAIdient/LayerSeq/ActivationSeq.swift:189 — Sources/GrAIdient/LayerSeq/ActivationSeq.swift:189-207 | Sources/GrAIdient/LayerSeq/LayerNormSeq.swift:383-401 | Sources/GrAIdient/LayerSeq/LayerNormSeq.swift:442-460 | Sources/GrAIdient/LayerSeq/RMSNormSeq.swift:397-415 | Sources/GrAIdient/LayerSeq/RMSNormSeq.swift:456-474 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/ActivationSeq.swift` and `Sources/GrAIdient/LayerSeq/LayerNormSeq.swift` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 132 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Sources/GrAIdient/LayerSeq/LayerNormSeq.swift:462` calls `download` and `Sources/GrAIdient/LayerSeq/LayerNormSeq.swift:404` 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.
D4 · Code Duplication · Duplicated block (19 lines × 3) · ×1
  • Duplicated block (19 lines × 3) Sources/GrAIdient/Core/Layer/LayerNormalization.swift:783 — Sources/GrAIdient/Core/Layer/LayerNormalization.swift:783-801 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1576-1594 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:2435-2453 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Sources/GrAIdient/Core/Layer/LayerNormalization.swift:775` calls `initStats` and `Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1568` 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.
D4 · Code Duplication · Duplicated block (17–19 lines × 3) · ×1
  • Duplicated block (17–19 lines × 3) Sources/GrAIdient/LayerSeq/ValueSeq.swift:450 — Sources/GrAIdient/LayerSeq/ValueSeq.swift:450-466 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1034-1052 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1958-1974 — 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/GrAIdient/LayerSeq/ValueSeq.swift:450` 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.
D4 · Code Duplication · Duplicated block (18–19 lines × 2) · ×1
  • Duplicated block (18–19 lines × 2) Sources/GrAIdient/Layer1D/FullyConnected.swift:797 — Sources/GrAIdient/Layer1D/FullyConnected.swift:797-814 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:688-706 — before extracting anything, compare `Sources/GrAIdient/Layer1D/FullyConnected.swift` and `Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift` as WHOLE FILES: this scan already matched 32 separate duplicated blocks between them, totalling at least 483 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/GrAIdient/Layer1D/FullyConnected.swift:797` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (17–19 lines × 2) · ×1
  • Duplicated block (17–19 lines × 2) Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift:309 — Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift:309-327 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift:414-430 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift:309` 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 · Duplicated block (18 lines × 4) · ×1
  • Duplicated block (18 lines × 4) Sources/GrAIdient/Layer2D/Convolution2D.swift:844 — Sources/GrAIdient/Layer2D/Convolution2D.swift:844-861 | Sources/GrAIdient/Layer2D/Convolution2D.swift:1040-1057 | Sources/GrAIdient/Layer2D/Deconvolution2D.swift:270-287 | Sources/GrAIdient/Layer2D/Deconvolution2D.swift:475-492 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Convolution2D.swift` and `Sources/GrAIdient/Layer2D/Deconvolution2D.swift` as WHOLE FILES: this scan already matched 26 separate duplicated blocks between them, totalling at least 499 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/GrAIdient/Layer2D/Convolution2D.swift:844` 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.
D4 · Code Duplication · Duplicated block (17–18 lines × 2) · ×1
  • Duplicated block (17–18 lines × 2) Sources/GrAIdient/Layer2D/Input2D.swift:199 — Sources/GrAIdient/Layer2D/Input2D.swift:199-216 | Sources/GrAIdient/Layer2D/Input2D.swift:241-257 — both copies are in the same file, so extract the 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/GrAIdient/Layer2D/Input2D.swift:199` 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 · Duplicated block (16–17 lines × 10) · ×1
  • Duplicated block (16–17 lines × 10) Sources/GrAIdient/Layer2D/Base/LayerOutput2D.swift:276 — Sources/GrAIdient/Layer2D/Base/LayerOutput2D.swift:276-291 | Sources/GrAIdient/Layer2D/Normalize2D.swift:87-103 | Sources/GrAIdient/Layer2D/Normalize2D.swift:444-460 | Sources/GrAIdient/Layer2D/Transform/Crop2D.swift:210-225 | Sources/GrAIdient/Layer2D/Transform/DecorrelateRGB.swift:129-144 | Sources/GrAIdient/Layer2D/Transform/Flip2D.swift:136-151 | Sources/GrAIdient/Layer2D/Transform/Flip2D.swift:393-408 | Sources/GrAIdient/Layer2D/Transform/IRDFT2RGB.swift:96-111 | Sources/GrAIdient/Layer2D/Transform/LinearScale2D.swift:124-139 | Sources/GrAIdient/Layer2D/Transform/Pad2D.swift:133-148 — there are 10 copies across 8 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 10 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/Layer2D/Base/LayerOutput2D.swift:276` 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.
D4 · Code Duplication · Duplicated block (16–17 lines × 5) · ×1
  • Duplicated block (16–17 lines × 5) Sources/GrAIdient/LayerSeq/QuerySeq.swift:592 — Sources/GrAIdient/LayerSeq/QuerySeq.swift:592-607 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:1066-1082 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:33-48 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:586-601 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1199-1214 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/QuerySeq.swift` and `Sources/GrAIdient/LayerSeq/ValueSeq.swift` as WHOLE FILES: this scan already matched 39 separate duplicated blocks between them, totalling at least 427 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/GrAIdient/LayerSeq/QuerySeq.swift:592` 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 · Duplicated block (16–17 lines × 3) · ×1
  • Duplicated block (16–17 lines × 3) Sources/GrAIdient/Layer1D/Activation1D.swift:180 — Sources/GrAIdient/Layer1D/Activation1D.swift:180-196 | Sources/GrAIdient/Layer1D/Base/LayerOutput1D.swift:232-247 | Sources/GrAIdient/Layer1D/SelectNeurons1D.swift:175-191 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Activation1D.swift` and `Sources/GrAIdient/Layer1D/Base/LayerOutput1D.swift` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 130 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/GrAIdient/Layer1D/Activation1D.swift:180` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (16 lines × 15) · ×1
  • Duplicated block (16 lines × 15) Sources/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:256 — Sources/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:256-271 | Sources/GrAIdient/Layer2D/Base/LayerOutput2D.swift:272-287 | Sources/GrAIdient/Layer2D/MaxPool2D.swift:239-254 | Sources/GrAIdient/Layer2D/Normalize2D.swift:83-98 | Sources/GrAIdient/Layer2D/Normalize2D.swift:440-455 | Sources/GrAIdient/Layer2D/Transform/Crop2D.swift:206-221 | Sources/GrAIdient/Layer2D/Transform/DecorrelateRGB.swift:125-140 | Sources/GrAIdient/Layer2D/Transform/Flip2D.swift:132-147 | Sources/GrAIdient/Layer2D/Transform/Flip2D.swift:389-404 | Sources/GrAIdient/Layer2D/Transform/IRDFT2RGB.swift:92-107 | Sources/GrAIdient/Layer2D/Transform/LinearScale2D.swift:120-135 | Sources/GrAIdient/Layer2D/Transform/Pad2D.swift:129-144 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:308-323 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift:271-286 | Sources/GrAIdient/Layer2D/Transform/Rotate2D.swift:216-231 — before extracting anything, compare `Sources/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift` and `Sources/GrAIdient/Layer2D/MaxPool2D.swift` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 44 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. 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/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:256` 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/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:325` calls `Double` and `Sources/GrAIdient/Layer2D/Base/LayerOutput2D.swift:289` 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.
D4 · Code Duplication · Duplicated block (16 lines × 11) · ×1
  • Duplicated block (16 lines × 11) Sources/GrAIdient/Layer1D/Activation1D.swift:248 — Sources/GrAIdient/Layer1D/Activation1D.swift:248-263 | Sources/GrAIdient/Layer1D/Base/LayerOutput1D.swift:292-307 | Sources/GrAIdient/Layer1D/Input1D.swift:346-361 | Sources/GrAIdient/Layer2D/Activation2D.swift:259-274 | Sources/GrAIdient/Layer2D/BN2D.swift:597-612 | Sources/GrAIdient/Layer2D/Base/LayerOutput2D.swift:348-363 | Sources/GrAIdient/Layer2D/Input2D.swift:448-463 | Sources/GrAIdient/Layer2D/InstanceNorm2D.swift:521-536 | Sources/GrAIdient/LayerSeq/ActivationSeq.swift:257-272 | Sources/GrAIdient/LayerSeq/LayerNormSeq.swift:517-532 | Sources/GrAIdient/LayerSeq/RMSNormSeq.swift:531-546 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Activation1D.swift` and `Sources/GrAIdient/Layer1D/Base/LayerOutput1D.swift` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 130 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Sources/GrAIdient/Layer1D/Activation1D.swift:265` calls `forwardGPU` and `Sources/GrAIdient/Layer1D/Base/LayerOutput1D.swift:308` 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.
D4 · Code Duplication · Duplicated block (10–16 lines × 4) · ×1
  • Duplicated block (10–16 lines × 4) Sources/GrAIdient/LayerSeq/QuerySeq.swift:159 — Sources/GrAIdient/LayerSeq/QuerySeq.swift:159-168 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:251-260 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:1387-1402 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:1513-1528 — 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/GrAIdient/LayerSeq/QuerySeq.swift:159` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Sources/GrAIdient/LayerSeq/QuerySeq.swift:263` calls `download` and `Sources/GrAIdient/LayerSeq/QuerySeq.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.
D4 · Code Duplication · Duplicated block (15 lines × 7) · ×1
  • Duplicated block (15 lines × 7) Sources/GrAIdient/LayerSeq/MutiplySeq.swift:168 — Sources/GrAIdient/LayerSeq/MutiplySeq.swift:168-182 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:128-142 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:1350-1364 | Sources/GrAIdient/LayerSeq/SumSeq.swift:90-104 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:132-146 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:694-708 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1400-1414 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/MutiplySeq.swift` and `Sources/GrAIdient/LayerSeq/QuerySeq.swift` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 61 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/LayerSeq/MutiplySeq.swift:168` 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.
D4 · Code Duplication · Duplicated block (15 lines × 5) · ×1
  • Duplicated block (15 lines × 5) Sources/GrAIdient/LayerSeq/QuerySeq.swift:219 — Sources/GrAIdient/LayerSeq/QuerySeq.swift:219-233 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:1473-1487 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:222-236 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:789-803 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1496-1510 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/QuerySeq.swift` and `Sources/GrAIdient/LayerSeq/ValueSeq.swift` as WHOLE FILES: this scan already matched 39 separate duplicated blocks between them, totalling at least 427 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/GrAIdient/LayerSeq/QuerySeq.swift:219` 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.
D4 · Code Duplication · Duplicated block (14 lines × 12) · ×1
  • Duplicated block (14 lines × 12) Sources/GrAIdient/LayerSeq/MutiplySeq.swift:170 — Sources/GrAIdient/LayerSeq/MutiplySeq.swift:170-183 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:130-143 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:221-234 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:1352-1365 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:1475-1488 | Sources/GrAIdient/LayerSeq/SumSeq.swift:92-105 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:134-147 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:224-237 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:696-709 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:791-804 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1402-1415 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1498-1511 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/MutiplySeq.swift` and `Sources/GrAIdient/LayerSeq/QuerySeq.swift` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 61 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/LayerSeq/MutiplySeq.swift:170` 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.
D4 · Code Duplication · Duplicated block (14 lines × 8) · ×1
  • Duplicated block (14 lines × 8) Sources/GrAIdient/Layer2D/Convolution2D.swift:868 — Sources/GrAIdient/Layer2D/Convolution2D.swift:868-881 | Sources/GrAIdient/Layer2D/Convolution2D.swift:901-914 | Sources/GrAIdient/Layer2D/Convolution2D.swift:997-1010 | Sources/GrAIdient/Layer2D/Convolution2D.swift:1285-1298 | Sources/GrAIdient/Layer2D/Deconvolution2D.swift:294-307 | Sources/GrAIdient/Layer2D/Deconvolution2D.swift:332-345 | Sources/GrAIdient/Layer2D/Deconvolution2D.swift:439-452 | Sources/GrAIdient/Layer2D/Deconvolution2D.swift:732-745 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Convolution2D.swift` and `Sources/GrAIdient/Layer2D/Deconvolution2D.swift` as WHOLE FILES: this scan already matched 26 separate duplicated blocks between them, totalling at least 499 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/GrAIdient/Layer2D/Convolution2D.swift:868` 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.
D4 · Code Duplication · Duplicated block (20–22 lines × 7) · ×1
  • Duplicated block (20–22 lines × 7) Sources/GrAIdient/Layer1D/BCE1D.swift:222 — Sources/GrAIdient/Layer1D/BCE1D.swift:222-241 | Sources/GrAIdient/Layer1D/BCESigmoid1D.swift:245-264 | Sources/GrAIdient/Layer1D/LinearError1D.swift:214-233 | Sources/GrAIdient/Layer1D/MSE1D.swift:218-237 | Sources/GrAIdient/Layer2D/BCE2D.swift:288-309 | Sources/GrAIdient/Layer2D/BCESigmoid2D.swift:331-352 | Sources/GrAIdient/Layer2D/MSE2D.swift:284-305 — before extracting anything, compare `Sources/GrAIdient/Layer1D/BCE1D.swift` and `Sources/GrAIdient/Layer1D/BCESigmoid1D.swift` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 218 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. 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. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Sources/GrAIdient/Layer2D/BCE2D.swift:287` calls `UInt32` and `Sources/GrAIdient/Layer1D/BCE1D.swift:221` 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.
D4 · Code Duplication · Duplicated block (14 lines × 7) · ×1
  • Duplicated block (14 lines × 7) Sources/GrAIdient/Layer2D/Normalize2D.swift:293 — Sources/GrAIdient/Layer2D/Normalize2D.swift:293-306 | Sources/GrAIdient/Layer2D/Normalize2D.swift:769-782 | Sources/GrAIdient/Layer2D/Transform/DecorrelateRGB.swift:304-317 | Sources/GrAIdient/Layer2D/Transform/Flip2D.swift:316-329 | Sources/GrAIdient/Layer2D/Transform/IRDFT2RGB.swift:289-302 | Sources/GrAIdient/Layer2D/Transform/LinearScale2D.swift:276-289 | Sources/GrAIdient/Layer2D/Transform/Rotate2D.swift:480-493 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Normalize2D.swift` and `Sources/GrAIdient/Layer2D/Transform/DecorrelateRGB.swift` as WHOLE FILES: this scan already matched 16 separate duplicated blocks between them, totalling at least 156 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/GrAIdient/Layer2D/Normalize2D.swift:293` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Sources/GrAIdient/Layer2D/Normalize2D.swift:291` calls `setBuffer` and `Sources/GrAIdient/Layer2D/Transform/IRDFT2RGB.swift:287` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (13–14 lines × 6) · ×1
  • Duplicated block (13–14 lines × 6) Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:503 — Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:503-516 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:629-642 | Sources/GrAIdient/LayerSeq/LayerNormSeq.swift:377-389 | Sources/GrAIdient/LayerSeq/LayerNormSeq.swift:436-448 | Sources/GrAIdient/LayerSeq/RMSNormSeq.swift:391-403 | Sources/GrAIdient/LayerSeq/RMSNormSeq.swift:450-462 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift` and `Sources/GrAIdient/LayerSeq/LayerNormSeq.swift` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 35 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/GrAIdient/LayerSeq/FullyConnectedSeq.swift:503` 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/GrAIdient/LayerSeq/FullyConnectedSeq.swift:644` calls `download` and `Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:518` 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.
D4 · Code Duplication · Duplicated block (14 lines × 5) · ×1
  • Duplicated block (14 lines × 5) Sources/GrAIdient/Layer2D/Deconvolution2D.swift:300 — Sources/GrAIdient/Layer2D/Deconvolution2D.swift:300-313 | Sources/GrAIdient/Layer2D/Deconvolution2D.swift:338-351 | Sources/GrAIdient/Layer2D/Deconvolution2D.swift:405-418 | Sources/GrAIdient/Layer2D/Deconvolution2D.swift:445-458 | Sources/GrAIdient/Layer2D/Deconvolution2D.swift:738-751 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/Layer2D/Deconvolution2D.swift:300` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (12–14 lines × 2) · ×1
  • Duplicated block (12–14 lines × 2) Sources/GrAIdient/Layer2D/Base/LayerMerge2D.swift:102 — Sources/GrAIdient/Layer2D/Base/LayerMerge2D.swift:102-113 | Sources/GrAIdient/LayerSeq/Base/LayerMergeSeq.swift:46-59 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Base/LayerMerge2D.swift` and `Sources/GrAIdient/LayerSeq/Base/LayerMergeSeq.swift` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 128 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/GrAIdient/Layer2D/Base/LayerMerge2D.swift:102` 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 · Duplicated block (12–13 lines × 14) · ×1
  • Duplicated block (12–13 lines × 14) Sources/GrAIdient/Layer1D/Activation1D.swift:317 — Sources/GrAIdient/Layer1D/Activation1D.swift:317-328 | Sources/GrAIdient/Layer1D/Base/LayerOutput1D.swift:358-369 | Sources/GrAIdient/Layer1D/Input1D.swift:408-419 | Sources/GrAIdient/Layer1D/Sum1D.swift:352-364 | Sources/GrAIdient/Layer2D/Activation2D.swift:330-341 | Sources/GrAIdient/Layer2D/BN2D.swift:671-682 | Sources/GrAIdient/Layer2D/Base/LayerOutput2D.swift:418-429 | Sources/GrAIdient/Layer2D/Input2D.swift:514-525 | Sources/GrAIdient/Layer2D/InstanceNorm2D.swift:595-606 | Sources/GrAIdient/Layer2D/Sum2D.swift:403-415 | Sources/GrAIdient/LayerSeq/ActivationSeq.swift:327-338 | Sources/GrAIdient/LayerSeq/LayerNormSeq.swift:590-601 | Sources/GrAIdient/LayerSeq/RMSNormSeq.swift:604-615 | Sources/GrAIdient/LayerSeq/SumSeq.swift:364-376 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Activation1D.swift` and `Sources/GrAIdient/Layer1D/Base/LayerOutput1D.swift` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 130 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/GrAIdient/Layer1D/Activation1D.swift:317` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (13 lines × 14) · ×1
  • Duplicated block (13 lines × 14) Sources/GrAIdient/LayerSeq/MutiplySeq.swift:172 — Sources/GrAIdient/LayerSeq/MutiplySeq.swift:172-184 | Sources/GrAIdient/LayerSeq/MutiplySeq.swift:248-260 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:132-144 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:223-235 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:1354-1366 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:1477-1489 | Sources/GrAIdient/LayerSeq/SumSeq.swift:94-106 | Sources/GrAIdient/LayerSeq/SumSeq.swift:170-182 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:136-148 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:226-238 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:698-710 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:793-805 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1404-1416 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1500-1512 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/MutiplySeq.swift` and `Sources/GrAIdient/LayerSeq/QuerySeq.swift` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 61 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (11–13 lines × 10) · ×1
  • Duplicated block (11–13 lines × 10) Sources/GrAIdient/Layer2D/BCE2D.swift:133 — Sources/GrAIdient/Layer2D/BCE2D.swift:133-143 | Sources/GrAIdient/Layer2D/BCE2D.swift:203-213 | Sources/GrAIdient/Layer2D/BCE2D.swift:388-398 | Sources/GrAIdient/Layer2D/BCESigmoid2D.swift:146-156 | Sources/GrAIdient/Layer2D/BCESigmoid2D.swift:236-246 | Sources/GrAIdient/Layer2D/BCESigmoid2D.swift:427-437 | Sources/GrAIdient/Layer2D/Base/LayerOutput2D.swift:193-203 | Sources/GrAIdient/Layer2D/MSE2D.swift:131-143 | Sources/GrAIdient/Layer2D/MSE2D.swift:200-210 | Sources/GrAIdient/Layer2D/MSE2D.swift:371-381 — before extracting anything, compare `Sources/GrAIdient/Layer2D/BCE2D.swift` and `Sources/GrAIdient/Layer2D/BCESigmoid2D.swift` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 271 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/GrAIdient/Layer2D/BCE2D.swift:133` it begins part-way through the construct above it, so those 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.
D4 · Code Duplication · Duplicated block (13 lines × 10) · ×1
  • Duplicated block (13 lines × 10) Sources/GrAIdient/Layer2D/Base/LayerOutput2D.swift:383 — Sources/GrAIdient/Layer2D/Base/LayerOutput2D.swift:383-395 | Sources/GrAIdient/Layer2D/Convolution2D.swift:1430-1442 | Sources/GrAIdient/Layer2D/Deconvolution2D.swift:798-810 | Sources/GrAIdient/Layer2D/Input2D.swift:480-494 | Sources/GrAIdient/Layer2D/Normalize2D.swift:254-269 | Sources/GrAIdient/Layer2D/Normalize2D.swift:674-688 | Sources/GrAIdient/Layer2D/SelfCorrelate2D.swift:234-247 | Sources/GrAIdient/Layer2D/Transform/DecorrelateRGB.swift:267-279 | Sources/GrAIdient/Layer2D/Transform/Flip2D.swift:279-291 | Sources/GrAIdient/Layer2D/Transform/Flip2D.swift:490-502 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Base/LayerOutput2D.swift` and `Sources/GrAIdient/Layer2D/Input2D.swift` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 136 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/GrAIdient/Layer2D/Base/LayerOutput2D.swift:383` 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.
D4 · Code Duplication · Duplicated block (13 lines × 5) · ×1
  • Duplicated block (13 lines × 5) Sources/GrAIdient/Layer2D/Activation2D.swift:192 — Sources/GrAIdient/Layer2D/Activation2D.swift:192-204 | Sources/GrAIdient/Layer2D/BN2D.swift:460-472 | Sources/GrAIdient/Layer2D/BN2D.swift:518-530 | Sources/GrAIdient/Layer2D/InstanceNorm2D.swift:384-396 | Sources/GrAIdient/Layer2D/InstanceNorm2D.swift:442-454 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Activation2D.swift` and `Sources/GrAIdient/Layer2D/BN2D.swift` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 171 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/GrAIdient/Layer2D/Activation2D.swift:192` 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.
D4 · Code Duplication · Duplicated block (10–13 lines × 3) · ×1
  • Duplicated block (10–13 lines × 3) Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1030 — Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1030-1039 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1921-1933 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:3205-3217 — 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/GrAIdient/Core/Layer/LayerNormalization.swift:1921` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (10–13 lines × 2) · ×1
  • Duplicated block (10–13 lines × 2) Sources/GrAIdient/Layer1D/Activation1D.swift:221 — Sources/GrAIdient/Layer1D/Activation1D.swift:221-233 | Sources/GrAIdient/Layer1D/Base/LayerOutput1D.swift:270-279 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Activation1D.swift` and `Sources/GrAIdient/Layer1D/Base/LayerOutput1D.swift` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 130 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/GrAIdient/Layer1D/Activation1D.swift:221` 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.
D4 · Code Duplication · Duplicated block (12 lines × 9) · ×1
  • Duplicated block (12 lines × 9) Sources/GrAIdient/LayerSeq/ConcatSeq.swift:60 — Sources/GrAIdient/LayerSeq/ConcatSeq.swift:60-71 | Sources/GrAIdient/LayerSeq/ConcatSeq.swift:492-503 | Sources/GrAIdient/LayerSeq/MutiplySeq.swift:79-90 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:103-114 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:1164-1175 | Sources/GrAIdient/LayerSeq/SumSeq.swift:68-79 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:107-118 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:667-678 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1290-1301 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/ConcatSeq.swift` and `Sources/GrAIdient/LayerSeq/MutiplySeq.swift` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 36 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/GrAIdient/LayerSeq/ConcatSeq.swift:60` 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 · Duplicated block (10–12 lines × 4) · ×1
  • Duplicated block (10–12 lines × 4) Sources/GrAIdient/LayerSeq/QuerySeq.swift:198 — Sources/GrAIdient/LayerSeq/QuerySeq.swift:198-207 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:301-310 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:1443-1454 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:1582-1593 — 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/GrAIdient/LayerSeq/QuerySeq.swift:198` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (11–12 lines × 4) · ×1
  • Duplicated block (11–12 lines × 4) Sources/GrAIdient/LayerSeq/ValueSeq.swift:154 — Sources/GrAIdient/LayerSeq/ValueSeq.swift:154-164 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:245-255 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:716-727 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:815-826 — 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/GrAIdient/LayerSeq/ValueSeq.swift:154` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. 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.
D4 · Code Duplication · Duplicated block (11–12 lines × 3) · ×1
  • Duplicated block (11–12 lines × 3) Sources/GrAIdient/Layer1D/DotProduct1D.swift:154 — Sources/GrAIdient/Layer1D/DotProduct1D.swift:154-165 | Sources/GrAIdient/Layer1D/Sum1D.swift:114-124 | Sources/GrAIdient/Layer1D/Sum1D.swift:187-197 — before extracting anything, compare `Sources/GrAIdient/Layer1D/DotProduct1D.swift` and `Sources/GrAIdient/Layer1D/Sum1D.swift` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 54 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/GrAIdient/Layer1D/DotProduct1D.swift:154` 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 · Duplicated block (10–12 lines × 3) · ×1
  • Duplicated block (10–12 lines × 3) Sources/GrAIdient/LayerSeq/QuerySeq.swift:150 — Sources/GrAIdient/LayerSeq/QuerySeq.swift:150-159 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:242-251 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:716-727 — 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/GrAIdient/LayerSeq/QuerySeq.swift:150` 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.
D4 · Code Duplication · Duplicated block (10–12 lines × 2) · ×1
  • Duplicated block (10–12 lines × 2) Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:723 — Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:723-732 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:758-769 — both copies are in the same file, so extract the 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/GrAIdient/LayerSeq/FullyConnectedPatch.swift:723` 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.
D4 · Code Duplication · Duplicated block (11 lines × 13) · ×1
  • Duplicated block (11 lines × 13) Sources/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:573 — Sources/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:573-583 | Sources/GrAIdient/Layer2D/Constant2D.swift:471-481 | Sources/GrAIdient/Layer2D/Normalize2D.swift:193-203 | Sources/GrAIdient/Layer2D/Normalize2D.swift:610-620 | Sources/GrAIdient/Layer2D/Transform/Crop2D.swift:310-320 | Sources/GrAIdient/Layer2D/Transform/DecorrelateRGB.swift:232-242 | Sources/GrAIdient/Layer2D/Transform/Flip2D.swift:243-253 | Sources/GrAIdient/Layer2D/Transform/IRDFT2RGB.swift:206-216 | Sources/GrAIdient/Layer2D/Transform/LinearScale2D.swift:210-220 | Sources/GrAIdient/Layer2D/Transform/Pad2D.swift:240-250 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:590-600 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift:516-526 | Sources/GrAIdient/Layer2D/Transform/Rotate2D.swift:381-391 — there are 13 copies across 12 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 13 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:573` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Sources/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:572` calls `setBytes` and `Sources/GrAIdient/Layer2D/Constant2D.swift:470` 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.
D4 · Code Duplication · Duplicated block (7–11 lines × 8) · ×1
  • Duplicated block (7–11 lines × 8) Sources/GrAIdient/Layer2D/Normalize2D.swift:181 — Sources/GrAIdient/Layer2D/Normalize2D.swift:181-187 | Sources/GrAIdient/Layer2D/Normalize2D.swift:538-548 | Sources/GrAIdient/Layer2D/Normalize2D.swift:595-601 | Sources/GrAIdient/Layer2D/Transform/DecorrelateRGB.swift:218-224 | Sources/GrAIdient/Layer2D/Transform/IRDFT2RGB.swift:194-200 | Sources/GrAIdient/Layer2D/Transform/LinearScale2D.swift:196-202 | Sources/GrAIdient/Layer2D/Transform/Pad2D.swift:224-230 | Sources/GrAIdient/Layer2D/VQ2D.swift:512-518 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Normalize2D.swift` and `Sources/GrAIdient/Layer2D/Transform/DecorrelateRGB.swift` as WHOLE FILES: this scan already matched 16 separate duplicated blocks between them, totalling at least 156 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/GrAIdient/Layer2D/Normalize2D.swift:181` 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/GrAIdient/Layer2D/Normalize2D.swift:549` calls `UInt32` and `Sources/GrAIdient/Layer2D/Normalize2D.swift:189` 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.
D4 · Code Duplication · Duplicated block (10–11 lines × 6) · ×1
  • Duplicated block (10–11 lines × 6) Sources/GrAIdient/Layer2D/Activation2D.swift:232 — Sources/GrAIdient/Layer2D/Activation2D.swift:232-242 | Sources/GrAIdient/Layer2D/BN2D.swift:569-579 | Sources/GrAIdient/Layer2D/Base/LayerOutput2D.swift:323-333 | Sources/GrAIdient/Layer2D/Input2D.swift:423-433 | Sources/GrAIdient/Layer2D/InstanceNorm2D.swift:493-503 | Sources/GrAIdient/Layer2D/Transform/LinearScale2D.swift:172-181 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Activation2D.swift` and `Sources/GrAIdient/Layer2D/BN2D.swift` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 171 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/GrAIdient/Layer2D/Activation2D.swift:232` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. 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.
D4 · Code Duplication · Duplicated block (11 lines × 6) · ×1
  • Duplicated block (11 lines × 6) Sources/GrAIdient/LayerSeq/ConstantSeq.swift:401 — Sources/GrAIdient/LayerSeq/ConstantSeq.swift:401-411 | Sources/GrAIdient/LayerSeq/ConstantSeq.swift:904-914 | Sources/GrAIdient/LayerSeq/SoftmaxSeq.swift:259-269 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:382-392 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:961-971 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1877-1887 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/SoftmaxSeq.swift` and `Sources/GrAIdient/LayerSeq/ValueSeq.swift` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 95 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/GrAIdient/LayerSeq/ConstantSeq.swift:401` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Sources/GrAIdient/LayerSeq/ValueSeq.swift:379` calls `setBuffer`, `setBytes` and `Sources/GrAIdient/LayerSeq/ConstantSeq.swift:400` 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.
D4 · Code Duplication · Duplicated block (9–11 lines × 2) · ×1
  • Duplicated block (9–11 lines × 2) Sources/GrAIdient/Layer2D/VQ2D.swift:552 — Sources/GrAIdient/Layer2D/VQ2D.swift:552-560 | Sources/GrAIdient/Layer2D/VQ2D.swift:795-805 — both copies are in the same file, so extract the 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/GrAIdient/Layer2D/VQ2D.swift:552` 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.
D4 · Code Duplication · Duplicated block (10 lines × 7) · ×1
  • Duplicated block (10 lines × 7) Sources/GrAIdient/LayerSeq/QuerySeq.swift:510 — Sources/GrAIdient/LayerSeq/QuerySeq.swift:510-519 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:538-547 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:961-970 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:984-993 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:2031-2040 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:2061-2070 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:2023-2032 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/QuerySeq.swift` and `Sources/GrAIdient/LayerSeq/ValueSeq.swift` as WHOLE FILES: this scan already matched 39 separate duplicated blocks between them, totalling at least 427 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (8–10 lines × 5) · ×1
  • Duplicated block (8–10 lines × 5) Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:305 — Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:305-312 | Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:377-384 | Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:460-467 | Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:596-605 | Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:680-689 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:305` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:387` calls `setBuffer` and `Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:316` 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.
D4 · Code Duplication · Duplicated block (10 lines × 5) · ×1
  • Duplicated block (10 lines × 5) Sources/GrAIdient/Layer2D/Convolution2D.swift:874 — Sources/GrAIdient/Layer2D/Convolution2D.swift:874-883 | Sources/GrAIdient/Layer2D/Convolution2D.swift:907-916 | Sources/GrAIdient/Layer2D/Convolution2D.swift:968-977 | Sources/GrAIdient/Layer2D/Convolution2D.swift:1003-1012 | Sources/GrAIdient/Layer2D/Convolution2D.swift:1291-1300 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/Layer2D/Convolution2D.swift:874` 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.
D4 · Code Duplication · Duplicated block (7–10 lines × 4) · ×1
  • Duplicated block (7–10 lines × 4) Sources/GrAIdient/Core/Layer/LayerNormalization.swift:870 — Sources/GrAIdient/Core/Layer/LayerNormalization.swift:870-876 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1715-1724 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1748-1757 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:3140-3149 — 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/GrAIdient/Core/Layer/LayerNormalization.swift:1715` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (7–10 lines × 3) · ×1
  • Duplicated block (7–10 lines × 3) Sources/GrAIdient/Core/Layer/LayerNormalization.swift:903 — Sources/GrAIdient/Core/Layer/LayerNormalization.swift:903-909 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1780-1789 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1814-1823 — 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/GrAIdient/Core/Layer/LayerNormalization.swift:1780` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (9–10 lines × 3) · ×1
  • Duplicated block (9–10 lines × 3) Sources/GrAIdient/LayerSeq/ValueSeq.swift:343 — Sources/GrAIdient/LayerSeq/ValueSeq.swift:343-351 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:917-926 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1629-1637 — 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/GrAIdient/LayerSeq/ValueSeq.swift:343` 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.
D4 · Code Duplication · Duplicated block (8–10 lines × 2) · ×1
  • Duplicated block (8–10 lines × 2) Sources/GrAIdient/Layer2D/SimilarityBatchError2D.swift:251 — Sources/GrAIdient/Layer2D/SimilarityBatchError2D.swift:251-258 | Sources/GrAIdient/Layer2D/SimilarityError2D.swift:613-622 — before extracting anything, compare `Sources/GrAIdient/Layer2D/SimilarityBatchError2D.swift` and `Sources/GrAIdient/Layer2D/SimilarityError2D.swift` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 66 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/GrAIdient/Layer2D/SimilarityError2D.swift:613` 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.
D4 · Code Duplication · Duplicated block (9 lines × 13) · ×1
  • Duplicated block (9 lines × 13) Sources/GrAIdient/LayerSeq/ActivationSeq.swift:137 — Sources/GrAIdient/LayerSeq/ActivationSeq.swift:137-145 | Sources/GrAIdient/LayerSeq/AvgPoolSeq.swift:54-62 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:238-246 | Sources/GrAIdient/LayerSeq/LayerCAMSeq.swift:86-94 | Sources/GrAIdient/LayerSeq/LayerNormSeq.swift:163-171 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:671-679 | Sources/GrAIdient/LayerSeq/RMSNormSeq.swift:174-182 | Sources/GrAIdient/LayerSeq/RoPESeq.swift:134-142 | Sources/GrAIdient/LayerSeq/SelectSeq.swift:86-94 | Sources/GrAIdient/LayerSeq/SoftmaxSeq.swift:98-106 | Sources/GrAIdient/LayerSeq/SoftmaxSeq.swift:447-455 | Sources/GrAIdient/LayerSeq/VQSeq.swift:202-210 | Sources/GrAIdient/LayerSeq/VQSeq.swift:994-1002 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/ActivationSeq.swift` and `Sources/GrAIdient/LayerSeq/LayerNormSeq.swift` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 132 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/GrAIdient/LayerSeq/ActivationSeq.swift:137` 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.
D4 · Code Duplication · Duplicated block (9 lines × 7) · ×1
  • Duplicated block (9 lines × 7) Sources/GrAIdient/Layer1D/Softmax1D.swift:241 — Sources/GrAIdient/Layer1D/Softmax1D.swift:241-249 | Sources/GrAIdient/Layer2D/AvgPool2D.swift:173-181 | Sources/GrAIdient/Layer2D/Normalize2D.swift:190-198 | Sources/GrAIdient/Layer2D/SelfCorrelate2D.swift:189-197 | Sources/GrAIdient/Layer2D/Transform/ColorJitterHSV.swift:317-325 | Sources/GrAIdient/Layer2D/Transform/IRDFT2RGB.swift:203-211 | Sources/GrAIdient/LayerSeq/AvgPoolSeq.swift:163-171 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Softmax1D.swift` and `Sources/GrAIdient/Layer2D/AvgPool2D.swift` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 34 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/GrAIdient/Layer1D/Softmax1D.swift:241` it begins part-way through the construct above it, so those 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/GrAIdient/Layer2D/AvgPool2D.swift:169` calls `UInt32` and `Sources/GrAIdient/Layer1D/Softmax1D.swift:238` 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.
D4 · Code Duplication · Duplicated block (8–9 lines × 7) · ×1
  • Duplicated block (8–9 lines × 7) Sources/GrAIdient/Layer2D/Activation2D.swift:234 — Sources/GrAIdient/Layer2D/Activation2D.swift:234-241 | Sources/GrAIdient/Layer2D/BN2D.swift:571-578 | Sources/GrAIdient/Layer2D/Base/LayerOutput2D.swift:325-332 | Sources/GrAIdient/Layer2D/Input2D.swift:425-432 | Sources/GrAIdient/Layer2D/InstanceNorm2D.swift:495-502 | Sources/GrAIdient/Layer2D/Transform/Crop2D.swift:266-274 | Sources/GrAIdient/Layer2D/Transform/LinearScale2D.swift:174-181 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Activation2D.swift` and `Sources/GrAIdient/Layer2D/BN2D.swift` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 171 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/GrAIdient/Layer2D/Activation2D.swift:234` 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.
D4 · Code Duplication · Duplicated block (9 lines × 6) · ×1
  • Duplicated block (9 lines × 6) Sources/GrAIdient/Layer2D/AvgPool2D.swift:242 — Sources/GrAIdient/Layer2D/AvgPool2D.swift:242-250 | Sources/GrAIdient/Layer2D/SelectNeurons2D.swift:344-352 | Sources/GrAIdient/Layer2D/Transform/Crop2D.swift:379-387 | Sources/GrAIdient/Layer2D/Transform/IRDFT2RGB.swift:282-290 | Sources/GrAIdient/Layer2D/Transform/Pad2D.swift:301-309 | Sources/GrAIdient/LayerSeq/AvgPoolSeq.swift:226-234 — before extracting anything, compare `Sources/GrAIdient/Layer2D/AvgPool2D.swift` and `Sources/GrAIdient/Layer2D/SelectNeurons2D.swift` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 100 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Sources/GrAIdient/Layer2D/SelectNeurons2D.swift:354` calls `setBytes` and `Sources/GrAIdient/Layer2D/AvgPool2D.swift:252` 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.
D4 · Code Duplication · Duplicated block (8–9 lines × 6) · ×1
  • Duplicated block (8–9 lines × 6) Sources/GrAIdient/LayerSeq/ValueSeq.swift:166 — Sources/GrAIdient/LayerSeq/ValueSeq.swift:166-173 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:257-264 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:729-737 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:828-836 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1438-1445 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1537-1544 — 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/GrAIdient/LayerSeq/ValueSeq.swift:166` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Sources/GrAIdient/LayerSeq/ValueSeq.swift:266` calls `download` and `Sources/GrAIdient/LayerSeq/ValueSeq.swift:175` 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.
D4 · Code Duplication · Duplicated block (4–9 lines × 3) · ×1
  • Duplicated block (4–9 lines × 3) Sources/GrAIdient/LayerSeq/ValueSeq.swift:1673 — Sources/GrAIdient/LayerSeq/ValueSeq.swift:1673-1676 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1852-1860 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1988-1996 — 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.
D4 · Code Duplication · Duplicated block (8 lines × 33) · ×1
  • Duplicated block (8 lines × 33) Sources/GrAIdient/Layer2D/Activation2D.swift:141 — Sources/GrAIdient/Layer2D/Activation2D.swift:141-148 | Sources/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:217-224 | Sources/GrAIdient/Layer2D/AvgPool2D.swift:55-62 | Sources/GrAIdient/Layer2D/BCE2D.swift:26-33 | Sources/GrAIdient/Layer2D/BCESigmoid2D.swift:29-36 | Sources/GrAIdient/Layer2D/BN2D.swift:240-247 | Sources/GrAIdient/Layer2D/Convolution2D.swift:538-545 | Sources/GrAIdient/Layer2D/Deconvolution2D.swift:134-141 | Sources/GrAIdient/Layer2D/InstanceNorm2D.swift:165-172 | Sources/GrAIdient/Layer2D/LayerCAM2D.swift:88-95 | Sources/GrAIdient/Layer2D/MSE2D.swift:24-31 | Sources/GrAIdient/Layer2D/MaxPool2D.swift:156-163 | Sources/GrAIdient/Layer2D/Normalize2D.swift:60-67 | Sources/GrAIdient/Layer2D/Normalize2D.swift:382-389 | Sources/GrAIdient/Layer2D/SelectNeurons2D.swift:133-140 | Sources/GrAIdient/Layer2D/SelectNeurons2D.swift:168-175 | Sources/GrAIdient/Layer2D/SelfCorrelate2D.swift:58-65 | Sources/GrAIdient/Layer2D/SimilarityBatchError2D.swift:57-64 | Sources/GrAIdient/Layer2D/Transform/ColorJitterHSV.swift:161-168 | Sources/GrAIdient/Layer2D/Transform/Crop2D.swift:168-175 | Sources/GrAIdient/Layer2D/Transform/DecorrelateRGB.swift:101-108 | Sources/GrAIdient/Layer2D/Transform/Flip2D.swift:108-115 | Sources/GrAIdient/Layer2D/Transform/Flip2D.swift:365-372 | Sources/GrAIdient/Layer2D/Transform/IRDFT2RGB.swift:69-76 | Sources/GrAIdient/Layer2D/Transform/LinearScale2D.swift:95-102 | Sources/GrAIdient/Layer2D/Transform/Pad2D.swift:104-111 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinear.swift:65-72 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:257-264 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift:228-235 | Sources/GrAIdient/Layer2D/Transform/Rotate2D.swift:173-180 | Sources/GrAIdient/Layer2D/VQ2D.swift:213-220 | Sources/GrAIdient/Layer2D/VQ2D.swift:1075-1082 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:261-268 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Activation2D.swift` and `Sources/GrAIdient/Layer2D/BN2D.swift` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 171 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/GrAIdient/Layer2D/Activation2D.swift:141` 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 · Duplicated block (8 lines × 10) · ×1
  • Duplicated block (8 lines × 10) Sources/GrAIdient/Layer1D/DotProduct1D.swift:329 — Sources/GrAIdient/Layer1D/DotProduct1D.swift:329-336 | Sources/GrAIdient/Layer1D/Dropout1D.swift:343-350 | Sources/GrAIdient/Layer2D/SelectNeurons2D.swift:275-282 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:939-946 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:841-848 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:378-385 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:827-834 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:1306-1313 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:1881-1888 | Sources/GrAIdient/LayerSeq/SelectSeq.swift:188-195 — there are 10 copies across 7 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 10 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/Layer1D/DotProduct1D.swift:329` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Sources/GrAIdient/Layer1D/DotProduct1D.swift:327` calls `setBuffer` and `Sources/GrAIdient/LayerSeq/QuerySeq.swift:1305` 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.
D4 · Code Duplication · Duplicated block (7–8 lines × 8) · ×1
  • Duplicated block (7–8 lines × 8) Sources/GrAIdient/Layer1D/DotProduct1D.swift:426 — Sources/GrAIdient/Layer1D/DotProduct1D.swift:426-433 | Sources/GrAIdient/Layer1D/DotProduct1D.swift:453-460 | Sources/GrAIdient/Layer1D/Dropout1D.swift:425-432 | Sources/GrAIdient/Layer1D/LinearError1D.swift:305-312 | Sources/GrAIdient/Layer1D/Softmax1D.swift:320-327 | Sources/GrAIdient/LayerSeq/AvgPoolSeq.swift:233-239 | Sources/GrAIdient/LayerSeq/SelectSeq.swift:270-277 | Sources/GrAIdient/LayerSeq/VQSeq.swift:589-595 — there are 8 copies across 7 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 8 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/Layer1D/DotProduct1D.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. 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/GrAIdient/LayerSeq/VQSeq.swift:586` calls `setBytes` and `Sources/GrAIdient/Layer1D/DotProduct1D.swift:423` 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.
D4 · Code Duplication · Duplicated block (8 lines × 7) · ×1
  • Duplicated block (8 lines × 7) Sources/GrAIdient/Layer2D/Normalize2D.swift:276 — Sources/GrAIdient/Layer2D/Normalize2D.swift:276-283 | Sources/GrAIdient/Layer2D/Transform/Crop2D.swift:368-375 | Sources/GrAIdient/Layer2D/Transform/DecorrelateRGB.swift:286-293 | Sources/GrAIdient/Layer2D/Transform/Flip2D.swift:298-305 | Sources/GrAIdient/Layer2D/Transform/IRDFT2RGB.swift:273-280 | Sources/GrAIdient/Layer2D/Transform/LinearScale2D.swift:258-265 | Sources/GrAIdient/Layer2D/Transform/Pad2D.swift:291-298 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Normalize2D.swift` and `Sources/GrAIdient/Layer2D/Transform/Crop2D.swift` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 109 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/GrAIdient/Layer2D/Normalize2D.swift:276` 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/GrAIdient/Layer2D/Transform/Crop2D.swift:377` calls `UInt32` and `Sources/GrAIdient/Layer2D/Normalize2D.swift:285` 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.
D4 · Code Duplication · Duplicated block (9 lines × 5) · ×1
  • Duplicated block (9 lines × 5) Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:294 — Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:294-302 | Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:366-374 | Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:449-457 | Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:583-591 | Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:667-675 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:294` 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/GrAIdient/Core/Optimizer/OptimizerImpl.swift:592` calls `Float` and `Sources/GrAIdient/Core/Optimizer/OptimizerImpl.swift:304` 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.
D4 · Code Duplication · Duplicated block (7–8 lines × 5) · ×1
  • Duplicated block (7–8 lines × 5) Sources/GrAIdient/Layer2D/Deconvolution2D.swift:346 — Sources/GrAIdient/Layer2D/Deconvolution2D.swift:346-353 | Sources/GrAIdient/Layer2D/Deconvolution2D.swift:413-420 | Sources/GrAIdient/Layer2D/Deconvolution2D.swift:453-460 | Sources/GrAIdient/Layer2D/Deconvolution2D.swift:746-753 | Sources/GrAIdient/Layer2D/Deconvolution2D.swift:836-842 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/Layer2D/Deconvolution2D.swift:346` 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.
D4 · Code Duplication · Duplicated block (8 lines × 5) · ×1
  • Duplicated block (8 lines × 5) Sources/GrAIdient/LayerSeq/QuerySeq.swift:372 — Sources/GrAIdient/LayerSeq/QuerySeq.swift:372-379 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:1873-1880 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:375-382 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:952-959 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1868-1875 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/QuerySeq.swift` and `Sources/GrAIdient/LayerSeq/ValueSeq.swift` as WHOLE FILES: this scan already matched 39 separate duplicated blocks between them, totalling at least 427 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (7–8 lines × 4) · ×1
  • Duplicated block (7–8 lines × 4) Sources/GrAIdient/Layer2D/Constant2D.swift:469 — Sources/GrAIdient/Layer2D/Constant2D.swift:469-476 | Sources/GrAIdient/LayerSeq/ConstantSeq.swift:399-406 | Sources/GrAIdient/LayerSeq/ConstantSeq.swift:902-909 | Sources/GrAIdient/LayerSeq/EmbeddingSeq.swift:595-601 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Constant2D.swift` and `Sources/GrAIdient/LayerSeq/ConstantSeq.swift` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 150 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/GrAIdient/Layer2D/Constant2D.swift:469` it begins part-way through the construct above it, so those 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/GrAIdient/LayerSeq/EmbeddingSeq.swift:594` calls `setBuffer` and `Sources/GrAIdient/Layer2D/Constant2D.swift:469` 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.
D4 · Code Duplication · Duplicated block (14–15 lines × 3) · ×1
  • Duplicated block (14–15 lines × 3) Sources/GrAIdient/Layer2D/Convolution2D.swift:1332 — Sources/GrAIdient/Layer2D/Convolution2D.swift:1332-1345 | Sources/GrAIdient/Layer2D/Convolution2D.swift:1527-1540 | Sources/GrAIdient/Layer2D/Convolution2D.swift:1589-1603 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Sources/GrAIdient/Layer2D/Convolution2D.swift:1525` calls `checkStateBackwardGPU` and `Sources/GrAIdient/Layer2D/Convolution2D.swift:1585` 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.
D4 · Code Duplication · Duplicated block (7–8 lines × 2) · ×1
  • Duplicated block (7–8 lines × 2) Sources/GrAIdient/Layer2D/AdaIN.swift:550 — Sources/GrAIdient/Layer2D/AdaIN.swift:550-557 | Sources/GrAIdient/Layer2D/AdaIN.swift:609-615 — both copies are in the same file, so extract the 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/GrAIdient/Layer2D/AdaIN.swift:550` 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.
D4 · Code Duplication · Duplicated block (7 lines × 59) · ×1
  • Duplicated block (7 lines × 59) Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1099 — Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1099-1105 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1889-1895 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:3177-3183 | Sources/GrAIdient/Layer1D/BCE1D.swift:393-399 | Sources/GrAIdient/Layer1D/BCESigmoid1D.swift:412-418 | Sources/GrAIdient/Layer1D/Concat1D.swift:380-386 | Sources/GrAIdient/Layer1D/DotProduct1D.swift:425-431 | Sources/GrAIdient/Layer1D/DotProduct1D.swift:452-458 | Sources/GrAIdient/Layer1D/Dropout1D.swift:424-430 | Sources/GrAIdient/Layer1D/LinearError1D.swift:304-310 | Sources/GrAIdient/Layer1D/MSE1D.swift:376-382 | Sources/GrAIdient/Layer1D/Softmax1D.swift:319-325 | Sources/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:782-788 | Sources/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:801-807 | Sources/GrAIdient/Layer2D/AvgPool2D.swift:248-254 | Sources/GrAIdient/Layer2D/BCE2D.swift:519-525 | Sources/GrAIdient/Layer2D/BCESigmoid2D.swift:554-560 | Sources/GrAIdient/Layer2D/Concat2D.swift:425-431 | Sources/GrAIdient/Layer2D/Convolution2D.swift:1566-1572 | Sources/GrAIdient/Layer2D/MSE2D.swift:489-495 | Sources/GrAIdient/Layer2D/MaxPool2D.swift:472-478 | Sources/GrAIdient/Layer2D/Normalize2D.swift:292-298 | Sources/GrAIdient/Layer2D/Normalize2D.swift:768-774 | Sources/GrAIdient/Layer2D/SelectNeurons2D.swift:351-357 | Sources/GrAIdient/Layer2D/SelfCorrelate2D.swift:275-281 | Sources/GrAIdient/Layer2D/SimilarityBatchError2D.swift:342-348 | Sources/GrAIdient/Layer2D/SimilarityError2D.swift:504-510 | Sources/GrAIdient/Layer2D/SimilarityError2D.swift:746-752 | Sources/GrAIdient/Layer2D/Transform/Crop2D.swift:387-393 | Sources/GrAIdient/Layer2D/Transform/DecorrelateRGB.swift:303-309 | Sources/GrAIdient/Layer2D/Transform/Flip2D.swift:315-321 | Sources/GrAIdient/Layer2D/Transform/IRDFT2RGB.swift:288-294 | Sources/GrAIdient/Layer2D/Transform/LinearScale2D.swift:275-281 | Sources/GrAIdient/Layer2D/Transform/Pad2D.swift:308-314 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:712-718 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift:645-651 | Sources/GrAIdient/Layer2D/Transform/Rotate2D.swift:479-485 | Sources/GrAIdient/Layer2D/VQ2D.swift:665-671 | Sources/GrAIdient/LayerSeq/AvgPoolSeq.swift:232-238 | Sources/GrAIdient/LayerSeq/ConcatSeq.swift:422-428 | Sources/GrAIdient/LayerSeq/ConcatSeq.swift:844-850 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:1112-1118 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:1002-1008 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:509-515 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:537-543 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:960-966 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:983-989 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:2030-2036 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:2060-2066 | Sources/GrAIdient/LayerSeq/RoPESeq.swift:458-464 | Sources/GrAIdient/LayerSeq/SelectSeq.swift:269-275 | Sources/GrAIdient/LayerSeq/SoftmaxSeq.swift:342-348 | Sources/GrAIdient/LayerSeq/VQSeq.swift:588-594 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:509-515 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:536-542 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1111-1117 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1140-1146 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:2022-2028 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:2051-2057 — before extracting anything, compare `Sources/GrAIdient/Layer1D/BCE1D.swift` and `Sources/GrAIdient/Layer1D/BCESigmoid1D.swift` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 218 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1099` 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/GrAIdient/Layer1D/DotProduct1D.swift:424` calls `setBytes` and `Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1098` 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.
D4 · Code Duplication · Duplicated block (7 lines × 35) · ×1
  • Duplicated block (7 lines × 35) Sources/GrAIdient/Layer1D/Concat1D.swift:279 — Sources/GrAIdient/Layer1D/Concat1D.swift:279-286 | Sources/GrAIdient/Layer1D/DotProduct1D.swift:329-335 | Sources/GrAIdient/Layer1D/Dropout1D.swift:343-349 | Sources/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:572-578 | Sources/GrAIdient/Layer2D/Concat2D.swift:320-326 | Sources/GrAIdient/Layer2D/Convolution2D.swift:1370-1376 | Sources/GrAIdient/Layer2D/LayerCAM2D.swift:188-194 | Sources/GrAIdient/Layer2D/Normalize2D.swift:609-615 | Sources/GrAIdient/Layer2D/SelectNeurons2D.swift:275-281 | Sources/GrAIdient/Layer2D/SimilarityError2D.swift:397-404 | Sources/GrAIdient/Layer2D/Transform/Crop2D.swift:309-315 | Sources/GrAIdient/Layer2D/Transform/DecorrelateRGB.swift:231-237 | Sources/GrAIdient/Layer2D/Transform/Flip2D.swift:242-248 | Sources/GrAIdient/Layer2D/Transform/LinearScale2D.swift:209-215 | Sources/GrAIdient/Layer2D/Transform/Pad2D.swift:239-245 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:589-595 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift:515-521 | Sources/GrAIdient/Layer2D/Transform/Rotate2D.swift:380-386 | Sources/GrAIdient/LayerSeq/ConcatSeq.swift:313-319 | Sources/GrAIdient/LayerSeq/ConcatSeq.swift:740-746 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:939-945 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:841-847 | Sources/GrAIdient/LayerSeq/LayerCAMSeq.swift:184-190 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:378-384 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:827-833 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:1698-1704 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:1881-1887 | Sources/GrAIdient/LayerSeq/RoPESeq.swift:370-376 | Sources/GrAIdient/LayerSeq/SelectSeq.swift:188-194 | Sources/GrAIdient/LayerSeq/SoftmaxSeq.swift:258-264 | Sources/GrAIdient/LayerSeq/SoftmaxSeq.swift:532-538 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:381-387 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:960-966 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1692-1698 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1876-1882 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Concat1D.swift` and `Sources/GrAIdient/Layer1D/DotProduct1D.swift` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 46 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/Layer1D/Concat1D.swift:279` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Sources/GrAIdient/Layer2D/Concat2D.swift:319` calls `setBytes` and `Sources/GrAIdient/Layer1D/Concat1D.swift:279` 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.
D4 · Code Duplication · Duplicated block (5–7 lines × 18) · ×1
  • Duplicated block (5–7 lines × 18) Sources/GrAIdient/Layer1D/FullyConnected.swift:1086 — Sources/GrAIdient/Layer1D/FullyConnected.swift:1086-1092 | Sources/GrAIdient/Layer1D/FullyConnected.swift:1158-1164 | Sources/GrAIdient/Layer2D/Constant2D.swift:535-539 | Sources/GrAIdient/Layer2D/Convolution2D.swift:1623-1629 | Sources/GrAIdient/Layer2D/Convolution2D.swift:1647-1653 | Sources/GrAIdient/Layer2D/Convolution2D.swift:1728-1734 | Sources/GrAIdient/Layer2D/VQ2D.swift:720-724 | Sources/GrAIdient/Layer2D/VQ2D.swift:772-776 | Sources/GrAIdient/LayerSeq/ConstantSeq.swift:461-467 | Sources/GrAIdient/LayerSeq/ConstantSeq.swift:970-974 | Sources/GrAIdient/LayerSeq/EmbeddingSeq.swift:691-697 | Sources/GrAIdient/LayerSeq/EmbeddingSeq.swift:743-749 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:1155-1161 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:1236-1242 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:1043-1049 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:1120-1126 | Sources/GrAIdient/LayerSeq/VQSeq.swift:643-647 | Sources/GrAIdient/LayerSeq/VQSeq.swift:695-699 — before extracting anything, compare `Sources/GrAIdient/Layer1D/FullyConnected.swift` and `Sources/GrAIdient/Layer2D/Constant2D.swift` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 36 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/GrAIdient/Layer1D/FullyConnected.swift:1086` 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/GrAIdient/Layer1D/FullyConnected.swift:1084` calls `setBuffer` and `Sources/GrAIdient/Layer1D/FullyConnected.swift:1156` 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.
D4 · Code Duplication · Duplicated block (7 lines × 17) · ×1
  • Duplicated block (7 lines × 17) Sources/GrAIdient/Layer1D/Concat1D.swift:47 — Sources/GrAIdient/Layer1D/Concat1D.swift:47-53 | Sources/GrAIdient/Layer1D/DotProduct1D.swift:93-99 | Sources/GrAIdient/Layer1D/Sum1D.swift:64-70 | Sources/GrAIdient/Layer2D/AdaIN.swift:137-143 | Sources/GrAIdient/Layer2D/Concat2D.swift:57-63 | Sources/GrAIdient/Layer2D/Multiply2D.swift:79-85 | Sources/GrAIdient/Layer2D/SimilarityError2D.swift:121-127 | Sources/GrAIdient/Layer2D/Sum2D.swift:68-74 | Sources/GrAIdient/LayerSeq/ConcatSeq.swift:59-65 | Sources/GrAIdient/LayerSeq/ConcatSeq.swift:491-497 | Sources/GrAIdient/LayerSeq/MutiplySeq.swift:78-84 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:102-108 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:1163-1169 | Sources/GrAIdient/LayerSeq/SumSeq.swift:67-73 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:106-112 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:666-672 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1289-1295 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Concat1D.swift` and `Sources/GrAIdient/Layer1D/DotProduct1D.swift` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 46 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/Layer1D/Concat1D.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.
D4 · Code Duplication · Duplicated block (7 lines × 16) · ×1
  • Duplicated block (7 lines × 16) Sources/GrAIdient/Layer1D/DotProduct1D.swift:329 — Sources/GrAIdient/Layer1D/DotProduct1D.swift:329-335 | Sources/GrAIdient/Layer1D/Dropout1D.swift:343-349 | Sources/GrAIdient/Layer2D/SelectNeurons2D.swift:275-281 | Sources/GrAIdient/LayerSeq/ConcatSeq.swift:313-319 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:939-945 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:841-847 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:378-384 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:827-833 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:1305-1312 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:1881-1887 | Sources/GrAIdient/LayerSeq/SelectSeq.swift:188-194 | Sources/GrAIdient/LayerSeq/SoftmaxSeq.swift:258-264 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:381-387 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:960-966 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1692-1698 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1876-1882 — there are 16 copies across 10 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 16 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/Layer1D/DotProduct1D.swift:329` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `Sources/GrAIdient/Layer1D/DotProduct1D.swift:327` calls `setBuffer`, `setBytes` and `Sources/GrAIdient/LayerSeq/QuerySeq.swift:1305` 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.
D4 · Code Duplication · Duplicated block (7 lines × 10) · ×1
  • Duplicated block (7 lines × 10) Sources/GrAIdient/LayerSeq/QuerySeq.swift:502 — Sources/GrAIdient/LayerSeq/QuerySeq.swift:502-508 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:530-536 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:2021-2027 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:2051-2057 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:502-508 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:529-535 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1103-1109 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1131-1137 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:2013-2019 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:2042-2048 — before extracting anything, compare `Sources/GrAIdient/LayerSeq/QuerySeq.swift` and `Sources/GrAIdient/LayerSeq/ValueSeq.swift` as WHOLE FILES: this scan already matched 39 separate duplicated blocks between them, totalling at least 427 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (7 lines × 8) · ×1
  • Duplicated block (7 lines × 8) Sources/GrAIdient/LayerSeq/ConcatSeq.swift:314 — Sources/GrAIdient/LayerSeq/ConcatSeq.swift:314-320 | Sources/GrAIdient/LayerSeq/ConstantSeq.swift:401-407 | Sources/GrAIdient/LayerSeq/ConstantSeq.swift:904-910 | Sources/GrAIdient/LayerSeq/SoftmaxSeq.swift:259-265 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:382-388 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:961-967 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1693-1700 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1877-1883 — there are 8 copies across 4 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 8 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/LayerSeq/ConcatSeq.swift:314` 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/GrAIdient/LayerSeq/ConcatSeq.swift:312` calls `setBytes` and `Sources/GrAIdient/LayerSeq/ConstantSeq.swift:400` 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.
D4 · Code Duplication · Duplicated block (6–7 lines × 3) · ×1
  • Duplicated block (6–7 lines × 3) Sources/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:555 — Sources/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:555-560 | Sources/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:751-756 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:692-698 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:692` 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.
D4 · Code Duplication · Duplicated block (6–7 lines × 2) · ×1
  • Duplicated block (6–7 lines × 2) Sources/GrAIdient/Layer2D/Normalize2D.swift:606 — Sources/GrAIdient/Layer2D/Normalize2D.swift:606-612 | Sources/GrAIdient/Layer2D/Normalize2D.swift:708-713 — both copies are in the same file, so extract the 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/GrAIdient/Layer2D/Normalize2D.swift:606` it begins part-way through the construct above it, so those 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/GrAIdient/Layer2D/Normalize2D.swift:707` calls `setBuffer` and `Sources/GrAIdient/Layer2D/Normalize2D.swift:606` 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.
D4 · Code Duplication · Duplicated block (6 lines × 21) · ×1
  • Duplicated block (6 lines × 21) Sources/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:570 — Sources/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:570-575 | Sources/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:610-615 | Sources/GrAIdient/Layer2D/MaxPool2D.swift:375-380 | Sources/GrAIdient/Layer2D/Normalize2D.swift:553-558 | Sources/GrAIdient/Layer2D/SelectNeurons2D.swift:273-278 | Sources/GrAIdient/Layer2D/Transform/Crop2D.swift:306-311 | Sources/GrAIdient/Layer2D/Transform/DecorrelateRGB.swift:229-234 | Sources/GrAIdient/Layer2D/Transform/Flip2D.swift:240-245 | Sources/GrAIdient/Layer2D/Transform/LinearScale2D.swift:207-212 | Sources/GrAIdient/Layer2D/Transform/Pad2D.swift:236-241 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:585-590 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift:510-515 | Sources/GrAIdient/Layer2D/Transform/Rotate2D.swift:377-382 | Sources/GrAIdient/LayerSeq/ConcatSeq.swift:310-315 | Sources/GrAIdient/LayerSeq/ConcatSeq.swift:737-742 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:822-827 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:1778-1783 | Sources/GrAIdient/LayerSeq/SelectSeq.swift:186-191 | Sources/GrAIdient/LayerSeq/SoftmaxSeq.swift:256-261 | Sources/GrAIdient/LayerSeq/SoftmaxSeq.swift:530-535 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1772-1777 — before extracting anything, compare `Sources/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift` and `Sources/GrAIdient/Layer2D/MaxPool2D.swift` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 44 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. 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/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:570` it begins part-way through the construct above it, so those 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/GrAIdient/Layer2D/MaxPool2D.swift:381` calls `setBytes`, `setBuffer` and `Sources/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:576` 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.
D4 · Code Duplication · Duplicated block (6 lines × 19) · ×1
  • Duplicated block (6 lines × 19) Sources/GrAIdient/Layer1D/Constant1D.swift:460 — Sources/GrAIdient/Layer1D/Constant1D.swift:460-466 | Sources/GrAIdient/Layer1D/FullyConnected.swift:1100-1106 | Sources/GrAIdient/Layer2D/AvgPool2D.swift:245-250 | Sources/GrAIdient/Layer2D/Constant2D.swift:531-537 | Sources/GrAIdient/Layer2D/Constant2D.swift:549-555 | Sources/GrAIdient/Layer2D/SelectNeurons2D.swift:347-352 | Sources/GrAIdient/Layer2D/Transform/Crop2D.swift:382-387 | Sources/GrAIdient/Layer2D/Transform/DecorrelateRGB.swift:299-304 | Sources/GrAIdient/Layer2D/Transform/IRDFT2RGB.swift:285-290 | Sources/GrAIdient/Layer2D/Transform/LinearScale2D.swift:271-276 | Sources/GrAIdient/Layer2D/Transform/Pad2D.swift:304-309 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:706-712 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift:639-645 | Sources/GrAIdient/Layer2D/Transform/Rotate2D.swift:475-481 | Sources/GrAIdient/LayerSeq/AvgPoolSeq.swift:229-234 | Sources/GrAIdient/LayerSeq/ConstantSeq.swift:984-990 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:1212-1218 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:1097-1103 | Sources/GrAIdient/LayerSeq/SelectSeq.swift:265-271 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Constant1D.swift` and `Sources/GrAIdient/Layer1D/FullyConnected.swift` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 51 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. 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/GrAIdient/Layer2D/AvgPool2D.swift:245` it begins part-way through the construct above it, so those 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/GrAIdient/Layer2D/Constant2D.swift:538` calls `setBytes` and `Sources/GrAIdient/Layer1D/Constant1D.swift:467` 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.
D4 · Code Duplication · Duplicated block (6 lines × 11) · ×1
  • Duplicated block (6 lines × 11) Sources/GrAIdient/Layer1D/DotProduct1D.swift:421 — Sources/GrAIdient/Layer1D/DotProduct1D.swift:421-426 | Sources/GrAIdient/Layer1D/DotProduct1D.swift:448-453 | Sources/GrAIdient/Layer2D/Convolution2D.swift:1618-1623 | Sources/GrAIdient/Layer2D/Convolution2D.swift:1639-1644 | Sources/GrAIdient/Layer2D/Convolution2D.swift:1683-1688 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:1149-1154 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:1193-1198 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:1039-1044 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:1080-1085 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:953-958 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:976-981 — there are 11 copies across 5 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 11 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/Layer1D/DotProduct1D.swift:421` it begins part-way through the construct above it, so those 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/GrAIdient/Layer2D/Convolution2D.swift:1626` calls `setBytes` and `Sources/GrAIdient/Layer1D/DotProduct1D.swift:429` 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.
D4 · Code Duplication · Duplicated block (6 lines × 6) · ×1
  • Duplicated block (6 lines × 6) Sources/GrAIdient/Layer2D/VQ2D.swift:661 — Sources/GrAIdient/Layer2D/VQ2D.swift:661-666 | Sources/GrAIdient/Layer2D/VQ2D.swift:717-722 | Sources/GrAIdient/Layer2D/VQ2D.swift:750-755 | Sources/GrAIdient/LayerSeq/VQSeq.swift:584-589 | Sources/GrAIdient/LayerSeq/VQSeq.swift:640-645 | Sources/GrAIdient/LayerSeq/VQSeq.swift:673-678 — before extracting anything, compare `Sources/GrAIdient/Layer2D/VQ2D.swift` and `Sources/GrAIdient/LayerSeq/VQSeq.swift` as WHOLE FILES: this scan already matched 30 separate duplicated blocks between them, totalling at least 378 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/GrAIdient/Layer2D/VQ2D.swift:660` calls `setBuffer` and `Sources/GrAIdient/Layer2D/VQ2D.swift:716` 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.
D4 · Code Duplication · Duplicated block (6 lines × 5) · ×1
  • Duplicated block (6 lines × 5) Sources/GrAIdient/Core/Layer/LayerNormalization.swift:2658 — Sources/GrAIdient/Core/Layer/LayerNormalization.swift:2658-2663 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:3091-3096 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:3162-3167 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:3193-3198 | Sources/GrAIdient/Core/Layer/LayerNormalization.swift:3227-3232 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
D4 · Code Duplication · Duplicated block (5 lines × 27) · ×1
  • Duplicated block (5 lines × 27) Sources/GrAIdient/Layer2D/MaxPool2D.swift:375 — Sources/GrAIdient/Layer2D/MaxPool2D.swift:375-380 | Sources/GrAIdient/Layer2D/Transform/Crop2D.swift:306-311 | Sources/GrAIdient/Layer2D/Transform/Pad2D.swift:236-241 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:585-590 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift:510-515 | Sources/GrAIdient/Layer2D/Transform/Rotate2D.swift:377-382 | Sources/GrAIdient/LayerSeq/ConcatSeq.swift:310-315 | Sources/GrAIdient/LayerSeq/ConcatSeq.swift:737-742 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:376-380 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:506-510 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:534-538 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:822-827 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:1778-1783 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:1877-1881 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:2025-2029 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:2055-2059 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:379-383 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:506-510 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:533-537 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:956-960 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1107-1111 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1135-1139 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1688-1692 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1772-1777 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1872-1876 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:2017-2021 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:2046-2050 — before extracting anything, compare `Sources/GrAIdient/Layer2D/MaxPool2D.swift` and `Sources/GrAIdient/Layer2D/Transform/Crop2D.swift` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 62 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/GrAIdient/Layer2D/MaxPool2D.swift:375` it begins part-way through the construct above it, so those 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/GrAIdient/Layer2D/MaxPool2D.swift:382` calls `setBytes`, `setBuffer` and `Sources/GrAIdient/Layer2D/Transform/Crop2D.swift:313` 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.
D4 · Code Duplication · Duplicated block (5 lines × 24) · ×1
  • Duplicated block (5 lines × 24) Sources/GrAIdient/Layer1D/Concat1D.swift:377 — Sources/GrAIdient/Layer1D/Concat1D.swift:377-382 | Sources/GrAIdient/Layer1D/DotProduct1D.swift:423-427 | Sources/GrAIdient/Layer1D/DotProduct1D.swift:450-454 | Sources/GrAIdient/Layer2D/Concat2D.swift:421-426 | Sources/GrAIdient/Layer2D/Convolution2D.swift:1620-1624 | Sources/GrAIdient/Layer2D/Convolution2D.swift:1641-1645 | Sources/GrAIdient/Layer2D/Convolution2D.swift:1685-1689 | Sources/GrAIdient/Layer2D/SelectNeurons2D.swift:348-353 | Sources/GrAIdient/Layer2D/SimilarityError2D.swift:501-506 | Sources/GrAIdient/Layer2D/Transform/Crop2D.swift:383-388 | Sources/GrAIdient/Layer2D/Transform/DecorrelateRGB.swift:300-305 | Sources/GrAIdient/Layer2D/Transform/Flip2D.swift:312-317 | Sources/GrAIdient/Layer2D/Transform/LinearScale2D.swift:272-277 | Sources/GrAIdient/Layer2D/Transform/Pad2D.swift:305-310 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:708-713 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift:641-646 | Sources/GrAIdient/LayerSeq/ConcatSeq.swift:418-423 | Sources/GrAIdient/LayerSeq/ConcatSeq.swift:840-845 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:1151-1155 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:1195-1199 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:1041-1045 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:955-959 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:978-982 | Sources/GrAIdient/LayerSeq/SoftmaxSeq.swift:340-344 — before extracting anything, compare `Sources/GrAIdient/Layer1D/Concat1D.swift` and `Sources/GrAIdient/Layer1D/DotProduct1D.swift` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 46 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `Sources/GrAIdient/Layer1D/Concat1D.swift:377` it begins part-way through the construct above it, so those 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/GrAIdient/Layer1D/DotProduct1D.swift:422` calls `setBuffer` and `Sources/GrAIdient/Layer1D/Concat1D.swift:377` 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.
D4 · Code Duplication · Duplicated block (5 lines × 21) · ×1
  • Duplicated block (5 lines × 21) Sources/GrAIdient/Layer2D/Concat2D.swift:320 — Sources/GrAIdient/Layer2D/Concat2D.swift:320-324 | Sources/GrAIdient/Layer2D/Convolution2D.swift:1370-1374 | Sources/GrAIdient/Layer2D/MaxPool2D.swift:379-383 | Sources/GrAIdient/Layer2D/Transform/Crop2D.swift:309-313 | Sources/GrAIdient/Layer2D/Transform/Pad2D.swift:239-243 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:589-593 | Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift:515-519 | Sources/GrAIdient/Layer2D/Transform/Rotate2D.swift:380-384 | Sources/GrAIdient/Layer2D/VQ2D.swift:1350-1354 | Sources/GrAIdient/LayerSeq/ConcatSeq.swift:313-317 | Sources/GrAIdient/LayerSeq/ConcatSeq.swift:740-744 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:939-943 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:378-382 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:827-831 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:1698-1702 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:1881-1885 | Sources/GrAIdient/LayerSeq/VQSeq.swift:1267-1271 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:381-385 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:960-964 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1692-1696 | Sources/GrAIdient/LayerSeq/ValueSeq.swift:1876-1880 — there are 21 copies across 14 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 21 sites; resolving a subset leaves the remainder to drift apart. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Sources/GrAIdient/Layer2D/MaxPool2D.swift:384` calls `setBuffer` and `Sources/GrAIdient/Layer2D/Concat2D.swift:326` 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.
D4 · Code Duplication · Duplicated block (5 lines × 16) · ×1
  • Duplicated block (5 lines × 16) Sources/GrAIdient/Layer1D/DotProduct1D.swift:423 — Sources/GrAIdient/Layer1D/DotProduct1D.swift:423-427 | Sources/GrAIdient/Layer1D/DotProduct1D.swift:450-454 | Sources/GrAIdient/Layer1D/FullyConnected.swift:1085-1089 | Sources/GrAIdient/Layer1D/Softmax1D.swift:318-322 | Sources/GrAIdient/Layer2D/Convolution2D.swift:1620-1624 | Sources/GrAIdient/Layer2D/Convolution2D.swift:1641-1645 | Sources/GrAIdient/Layer2D/Convolution2D.swift:1685-1689 | Sources/GrAIdient/LayerSeq/EmbeddingSeq.swift:690-694 | Sources/GrAIdient/LayerSeq/EmbeddingSeq.swift:723-727 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:1151-1155 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:1195-1199 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:1041-1045 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:1082-1086 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:955-959 | Sources/GrAIdient/LayerSeq/QuerySeq.swift:978-982 | Sources/GrAIdient/LayerSeq/SoftmaxSeq.swift:340-344 — before extracting anything, compare `Sources/GrAIdient/Layer1D/DotProduct1D.swift` and `Sources/GrAIdient/Layer1D/Softmax1D.swift` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 41 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `Sources/GrAIdient/Layer1D/DotProduct1D.swift:428` calls `setBytes` and `Sources/GrAIdient/Layer1D/FullyConnected.swift:1090` 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.
D4 · Code Duplication · Duplicated block (5 lines × 9) · ×1
  • Duplicated block (5 lines × 9) Sources/GrAIdient/Layer2D/Activation2D.swift:201 — Sources/GrAIdient/Layer2D/Activation2D.swift:201-205 | Sources/GrAIdient/Layer2D/BN2D.swift:469-473 | Sources/GrAIdient/Layer2D/BN2D.swift:482-486 | Sources/GrAIdient/Layer2D/BN2D.swift:527-531 | Sources/GrAIdient/Layer2D/Base/LayerOutput2D.swift:292-297 | Sources/GrAIdient/Layer2D/InstanceNorm2D.swift:393-397 | Sources/GrAIdient/Layer2D/InstanceNorm2D.swift:406-410 | Sources/GrAIdient/Layer2D/InstanceNorm2D.swift:451-455 | Sources/GrAIdient/Layer2D/Transform/LinearScale2D.swift:140-145 — before extracting anything, compare `Sources/GrAIdient/Layer2D/Activation2D.swift` and `Sources/GrAIdient/Layer2D/BN2D.swift` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 171 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/GrAIdient/Layer2D/Activation2D.swift:201` 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.
D4 · Code Duplication · Duplicated block (5 lines × 8) · ×1
  • Duplicated block (5 lines × 8) Sources/GrAIdient/Layer1D/FullyConnected.swift:1049 — Sources/GrAIdient/Layer1D/FullyConnected.swift:1049-1053 | Sources/GrAIdient/Layer2D/Convolution2D.swift:1560-1564 | Sources/GrAIdient/Layer2D/VQ2D.swift:525-529 | Sources/GrAIdient/Layer2D/VQ2D.swift:1348-1352 | Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:1108-1112 | Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:1000-1004 | Sources/GrAIdient/LayerSeq/VQSeq.swift:453-457 | Sources/GrAIdient/LayerSeq/VQSeq.swift:1265-1269 — before extracting anything, compare `Sources/GrAIdient/Layer1D/FullyConnected.swift` and `Sources/GrAIdient/Layer2D/Convolution2D.swift` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 103 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/GrAIdient/Layer2D/VQ2D.swift:1345` calls `setBuffer` and `Sources/GrAIdient/Layer1D/FullyConnected.swift:1047` 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.
D4 · Code Duplication · Duplicated block (5 lines × 5) · ×1
  • Duplicated block (5 lines × 5) Sources/GrAIdient/Layer2D/MaxPool2D.swift:379 — Sources/GrAIdient/Layer2D/MaxPool2D.swift:379-383 | Sources/GrAIdient/Layer2D/VQ2D.swift:526-530 | Sources/GrAIdient/Layer2D/VQ2D.swift:1350-1354 | Sources/GrAIdient/LayerSeq/VQSeq.swift:454-458 | Sources/GrAIdient/LayerSeq/VQSeq.swift:1267-1271 — before extracting anything, compare `Sources/GrAIdient/Layer2D/VQ2D.swift` and `Sources/GrAIdient/LayerSeq/VQSeq.swift` as WHOLE FILES: this scan already matched 30 separate duplicated blocks between them, totalling at least 378 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/GrAIdient/Layer2D/VQ2D.swift:1347` calls `setBuffer`, `setBytes` and `Sources/GrAIdient/Layer2D/VQ2D.swift:525` 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.
D4 · Code Duplication · Duplicated block (14 lines × 4) · ×1
  • Duplicated block (14 lines × 4) Sources/GrAIdient/Layer2D/VQ2D.swift:79 — Sources/GrAIdient/Layer2D/VQ2D.swift:79-92 | Sources/GrAIdient/LayerSeq/ConstantSeq.swift:39-52 | Sources/GrAIdient/LayerSeq/EmbeddingSeq.swift:52-65 | Sources/GrAIdient/LayerSeq/VQSeq.swift:63-76 — before extracting anything, compare `Sources/GrAIdient/Layer2D/VQ2D.swift` and `Sources/GrAIdient/LayerSeq/ConstantSeq.swift` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 41 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D5 · Coupling · Off the main sequence · ×1
  • Off the main sequence: GrAIdient — GrAIdient: abstractness 0.07, instability 0.00, distance 0.93 — zone of pain — concrete and depended on by 1 project(s), so it's rigid to change.
Minor — 193 finding(s)
D34 · Knowledge Freshness · Orphaned file · ×98
  • Orphaned file Sources/GrAIdient/Layer2D/Convolution2D.swift:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file Sources/GrAIdient/LayerSeq/FullyConnectedPatch.swift:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file Sources/GrAIdient/Layer2D/VQ2D.swift:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file Sources/GrAIdient/LayerSeq/FullyConnectedSeq.swift:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file Sources/GrAIdient/LayerSeq/VQSeq.swift:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file Sources/GrAIdient/Layer1D/FullyConnected.swift:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file Sources/GrAITestsUtils/Trainer.swift:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file Sources/GrAIdient/Metal/MetalKernel.swift:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file Sources/GrAIdient/Core/Model/Model.swift:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file Sources/GrAIdient/Layer2D/Deconvolution2D.swift:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file Sources/GrAIdient/LayerSeq/ConstantSeq.swift:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file Sources/GrAIdient/Layer2D/AdaptiveAvgPool2D.swift:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file Sources/GrAIdient/Layer2D/Normalize2D.swift:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file Sources/GrAIdient/LayerSeq/ConcatSeq.swift:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file Sources/GrAIdient/Core/Function/Activation.swift:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file Sources/GrAIdient/Layer2D/Transform/ResizeBilinearCrop.swift:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file Sources/GrAIdient/Layer2D/BN2D.swift:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file Sources/GrAIdient/Layer2D/Transform/ResizeBilinearPad.swift:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file Sources/GrAIdient/Layer2D/SimilarityError2D.swift:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file Sources/GrAIdient/LayerSeq/EmbeddingSeq.swift:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file Sources/GrAIdient/Layer2D/AdaIN.swift:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file Sources/GrAIdient/Layer2D/InstanceNorm2D.swift:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file Sources/GrAIdient/LayerSeq/RMSNormSeq.swift:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file Sources/GrAIdient/LayerSeq/LayerNormSeq.swift:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file Sources/GrAIdient/Layer2D/BCESigmoid2D.swift:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • + 73 more in this group — see findings.md.
D10 · Test Quality · No direct assertions · ×77
  • No direct assertions: test1_TrainSimpleModel Tests/GrAIExamples/AutoEncoderExample.swift:334 — No conventional assertion call was detected, and 12 of 16 tests in `GrAIExamples` read the same way — so this is treated as that project's convention rather than a broken test, and it does not drag the score. Two things look like this: verification that happens indirectly (an approval/verifier harness or BDD step methods), or a project of runnable samples compiled as tests, where a run that does not throw is the only check. If it is the latter, these methods genuinely verify nothing.
  • No direct assertions: test2_TrainUNetModel Tests/GrAIExamples/AutoEncoderExample.swift:349 — No conventional assertion call was detected, and 12 of 16 tests in `GrAIExamples` read the same way — so this is treated as that project's convention rather than a broken test, and it does not drag the score. Two things look like this: verification that happens indirectly (an approval/verifier harness or BDD step methods), or a project of runnable samples compiled as tests, where a run that does not throw is the only check. If it is the latter, these methods genuinely verify nothing.
  • No direct assertions: test3_TrainStyleModel Tests/GrAIExamples/AutoEncoderExample.swift:369 — No conventional assertion call was detected, and 12 of 16 tests in `GrAIExamples` read the same way — so this is treated as that project's convention rather than a broken test, and it does not drag the score. Two things look like this: verification that happens indirectly (an approval/verifier harness or BDD step methods), or a project of runnable samples compiled as tests, where a run that does not throw is the only check. If it is the latter, these methods genuinely verify nothing.
  • No direct assertions: test1_DumpLoad Tests/GrAIExamples/CIFARTests.swift:33 — No conventional assertion call was detected, and 12 of 16 tests in `GrAIExamples` read the same way — so this is treated as that project's convention rather than a broken test, and it does not drag the score. Two things look like this: verification that happens indirectly (an approval/verifier harness or BDD step methods), or a project of runnable samples compiled as tests, where a run that does not throw is the only check. If it is the latter, these methods genuinely verify nothing.
  • No direct assertions: test4_DumpTest Tests/GrAIExamples/CIFARTests.swift:117 — No conventional assertion call was detected, and 12 of 16 tests in `GrAIExamples` read the same way — so this is treated as that project's convention rather than a broken test, and it does not drag the score. Two things look like this: verification that happens indirectly (an approval/verifier harness or BDD step methods), or a project of runnable samples compiled as tests, where a run that does not throw is the only check. If it is the latter, these methods genuinely verify nothing.
  • No direct assertions: test1_DumpDataset Tests/GrAIExamples/TransformerExample.swift:228 — No conventional assertion call was detected, and 12 of 16 tests in `GrAIExamples` read the same way — so this is treated as that project's convention rather than a broken test, and it does not drag the score. Two things look like this: verification that happens indirectly (an approval/verifier harness or BDD step methods), or a project of runnable samples compiled as tests, where a run that does not throw is the only check. If it is the latter, these methods genuinely verify nothing.
  • No direct assertions: test2_TrainTransformer Tests/GrAIExamples/TransformerExample.swift:243 — No conventional assertion call was detected, and 12 of 16 tests in `GrAIExamples` read the same way — so this is treated as that project's convention rather than a broken test, and it does not drag the score. Two things look like this: verification that happens indirectly (an approval/verifier harness or BDD step methods), or a project of runnable samples compiled as tests, where a run that does not throw is the only check. If it is the latter, these methods genuinely verify nothing.
  • No direct assertions: test1_DumpDataset Tests/GrAIExamples/VGGExample.swift:270 — No conventional assertion call was detected, and 12 of 16 tests in `GrAIExamples` read the same way — so this is treated as that project's convention rather than a broken test, and it does not drag the score. Two things look like this: verification that happens indirectly (an approval/verifier harness or BDD step methods), or a project of runnable samples compiled as tests, where a run that does not throw is the only check. If it is the latter, these methods genuinely verify nothing.
  • No direct assertions: test2_DumpImages Tests/GrAIExamples/VGGExample.swift:295 — No conventional assertion call was detected, and 12 of 16 tests in `GrAIExamples` read the same way — so this is treated as that project's convention rather than a broken test, and it does not drag the score. Two things look like this: verification that happens indirectly (an approval/verifier harness or BDD step methods), or a project of runnable samples compiled as tests, where a run that does not throw is the only check. If it is the latter, these methods genuinely verify nothing.
  • No direct assertions: test3_UntrainedModel Tests/GrAIExamples/VGGExample.swift:334 — No conventional assertion call was detected, and 12 of 16 tests in `GrAIExamples` read the same way — so this is treated as that project's convention rather than a broken test, and it does not drag the score. Two things look like this: verification that happens indirectly (an approval/verifier harness or BDD step methods), or a project of runnable samples compiled as tests, where a run that does not throw is the only check. If it is the latter, these methods genuinely verify nothing.
  • No direct assertions: test4_TrainVGG Tests/GrAIExamples/VGGExample.swift:360 — No conventional assertion call was detected, and 12 of 16 tests in `GrAIExamples` read the same way — so this is treated as that project's convention rather than a broken test, and it does not drag the score. Two things look like this: verification that happens indirectly (an approval/verifier harness or BDD step methods), or a project of runnable samples compiled as tests, where a run that does not throw is the only check. If it is the latter, these methods genuinely verify nothing.
  • No direct assertions: test5_CompareModels Tests/GrAIExamples/VGGExample.swift:500 — No conventional assertion call was detected, and 12 of 16 tests in `GrAIExamples` read the same way — so this is treated as that project's convention rather than a broken test, and it does not drag the score. Two things look like this: verification that happens indirectly (an approval/verifier harness or BDD step methods), or a project of runnable samples compiled as tests, where a run that does not throw is the only check. If it is the latter, these methods genuinely verify nothing.
  • No direct assertions: testBigSlice Tests/GrAITests/ConcurrencyTests.swift:32 — No conventional assertion call was detected, and 65 of 76 tests in `GrAITests` read the same way — so this is treated as that project's convention rather than a broken test, and it does not drag the score. Two things look like this: verification that happens indirectly (an approval/verifier harness or BDD step methods), or a project of runnable samples compiled as tests, where a run that does not throw is the only check. If it is the latter, these methods genuinely verify nothing.
  • No direct assertions: testSmallSlice Tests/GrAITests/ConcurrencyTests.swift:39 — No conventional assertion call was detected, and 65 of 76 tests in `GrAITests` read the same way — so this is treated as that project's convention rather than a broken test, and it does not drag the score. Two things look like this: verification that happens indirectly (an approval/verifier harness or BDD step methods), or a project of runnable samples compiled as tests, where a run that does not throw is the only check. If it is the latter, these methods genuinely verify nothing.
  • No direct assertions: testVerySmallSlice Tests/GrAITests/ConcurrencyTests.swift:46 — No conventional assertion call was detected, and 65 of 76 tests in `GrAITests` read the same way — so this is treated as that project's convention rather than a broken test, and it does not drag the score. Two things look like this: verification that happens indirectly (an approval/verifier harness or BDD step methods), or a project of runnable samples compiled as tests, where a run that does not throw is the only check. If it is the latter, these methods genuinely verify nothing.
  • No direct assertions: testNoneSlice Tests/GrAITests/ConcurrencyTests.swift:53 — No conventional assertion call was detected, and 65 of 76 tests in `GrAITests` read the same way — so this is treated as that project's convention rather than a broken test, and it does not drag the score. Two things look like this: verification that happens indirectly (an approval/verifier harness or BDD step methods), or a project of runnable samples compiled as tests, where a run that does not throw is the only check. If it is the latter, these methods genuinely verify nothing.
  • No direct assertions: testRotate1CPU Tests/GrAITests/ImageTests.swift:385 — No conventional assertion call was detected, and 65 of 76 tests in `GrAITests` read the same way — so this is treated as that project's convention rather than a broken test, and it does not drag the score. Two things look like this: verification that happens indirectly (an approval/verifier harness or BDD step methods), or a project of runnable samples compiled as tests, where a run that does not throw is the only check. If it is the latter, these methods genuinely verify nothing.
  • No direct assertions: testRotate1GPU Tests/GrAITests/ImageTests.swift:394 — No conventional assertion call was detected, and 65 of 76 tests in `GrAITests` read the same way — so this is treated as that project's convention rather than a broken test, and it does not drag the score. Two things look like this: verification that happens indirectly (an approval/verifier harness or BDD step methods), or a project of runnable samples compiled as tests, where a run that does not throw is the only check. If it is the latter, these methods genuinely verify nothing.
  • No direct assertions: testRotate2CPU Tests/GrAITests/ImageTests.swift:403 — No conventional assertion call was detected, and 65 of 76 tests in `GrAITests` read the same way — so this is treated as that project's convention rather than a broken test, and it does not drag the score. Two things look like this: verification that happens indirectly (an approval/verifier harness or BDD step methods), or a project of runnable samples compiled as tests, where a run that does not throw is the only check. If it is the latter, these methods genuinely verify nothing.
  • No direct assertions: testRotate2GPU Tests/GrAITests/ImageTests.swift:412 — No conventional assertion call was detected, and 65 of 76 tests in `GrAITests` read the same way — so this is treated as that project's convention rather than a broken test, and it does not drag the score. Two things look like this: verification that happens indirectly (an approval/verifier harness or BDD step methods), or a project of runnable samples compiled as tests, where a run that does not throw is the only check. If it is the latter, these methods genuinely verify nothing.
  • No direct assertions: testRotate3CPU Tests/GrAITests/ImageTests.swift:421 — No conventional assertion call was detected, and 65 of 76 tests in `GrAITests` read the same way — so this is treated as that project's convention rather than a broken test, and it does not drag the score. Two things look like this: verification that happens indirectly (an approval/verifier harness or BDD step methods), or a project of runnable samples compiled as tests, where a run that does not throw is the only check. If it is the latter, these methods genuinely verify nothing.
  • No direct assertions: testRotate3GPU Tests/GrAITests/ImageTests.swift:430 — No conventional assertion call was detected, and 65 of 76 tests in `GrAITests` read the same way — so this is treated as that project's convention rather than a broken test, and it does not drag the score. Two things look like this: verification that happens indirectly (an approval/verifier harness or BDD step methods), or a project of runnable samples compiled as tests, where a run that does not throw is the only check. If it is the latter, these methods genuinely verify nothing.
  • No direct assertions: testFlipHorizontal1CPU Tests/GrAITests/ImageTests.swift:439 — No conventional assertion call was detected, and 65 of 76 tests in `GrAITests` read the same way — so this is treated as that project's convention rather than a broken test, and it does not drag the score. Two things look like this: verification that happens indirectly (an approval/verifier harness or BDD step methods), or a project of runnable samples compiled as tests, where a run that does not throw is the only check. If it is the latter, these methods genuinely verify nothing.
  • No direct assertions: testFlipHorizontal1GPU Tests/GrAITests/ImageTests.swift:448 — No conventional assertion call was detected, and 65 of 76 tests in `GrAITests` read the same way — so this is treated as that project's convention rather than a broken test, and it does not drag the score. Two things look like this: verification that happens indirectly (an approval/verifier harness or BDD step methods), or a project of runnable samples compiled as tests, where a run that does not throw is the only check. If it is the latter, these methods genuinely verify nothing.
  • No direct assertions: testFlipHorizontal2CPU Tests/GrAITests/ImageTests.swift:457 — No conventional assertion call was detected, and 65 of 76 tests in `GrAITests` read the same way — so this is treated as that project's convention rather than a broken test, and it does not drag the score. Two things look like this: verification that happens indirectly (an approval/verifier harness or BDD step methods), or a project of runnable samples compiled as tests, where a run that does not throw is the only check. If it is the latter, these methods genuinely verify nothing.
  • + 52 more in this group — see findings.md.
X10 · Duplicated predicate · Duplicated predicate · ×11
  • Duplicated predicate Sources/GrAIdient/Layer2D/SimilarityBatchError2D.swift:153 — `batchSize <= 0 || batchSize * batchSize > loss.nbElems` appears character-identically in 2 files — Sources/GrAIdient/Layer2D/SimilarityBatchError2D.swift, Sources/GrAIdient/Layer2D/SimilarityError2D.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/GrAIdient/Layer2D/Base/LayerOutput2D.swift:259 — `batchSize <= 0 || batchSize > loss.nbElems` appears character-identically in 2 files — Sources/GrAIdient/Layer2D/Base/LayerOutput2D.swift, Sources/GrAIdient/LayerSeq/VQSeq.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/GrAIdient/Layer1D/Base/Layer1D.swift:126 — `batchSize <= 0 || batchSize > neurons.get(0)!.v.count` appears character-identically in 4 files — Sources/GrAIdient/Layer1D/Base/Layer1D.swift, Sources/GrAIdient/Layer1D/Base/LayerOutput1D.swift, Sources/GrAIdient/Layer1D/LinearError1D.swift, Sources/GrAIdient/LayerSeq/Base/LayerSeq.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/GrAIdient/Layer1D/Base/Layer1D.swift:145 — `batchSize <= 0 || batchSize > outs.nbElems / nbNeurons` appears character-identically in 2 files — Sources/GrAIdient/Layer1D/Base/Layer1D.swift, Sources/GrAIdient/LayerSeq/Base/LayerSeq.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/GrAIdient/Layer1D/Constant1D.swift:279 — `computeDeltaWeights && GrAI.Gradient.sample && _wDeltaWeights == nil` appears character-identically in 10 files — Sources/GrAIdient/Layer1D/Constant1D.swift, Sources/GrAIdient/Layer1D/FullyConnected.swift, Sources/GrAIdient/Layer2D/Constant2D.swift, Sources/GrAIdient/Layer2D/Convolution2D.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/GrAIdient/Layer2D/Convolution2D.swift:921 — `depth == DEPTH && depthPrev == DEPTHPREV && k-startI == I && l-startJ == J` appears character-identically in 2 files — Sources/GrAIdient/Layer2D/Convolution2D.swift, Sources/GrAIdient/Layer2D/Deconvolution2D.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/GrAIdient/Core/State/Ensemble.swift:108 — `i >= 0 && j >= 0 && j < width && i < height` appears character-identically in 2 files — Sources/GrAIdient/Core/State/Ensemble.swift, Sources/GrAIdient/Core/State/Weights.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/GrAIdient/Layer2D/Concat2D.swift:31 — `layerPrev.height != layer0.height || layerPrev.width != layer0.width` appears character-identically in 2 files — Sources/GrAIdient/Layer2D/Concat2D.swift, Sources/GrAIdient/Layer2D/SimilarityError2D.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/GrAIdient/Layer2D/Multiply2D.swift:39 — `layerPrev.nbChannels != layer0.nbChannels || layerPrev.height != layer0.height || layerPrev.width != layer0.width` appears character-identically in 2 files — Sources/GrAIdient/Layer2D/Multiply2D.swift, Sources/GrAIdient/Layer2D/Sum2D.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/GrAIdient/LayerSeq/MutiplySeq.swift:40 — `layerPrev.nbNeurons != nbNeurons || layerPrev.sequence != sequence` appears character-identically in 2 files — Sources/GrAIdient/LayerSeq/MutiplySeq.swift, Sources/GrAIdient/LayerSeq/SumSeq.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/GrAIdient/Core/Function/Activation.swift:319 — `phase != nil && (phase == .Training || phase == .InferenceBackward)` appears character-identically in 3 files — Sources/GrAIdient/Core/Function/Activation.swift, Sources/GrAIdient/Layer2D/Multiply2D.swift, Sources/GrAIdient/LayerSeq/MutiplySeq.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.
D34 · Knowledge Freshness · Most significant orphaned file · ×3
  • Most significant orphaned file Sources/GrAIdient/Core/Layer/LayerNormalization.swift:1 — One of the orphaned files carrying the most lost knowledge — ranked by size weighted by the file's role in the codebase, the same weighting behind the score above, so core code outranks equally large plumbing. A reasonable place to start a read-through before the aggregate risk above bites.
  • Most significant orphaned file Sources/GrAIdient/LayerSeq/QuerySeq.swift:1 — One of the orphaned files carrying the most lost knowledge — ranked by size weighted by the file's role in the codebase, the same weighting behind the score above, so core code outranks equally large plumbing. A reasonable place to start a read-through before the aggregate risk above bites.
  • Most significant orphaned file Sources/GrAIdient/LayerSeq/ValueSeq.swift:1 — One of the orphaned files carrying the most lost knowledge — ranked by size weighted by the file's role in the codebase, the same weighting behind the score above, so core code outranks equally large plumbing. A reasonable place to start a read-through before the aggregate risk above bites.
D34 · Knowledge Freshness · Dormant codebase · ×1
  • Dormant codebase — 101 of 101 significant files have no living knowledge — the codebase as a whole is dormant, not 101 separate risks. Counted over 101 of the 105 production source files in this repository: the rest are under the ~2,400-byte size floor this dimension measures over. Re-engage owners or document before change.
D36 · Supply-chain Provenance & Signing · REDACTED · ×1
  • REDACTED
M2 · Architecture documentation · No ADRs · ×1
  • No ADRs — No Architecture Decision Records found — no conventional ADR directory, no numbered `NNNN-title` documents in any markup this check reads, and nothing ADR-shaped by content. Design rationale recorded elsewhere (a design-notes tree, a mailing list, pull-request discussion) is not visible to this check and is not re-findable per decision, so a future maintainer cannot ask why one choice was made and get an answer.
P3 · Security & performance tooling · No SAST · ×1
  • No SAST REDACTED:4 — No static application security testing detected. For this repository's stack, add CodeQL's Swift pack (Swift/Xcode) (or `semgrep --config=auto`, which runs on any language) as a CI step. What was searched, so you can tell an absence from a miss: the 3 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.
Minor — 1 finding(s)
D12 · Dependency Hygiene · Dependency hygiene PARTLY measured · ×1
  • Dependency hygiene PARTLY measured — SwiftPM pinning read, dependency currency NOT established — This repository's SwiftPM dependencies were read for PINNING discipline: 1 declaration(s) across 1 `Package.swift` manifest(s), against 1 committed pin(s). 1 pinning defect(s) are reported as separate rows below. That is only PART of dependency hygiene, so this dimension is NOT SCORED: whether any of these packages has a newer release is the dependency-CURRENCY question, and no dependency here resolves to a VERSION to ask about — each is pinned to a branch or a revision, which tracks whatever that ref points at and therefore cannot be behind a release. A clean pinning pass is NOT an all-clear for these dependencies, and it is not a finding that they are all USED. Note also what is deliberately NOT charged here: a published LIBRARY correctly commits no `Package.resolved` (SwiftPM ignores a library's resolution when the package is consumed), and a `path:` dependency is a local directory and the tightest possible binding, not a floating one. Known CVEs in the same dependency graph are a separate question, reported under D30 wherever the manifest is OSV-readable.

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.

DimensionToolVersionCommandFindingsRaw output
D28 · Secrets (history)gitleaks—gitleaks detect --no-banner --config /opt/gitleaks-rules/canine-gitleaks.toml --report-format json --report-path /tmp/watchdog-gitleaks-dcabb1fc37fe4ca2a4ba4c0e6f678993/history.json --exit-code 0 --source .0artifacts/raw/gitleaks-history.json
D28 · Secrets (history)gitleaks—gitleaks detect --no-git --no-banner --config /opt/gitleaks-rules/canine-gitleaks.toml --report-format json --report-path /tmp/watchdog-gitleaks-dcabb1fc37fe4ca2a4ba4c0e6f678993/tree.json --exit-code 0 --source .0artifacts/raw/gitleaks-tree.json
D29 · Static Analysis (SAST)semgrep—semgrep --config /opt/semgrep-rules/security-audit.yml --config /opt/semgrep-rules/owasp-top-ten.yml --config /opt/semgrep-rules/canine-sast.yml --json --quiet --timeout 10 --timeout-threshold 3 --metrics off --exclude *.arrow --exclude *.avro --exclude *.csv --exclude *.dat --exclude *.db --exclude *.feather --exclude *.geojson --exclude *.h5 --exclude *.hdf5 --exclude *.jsonl --exclude *.log --exclude *.ndjson --exclude *.npy --exclude *.npz --exclude *.orc --exclude *.parquet --exclude *.pickle --exclude *.pkl --exclude *.psv --exclude *.sqlite --exclude *.sqlite3 --exclude *.tfrecord --exclude *.tsv --exclude *.txt .6artifacts/raw/semgrep.json
D30 · Dependency Vulnerabilitiesosv-scanner—osv-scanner --format json --recursive --experimental-disable-plugins transitivedependency/requirements --experimental-disable-plugins dotnet/csproj --experimental-disable-plugins dotnet/nugetcpm .0artifacts/raw/osv-scanner.json
D31 · IaC & Container Securitytrivy—trivy: not applicable — No Infrastructure-as-Code or container manifests found (Dockerfile, Docker Compose, Terraform, Kubernetes/Helm, CloudFormation, ARM, Bicep, Ansible); nothing to scan.0—
D32 · Data Compliance (PII/GDPR)semgrep—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.0—
D37 · Vulnerability-disclosure Policydisclosure—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.0—
D40 · Network Egress Confinementruntime-hardening—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.0—
D41 · Kernel & Syscall Confinementruntime-hardening—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.0—
D42 · Runtime Threat Enforcementruntime-hardening—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.0—
D43 · Malicious Dependenciesosv-scanner—osv-scanner --format json --recursive --experimental-disable-plugins transitivedependency/requirements --experimental-disable-plugins dotnet/csproj --experimental-disable-plugins dotnet/nugetcpm .0artifacts/raw/osv-scanner.json

Run 01a1e903-a87c-76bc-8881-2c318bc0b067 · every finding is also locatable in findings.md, and the complete scoring record (with exit codes + durations) in sidecar.json.

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.

⬇ Findings, MITRE CWE-tagged .sarif⬇ Health changelog .md