Public report of MomentsLD/moments, published 15 November 2026. It has the same score, grades and number of
findings as the full report. The details of security findings (where they are in the code, which known
vulnerabilities and which passwords or keys were found) are left out, so nobody can use them against the project.
Public
Executive reportMeasured under the Code Assurance Index, an open standard for code quality, using its published scoring rules (rubric version 2026.11.4). Assert signed this survey and filed it in the standard's public register, where anyone can look it up by its survey ID. Check this survey →
Signed and filed in the standard's public register, 15 November 2026, 11:39 UTC · Survey ID cd_406d7e38d5ae4b95ae95beedce0720a7
MomentsLD/moments
Measured 15 November 2026, 11:39 UTC, at code version c985309
Knowledge freshness is not measured: Freshness signal contradicted by repo activity.
CAI scoreAdequate
CriticalWeakAdequateStrongExemplary
Down 2 since the last survey
The score is built from these lenses. Each lens grades one area of the code, such as how easy it is to change or how well it is protected. The weakest lens counts most, so one weak area pulls the score down instead of being averaged away.
A medium codebase: 32,861 lines of product code in 1 project, tests not counted · Estimated rebuild effort: about 0.3 person-years · Weakest lens: Production Readiness, 49
Findings by how serious they are
42 critical564 serious14 minor
33 dimensions are left out of the score. For each one, we either couldn't measure it in this code, or found no evidence of the safeguard we look for, such as a tested backup restore. They count neither for nor against the score, and Limitations lists each one with its reason.
This survey was produced by
Canine Code Analyzer
Producer
Canine Development
Analyzer
Canine Code Analyzer engine 1.0.0
Measured
15 November 2026, 11:39 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 ▸
32of 32 dimensions measured by tools.
612of 620 findings point to an exact file and line, so you can open each one in the code. The other 8 concern the repository as a whole, such as missing documentation.
32dimensions across 5 lenses, read from 32,861 lines of product code in 1 project.
MomentsLD/moments falls short of our standard for production because we found no automated security scanning of the code, its secrets or its dependencies. It scores 54 out of 100 and is rated Adequate, and all 42 of its critical findings are security problems in the build pipeline and in its code.
Production Readiness, at 49, is the weakest lens, level with Maturity, and counts most in the score. The best first step is fixing the part of the code only one person knows, worth about 4 points. Adding automated security scanning would lift Production Readiness itself, also worth about 4. Raising Production Readiness to 70 would lift the score to about 58.
Twenty-five pipeline tools are referenced by a changeable name, so the build pipeline can be tampered with. Thirteen places in the code run text as code, which an attacker could use, and three pipeline steps install packages that can change without warning. Pinning each tool to an exact version, replacing text run as code with direct calls and pinning what the pipeline installs would close these risks. Limiting each secret to its own step would fix the secret exposed to more of the pipeline than needed.
The product code is 32,861 lines, about €41,000 to rebuild.
A lens is capped at Adequate while one of its dimensions scores below 4 out of 10, however well the rest of the lens does. That way a serious problem in one place always shows in the lens's rating.
How the score is built: what each lens counts forThe lenses don't count equally. The weakest lens counts most, the next weakest a little less, and so on, so a weak area pulls the score down instead of being averaged away. In the bar below, each part's width shows how much that lens counts and its colour shows its rating. Improving the widest part moves the score most, and as that lens improves, it counts for less, because another lens becomes the weakest.
We compare every finding with the previous survey's. A finding that has only moved to another line in the same file counts as the same finding, so only new findings appear here. Advisory notes from the AI model are left out, because the model words them afresh in every survey.
Fixed since the last survey: 77 findings
These 77 critical or serious findings were in the previous survey, on 31 October 2026, and are gone from this one.
€14,000 to €69,000, for 227 to 721 hours of work, about 0.3 person-years for one engineer
Difficulty of the problem
Standard, judged from the kind of software and how it is built. Code that solves a harder problem, such as payments or medical bookings, costs more per line to write.
Quality factor
×0.7 at a score of 54. Better code takes more work to write, so the factor is ×1.0 at a score of 70, lower below it and higher above it.
Size
Medium: 32,861 lines of product code
What it is not
Not a quotation: nobody has offered to build it for that. Not a valuation: it says nothing about what the business is worth. Not a certified figure: no professional has signed it as one.
How the estimate is made: We price the hours a team would need to write this code again, at €60 to €95 an hour. Declarations and boilerplate are priced at a fast rate and logic at a slower one, and the logic is then multiplied by the difficulty of the problem and by the quality factor. The estimate can be about 30% off either way, and it moves most with the hourly rate and the difficulty. For this code, every line is priced as straight logic, which keeps the estimate on the low side.
Top priorities
The three actions that raise the score most for the work they take. The full ranked list is in the Roadmap.
1
Resolve the 1 Off-boarding risk finding(s) in Bus Factor.
Raises the score by about 4 points · Low effort · Bus Factor
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.
Add a SAST step to CI running what this repository's stack ships: bandit, `semgrep --config=p/python`, or CodeQL's python pack — so a security regression fails the build instead of landing.
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 3.5 out of 10. Code at that level is slower to change than clean code, and we estimate the extra work at 11% to 25% on every change. The history of the code shows how much it changes: about 10,933 lines over the last 90 days, which is about 44,339 lines a year. At that pace, the extra work comes to an estimated 12.5 to 74.8 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 €41,000 to build again, about 0.3 person-years of work. Its weakest lens is Production Readiness, at 49 (Weak). Production Readiness is about whether the product is ready to run in production and to change without breaking. Because the weakest lens counts most in the score, work on Production Readiness also moves the score most.
Based on: the rebuild estimate · the Production Readiness grade · how much each lens counts
What to do: Start with the Production Readiness actions in Top priorities.
If you do one thing first · First action
Resolve the 1 Off-boarding risk finding(s) in Bus Factor. Of all the actions in this report, it raises the score most for the work it takes: about 4 points for low effort, because it clears the 1 Bus Factor findings. The next survey will show the change in the score.
Based on: the ranked actions in Top priorities, by score gain and effort
At a glance — Code Health · 60% · Checked 5 of 11 · gated by D1, D2, D4 ·
Findings mapped to OWASP categories; the specific CVEs/secrets are in the Security dimension cards below and findings.md (redacted only on the public version of this report).
OWASP category
Findings
Severity
A05:2025 — Injection
52
High / Critical
A03:2025 — Software Supply Chain Failures
6
Medium
Roadmap
Top priorities: 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: bandit, `semgrep --config=p/python`, or CodeQL's python pack — so a security regression fails the build instead of landing; Resolve the 1 Off-boarding risk finding(s) in Bus Factor.
Ranked by impact ÷ effort. "Helps" is the estimated gain on the 0–100 health score.
Do this
Helps
Effort
Dimension
Resolve the 1 Off-boarding risk finding(s) in Bus Factor.
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: bandit, `semgrep --config=p/python`, or CodeQL's python pack — so a security regression fails the build instead of landing.
Make sure a person approves each release. The release job names an environment, but its approval rules live in the code host's settings, where we can't see them. Check that a reviewer must approve each release, or publish releases as drafts first, so a bad build can be stopped before anyone downloads it.
Explain in the README how to run the tests. Add a section called Testing to the README in the repository's top folder, saying how to run the test suite.
Bring the 47 bodies over 30 down to 30 or less in Cognitive Complexity — start with Matrices.migration_ld (cognitive 358), Parsing._tally_vcf (cognitive 158), Demes.SFS (cognitive 152).
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 — 42
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 — 564
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 — 14
Recorded, with no effect on how the codebase functions.
Present so the survey is complete, not because it needs doing.
Could not be resolved — 33
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 32 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 — 32 dimensions across the health lenses
Each chip is a dimension scored from real signals across architecture, testing, dependencies, security & compliance, documentation, git-history and code quality — in one coherent pass. A surface report typically covers a handful.
How to trust any code-health report — three questions
Can you open the finding? Real findings cite a repo-relative file and line you can open at the cited line — never an absolute scratch path. Here, 612 of 620 do; the remainder are repo-wide signals — a dimension-level measurement, not a single line. (Every path in this report is repo-relative by construction: paths are normalized at the producer and the report is rejected if any rooted path leaks through.)
Is there a tool behind the number? Every score below names the method that produced it: Roslyn, git or a scanner, not a narrative.
Does re-running give the same result? Run it again on the same commit and the score — and this report, byte for byte — is identical. A report whose numbers move between runs is describing the run, not the code.
This report answers yes to all three. That's the bar to hold any assessment to.
Tools & methods
The actual versions used this run (captured at analysis time) — re-run on the same commit for the identical score.
Method
Backs
Version
Evaluator
Roslyn static analysis
Complexity, cohesion, coupling, dead code, API surface, layering
What ran differently this time — a tool absent, degraded, or that fell back to an estimate. Named openly, not folded silently into the scores. A degraded run also records its exact cause in diagnostics.md.
D8 Code Coverage — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. Coverage NOT MEASURED: test source is present (.py, .fs) but the built-in coverage collector has no runner for this repository's ecosystem — so this suite was never executed by it. Not scored — this is a gap in the analyzer's language coverage, not a defect in the repo.
D11 Test Reliability — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. Test source is present (.py, .fs) and this repository declares a Python test suite (repository root, 23 test files), but it was not re-run: its dependency install failed (pip exit 1: Failed building wheel for moments-popgen), so its suite was not run against dependencies it does not declare. 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 — 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. This repository's 11 shipped Python distribution(s) across 2 manifest(s) WERE read; what went unanswered is the currency half, because it grades an EXACT pin against the newest release and every declaration here is a floor or a range — which installs the newest release it admits and so cannot be behind one. So pypi.org was never asked. This is a true statement about the repository, and the healthy one, NOT a gap on our side: no reader we could write would find a currency question here.
D19 Documentation 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. Each ecosystem's manifests (what makes a folder runnable or a published package) need their own proof before D19 judges its units. Until then those folders' READMEs are judged only as documents (boilerplate, structure), never counted as complete.
D19 Documentation 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. This kind did not reach the 95 % precision gate in three adjudicated runs (docs/plans/deterministic-engine/adjudication/D19-sample3-v3.md), so by the pre-registered fallback it publishes no row until a re-measurement shows it does. The candidates are counted here, not reported as findings, and the score does not include them.
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 on C# first (docs/plans/deterministic-engine.md, P5): each other language is switched on only after its own concept suite and A/B gate pass. This says nothing about whether that surface is consistent.
D24 Comment Value — not measured this run — 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)` (32844 LoC, 60 module-visible types across 11 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.
D34 Knowledge Freshness — 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. File-level freshness contradicts repo activity: 87 commits in the last 90 days, yet 22 of 41 significant files carry no living knowledge. Those two readings cannot both be true, so the per-file recency signal is treated as unreliable here and freshness is not scored for this run.
AX2 Stateful singletons — 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 Microsoft.Extensions.DependencyInjection singletons in C#, Spring/JSR-330/CDI singletons in Java and Kotlin, module state in Python request handlers, handler state in Go and Swift, Play controllers, Cask routes, Scalatra servlets, Finatra controllers, Akka/Pekko HTTP routes and JSR-330 singletons in Scala, Rails, Sinatra, Grape, Roda and Hanami handlers and Rack apps in Ruby, and module state in F# request handlers (Giraffe, Saturn, Falco, Oxpecker and Suave handlers and ASP.NET Core controllers) only, and this repository's product is written in F#, which was left unread, so it had nothing of this repository's product to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
AX6 Interface segregation — not measured this run — 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 is computed over the public interfaces this run's compilations declare, and none was loaded, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
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.
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 and Scala source only, and this repository's Python is most of its product and is not read yet, so it had nothing of this repository's product to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
IC1 Incompleteness & stubs — not measured this run — 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 is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
P5 DR & Backup — not measured this run — This is a true statement about the repository that carries nothing for its owner to act on, so it is reported here rather than as a defect in their code. No backup/snapshot/replication config, RTO/RPO or restore-procedure documentation was found — and no production persistence was detected either (no data-access packages, no data-store services, no database resources), so there is nothing in this repository whose loss a DR control would recover. If this system's data lives in a platform or ops repo we can't see, that's where the DR evidence belongs.
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 is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X12 Unreachable branch — not measured this run — 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 is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X13 Undrained process stream — not measured this run — 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 is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X14 Bypassable address classification — not measured this run — 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 is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X15 Unvalidated length from an untrusted reader — not measured this run — 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 is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X16 Unfloored truncation loop — not measured this run — 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 is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X17 Uncapped recursion over a caller-supplied document — not measured this run — 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 is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X18 Disposal-pattern correctness — not measured this run — 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 is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X19 Unrestored process-global state — not measured this run — 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 is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X2 Cancellation propagation — not measured this run — 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 is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X21 Side-effecting pattern guard — not measured this run — 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 is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X22 Contradicted release guard — not measured this run — 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 is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X24 Document value interpolated into markup unescaped — not measured this run — 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 is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X25 Inert configuration knob — not measured this run — 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 is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X26 Unsynchronised callback handoff — not measured this run — 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 is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X29 Per-element action decided by a fixed element — not measured this run — 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 is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X3 Exception handling — not measured this run — 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 is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X30 Support guard that admits what it rejects — not measured this run — 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 is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X32 Type resolved by simple name across every loaded assembly — not measured this run — 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 is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X4 Structured logging — not measured this run — 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 is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X5 Nullable reference types — not measured this run — 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 is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
Repo exclusion declarations (.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.
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.
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.
D16 Bus Factor: Bus-factor is a time-decayed model of commit attribution (who has recently, repeatedly worked a file), not comprehension — pairing, review and reading-without-committing spread knowledge it can't see; bot commits and shared accounts still distort it.
D17 Explicit Debt: Acknowledged-debt signals (TODO/FIXME, suppressions, dead code) are textual — undocumented debt that nobody marked, and debt that lives in design rather than annotations, is invisible. Committed machine-written code (scaffolded migrations, designer/codegen output, generated stubs) is excluded — it is never the team's dead code to delete.
D19 Documentation Quality: Documentation quality publishes two things only: a runnable or packaged unit with no example, and a multi-project root README that maps none of its parts. It does not judge clarity, and its other checks (overview, licence, boilerplate, structure, empty sections, XML-doc coverage) are withheld after adjudication: their candidates are counted in the card's gaps, not shown as rows. A false statement in a document is M4's; units are .NET projects only.
D27 Navigability: Indirection/navigability is structural — it measures hops to follow a call, not whether that indirection buys real flexibility or just ceremony.
D28 Secrets (history): Secret-history scanning sweeps the git log for known patterns — a secret that predates the available history, or never matched a signature, is not found (clean means "nothing matched in the history we can see").
D29 Static Analysis (SAST): SAST findings are pattern-based (semgrep) — it finds classes of bug it has rules for; logic flaws, auth/authorization gaps and issues needing runtime context are out of reach (and clean means "no rule matched").
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.
D35 Change Coupling: Change coupling is co-change in COMMITS — files split across separate commits, or coupled only through a shared config/build step, read as uncoupled, and a sweeping commit (rename/format) is excluded so it doesn't couple everything. It shows that files change together, not WHY: a high coupling can be a healthy cohesive pair as readily as a hidden leak.
D43 Malicious Dependencies: Only packages some vulnerability database has already NAMED as malicious are seen — a compromise published in the last hours, or never reported at all, is invisible here, and this dimension reading 10 is not evidence that a dependency is trustworthy. There is no typosquat or dependency-confusion analysis: a package nobody has reported is simply absent from the feeds. Coverage is the dependency scan's: an ecosystem that could not be scanned is disclosed as unmeasured, never as clean.
D44 Platform End-of-Life: The support table is FROZEN, so it goes out of date by losing RECALL: a release that ended support after the table was written is missed until the table is refreshed, and this dimension reading 10 is not evidence that a platform is current. Only platforms the repository DECLARES in a place this pass reads are seen — a runtime named only in a Dockerfile (D31's subject), in a CI workflow (D29's), or in a file this pass does not parse (go.mod, a Gemfile ruby directive) is invisible here, which is why a repository declaring none of them abstains rather than scoring. Only frameworks with a PUBLISHED support policy are tracked: React, Flask and Express publish none, so their age cannot be judged and their absence from a report is not a statement that they are supported.
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.
P4 Deployment & Rollback: Approval/branch-protection rules live in repository settings the scan cannot see — only their in-repo evidence (config files, workflows) is checked, so a control enforced purely in the host's settings reads as "not evidenced".
P6 Release Hygiene: Rollback/observability controls are inferred from repo artefacts (pipelines, dashboards-as-code) — controls configured in external tooling, with no in-repo trace, cannot be credited.
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.
+ 53 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Bring the 4 bodies over 60 down to 60 or less in Cyclomatic Complexity — start with Matrices.admix_ld (cyclomatic 216), Matrices.migration_ld (cyclomatic 103), Demes.SFS (cyclomatic 82). — This score is capped by its worst body, so a finding fixed alone moves it by almost nothing — the next one down takes its place. Refactoring these 4 together lifts Cyclomatic Complexity from 2.0 to about 3.2/10, projected with the scoring formula itself and assuming each lands exactly at 60; a cleaner split scores higher.
Detailed fixes: d1_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: How hard the code is for a person to follow, beyond raw branching.
Method: Cognitive complexity per method (Sonar-style nesting-penalized score), computed exhaustively over production code, excluding test projects. Deterministic.
+ 103 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Bring the 47 bodies over 30 down to 30 or less in Cognitive Complexity — start with Matrices.migration_ld (cognitive 358), Parsing._tally_vcf (cognitive 158), Demes.SFS (cognitive 152). — 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 47 together lifts Cognitive Complexity from 2.0 to about 5.6/10, projected with the scoring formula itself and assuming each lands exactly at 30; a cleaner split scores higher.
Detailed fixes: d2_recommendation.md · top locations in Appendix A, every location in findings.md.
Do you agree with this assessment?
D3 · God Classes8.0 / 10Strong✓ Tool-verified
What it measures: Over-large classes that try to do too much ("god classes").
Method: God-class detection by line and method-count thresholds per logical type (partial classes unified), filtered for generated code and registration/contract false positives. Deterministic.
Resolve the 14 FileTooLong finding(s) in God Classes — start with Inference.py (3), Parsing.py (2), Matrices.py. — One of this dimension's main actionable groups (14 warning-level).
Resolve the 1 TooManyMethods finding(s) in God Classes — start with REDACTED. — One of this dimension's main actionable groups (1 warning-level).
Detailed fixes: d3_recommendation.md · top locations in Appendix A, every location in findings.md.
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.
303 duplicated block group(s) detected. 38.4 % of the production lines (12,609 of 32,861) are in a reported copy. A further 60 rows report members as variants of one another; the share counts each copied line once, however many rows cite it.
+ 195 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Resolve the 13 Duplicated block (10 lines × 2) finding(s) in Code Duplication — start with stats_from_genotype_counts.py (5), Numerics.py (3), Demes.py. — One of this dimension's main actionable groups (13 warning-level).
Resolve the 12 Duplicated block (13 lines × 2) finding(s) in Code Duplication — start with Inference.py (2), Manips.py (2), Numerics.py (2). — One of this dimension's main actionable groups (12 warning-level).
Resolve the 12 Duplicated block (6 lines × 2) finding(s) in Code Duplication — start with Matrices.py (2), stats_from_genotype_counts.py (2), REDACTED (2). — One of this dimension's main actionable groups (12 warning-level).
Detailed fixes: d4_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether a class's methods are focused on a single responsibility.
Method: LCOM4 cohesion per production class with at least two methods: connected components of methods sharing state or calls, computed syntactically. Deterministic, not a proxy.
Coverage: Exhaustive · type-level: LCOM4 cohesion computed over every production class — the population is all types, not a name convention.
What it measures: Whether any secrets (keys, tokens, passwords) have leaked into the code.
Method: In-process native secret scanner (entropy plus signature patterns) across all tracked files; no external tool. A clean result is a measured 10, not no-data zero. Deterministic.
What it measures: Whether the licenses of third-party packages are compatible with your policy.
Method: Third-party package licenses resolved from declared package metadata and checked against the configured policy (allow/deny/copyleft). Deterministic; clean = no incompatible license found at metadata depth.
0 of 93 shipped Python distribution(s) use a banned license. Licences were resolved from PyPI over the distributions a consumer installs — this repository's 11 declared runtime requirement(s) closed transitively over each distribution's published `requires_dist` (82 reached that way). Requirements it states ONLY under an extra, a PEP 735 dependency group, a Poetry dev group or a dev-named requirements file are excluded: pip does not install any of them for a consumer. ★ This repository commits no dependency lockfile that this pass reads, so each licence is the one PyPI publishes for the distribution's CURRENT release rather than for a pinned version. 29 of them publish no licence on PyPI this pass can read; that is missing data, not a violation, and none of them is charged. This repository publishes itself under MIT, which is its own choice and is not judged here.
What it measures: Files that change often and are also complex — the riskiest hotspots.
Method: Per production file churn times cyclomatic complexity over a rolling window, computed from git and Roslyn/JS/Razor analysis. Exhaustive, deterministic per commit date.
Resolve the 4 Hotspot finding(s) in Churn × Complexity Hotspots — start with Inference.py, Parsing.py, Plotting.py. — One of this dimension's main actionable groups (4 warning-level).
Detailed fixes: d15_recommendation.md · top locations in Appendix A, every location in findings.md.
Do you agree with this assessment?
D16 · Bus Factor5.5 / 10Adequate✓ Tool-verified
What it measures: Whether knowledge is concentrated in too few people (the "bus factor").
Method: Living knowledge per author via time-decayed commit attribution (6-month half-life, focus weighting) across largest source files. Deterministic, avoids blame's mechanical-refactor false positives.
18 source file(s) have their living knowledge concentrated in one author (≥90% of recent, decayed contribution). The largest is REDACTED. Counted over 40 of the 50 production source files in this repository: 9 are under the ~2,400-byte size floor this dimension measures over, and the remaining 1 have no attributable history left to measure.
Off-boarding risk: anonymized user #1
What to do
Resolve the 1 Off-boarding risk finding(s) in Bus Factor. — One of this dimension's main actionable groups (1 recommendation-level).
Detailed fixes: d16_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Acknowledged debt left in the code — TODOs, dead code, suppressed warnings.
Method: Roslyn syntactic debt markers (suppressions/TODO/FIXME/HACK/empty-catch/commented-code/Obsolete) plus SymbolFinder dead-code analysis; weighted-debt-per-KLoC density deducted 2.0x per unit. Deterministic, exhaustive.
2 deducted task-comment markers across 32861 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.
XxxComment · ×2moments/Plotting.py:946
What to do
Resolve the 2 XxxComment finding(s) in Explicit Debt — start with Plotting.py, REDACTED. — One of this dimension's main actionable groups (2 warning-level).
Detailed fixes: d17_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether the project's documentation is clear, complete, and useful.
Method: Every README, docs/ document and root guide parsed by its markup and measured in Unicode letters. Published: a runnable or packaged .NET project whose README (or a document it links, or a root guide) shows no example, and a root README naming none of three or more projects. Overview, licence, boilerplate, wall-of-text, empty-section and XML-doc rows are measured and withheld (counted in gaps) after adjudication. Deterministic, exhaustive, advisory.
What it measures: How far you must trace to follow a call — low indirection and co-located slices read easier.
Method: Call indirection (interface hops, cross-namespace calls, slice-locality scaled) over a sampled set of method invocations, size-aware baseline. Sampled; confidence discounted by symbol-resolution gaps. C# also names each pass-through layer (a class whose every public method only forwards its own parameters to one collaborator) as a located finding; the score is not affected.
Coverage: Slice locality from the first namespace segments, SAMPLED (≤400 methods) — not exhaustive.
55 % of calls cross a namespace and 0 % go through an interface, but 100 % of collaborators are co-located — so a call's collaborators sit together and tracing stays easy. Baseline: small — navigation cost is tolerated.
What it measures: Whether any secrets were ever committed — scanned across the full git history, not just now.
Method: Secret scan via TWO gitleaks detect passes in an isolated checkout — the full git history, then a second --no-git pass over the working tree as it stands — merged and de-duplicated by (rule, file, line); each match flagged High. Both invocations are recorded in the audit trail. Exhaustive; when the tool is absent, or when its output cannot be parsed into the expected shape, the dimension is WITHHELD as an explicit measurement gap on our side — unscored and excluded from the lens, never a hedged middling score.
What it measures: Real static-analysis (SAST) findings — likely security bugs in the code, any language.
Method: Polyglot static analysis via semgrep across the repo using the pinned, image-baked p/security-audit + p/owasp-top-ten rulesets (no scan-time registry fetch); severity rules (ERROR/WARNING/INFO) map to a full-band severity-weighted score. Exhaustive, deterministic; degrades on parse failure.
Coverage: semgrep pattern rules over all files — exhaustive for the rule set, blind to classes of bug without a rule (clean = no rule matched).
52 finding(s): 0 critical, 42 high, 10 medium, 0 low. 25 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
REDACTED
REDACTED
+ 2 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Resolve the 8 REDACTED finding(s) in Static Analysis (SAST) — start with REDACTED (2), REDACTED (2), REDACTED (2). — One of this dimension's main actionable groups (8 issue-level).
Resolve the 5 REDACTED finding(s) in Static Analysis (SAST) — start with REDACTED (3), REDACTED (2). — One of this dimension's main actionable groups (5 issue-level).
No action in Static Analysis (SAST) — all 25 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 (25 issue-level, 0 of them charged here).
Detailed fixes: d29_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether any dependency has a known published vulnerability (CVE), direct or transitive, in ANY ecosystem the repository declares — Dart pub, Elixir and Erlang via Hex, Go modules, Java and Kotlin via Maven/Gradle, JavaScript/npm, .NET/NuGet, PHP/Composer, Python/PyPI, RubyGems, Rust/Cargo and Swift.
Method: Dependency-CVE scan across every ecosystem the repository declares, scored ONCE. Three sources are unioned and deduplicated by advisory identity (rule id + alias closure, CVE<->GHSA) scoped to package+version, keeping the worst severity: `osv-scanner --recursive` over osv.dev for Dart pub, Elixir/Hex (and Erlang, whose `rebar.lock` syft first converts to a CycloneDX SBOM the scanner reads, with rows attributed back to the lock), Go, Java and Kotlin via Maven/Gradle (and Scala, whose sbt build's pinned direct declarations are written into a CycloneDX SBOM the scanner reads, with rows attributed back to the build file), npm, PHP/Composer, Python/PyPI, RubyGems, Rust/Cargo and Swift; `trivy fs --scanners vuln` for npm lockfiles; and `dotnet list package --vulnerable --include-transitive` for NuGet (with per-advisory collapse of the project x target-framework fan-out), plus a DECLARED-dependency arm that resolves a published gem's gemspec against rubygems.org where no Gemfile.lock is committed. `SeverityScore(c,h,m,l, normalizer 8.0)`. NotApplicable only when NO ecosystem is readable; if any applicable ecosystem could not be scanned the findings are REPORTED and the score is withheld. Supersedes the npm and OSV arms, retired 2026-09-05. 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.
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.
What it measures: Whether the build pipeline provides supply-chain integrity — generated provenance/attestation, signed artifacts (cosign/sigstore), an SBOM, and pinned build actions. Presence of the configuration, not a runtime guarantee.
Method: Supply-chain provenance/signing read deterministically from CI/build config (.github/workflows, .gitlab-ci.yml, azure-pipelines, Jenkinsfile, .circleci) + the release surface: four signals — generated provenance/attestation (SLSA/in-toto/actions-attest), artifact signing (cosign/sigstore/gitsign), an SBOM (syft/sbom-action/*.spdx.json/*.cdx.json), and SHA-pinned build actions — scored 10·present/denom. NotApplicable without a build pipeline. Detects configuration presence, not runtime enforcement.
Resolve the 2 REDACTED finding(s) in Supply-chain Provenance & Signing — start with REDACTED, REDACTED. — One of this dimension's main actionable groups (2 warning-level).
Resolve the 1 REDACTED finding(s) in Supply-chain Provenance & Signing. — One of this dimension's main actionable groups (1 warning-level).
Resolve the 1 REDACTED finding(s) in Supply-chain Provenance & Signing — start with REDACTED. — One of this dimension's main actionable groups (1 warning-level).
Detailed fixes: d36_recommendation.md · top locations in Appendix A, every location in findings.md.
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.
What it measures: Whether anyone still ships security patches for the platform this repository RUNS ON — the runtime it pins and the framework majors its own constraints hold it to. Separate from D12 because the question differs: a current Django on an end-of-life Python is perfectly up to date and completely unsupported, and the fix is a migration rather than a version bump. What the repository says it merely SUPPORTS is never charged.
Method: End-of-life PLATFORM read from the repository's own declarations and graded against a FROZEN, dated table of vendor support dates — no network, no feed, no API, so this dimension answers identically inside a closed scan fence. Two subjects: a RUNTIME the project pins (a single or all-end-of-life TargetFramework, a .nvmrc or .python-version, a requires-python CAP) and a FRAMEWORK major a dependency constraint cannot move off (a caret, tilde or exact version; `vue@^2.7.16` pins Vue 2). A FLOOR is deliberately never charged — `requires-python = ">=3.8"` states what a package SUPPORTS, not what it runs on — and a multi-target project is charged only when EVERY target is out of support. Runtime 4.0/product capped 8.0, framework 1.5 capped 4.5. The table is safe to freeze because a statement about support that ended in the past cannot become false: it loses recall as it ages, never precision, and a test asserts every entry predates the freeze date. Disjoint from D31 (a container image's OS layer) and D29 (the toolchain a CI workflow installs). Abstains when the repository declares no platform this pass reads — never scores it clean.
0 end-of-life runtime(s) and 0 end-of-life framework(s), read from 1 platform declaration(s) and 11 dependency declaration(s). This dimension reads what the repository says about ITSELF — a pinned target framework, a version file, a capped requires-python, a Rust toolchain pin, a framework major a constraint cannot move off. A FLOOR is deliberately never charged: `requires-python = ">=3.8"` states what the package SUPPORTS, not what it runs on, and a well-maintained library declares exactly that while running its own CI on a current release. The end-of-life facts are FROZEN and dated, so this dimension needs no network and answers identically inside a closed scan fence; as the table ages it loses recall and never precision, because a statement about support that ended in the past cannot become false. The OS layer of a container image is D31's question and the toolchain a CI workflow installs is D29's; this row is neither.
Other · Architecture — How the codebase splits by code ROLE — domain, application, infrastructure, test, generated. The significance map behind the knowledge/coupling weighting, and a DDD signal in its own right: a thin domain core under fat infrastructure is the anemic-domain smell, quantified. How each file's role is decided, because the split is only as good as that: a generated name or a build-output tree makes it Generated, a test project makes it Test, and otherwise the file's NAMESPACE and PATH words are matched against fixed vocabularies in a fixed ORDER — domain, then infrastructure, then application — so a file whose words hit two layers is counted under the earlier one. A production file matching none of them counts as application, so that share reads 'application or unclassified' rather than a measured application layer. Roles come from naming convention, never from what the code does. On this repository the split was taken from the source tree on disk rather than from a loaded .NET workspace, so a file's role is decided by its PATH segments alone — no declared namespace was available to add to the evidence — and generated output is excluded from the census entirely rather than counted as a generated share.
Method: Roslyn line-count by code ROLE: every source file classified Domain/Application/Infrastructure/Test/Generated by namespace + path convention (the shared CodeRoleClassifier), then significant lines summed per role. Deterministic; the advisory score is the business-logic (domain+application) share of production code.
Coverage: Population: ALL source files, each bucketed into ONE of five roles (Domain/Application/Infrastructure/Test/Generated) by namespace + path convention — a file whose layer isn't named in the convention falls to Application (the neutral default), and the split is line-count, not semantic depth or business value.
Other · Architecture — Whether the project-reference graph is acyclic (cycles block independent build/deploy and signal eroding boundaries).
Method: Project reference cycles via elementary-DFS over real .csproj references, using the engine shared with D5/D7; cyclic versus acyclic. Exhaustive, deterministic.
Other · Architecture — Whether dependencies point inward (Domain ← Application ← Infrastructure/Web) — the clean-architecture dependency rule, checked across the project graph.
Method: Layer violations by name-segment inference (Domain/Core to Application to Infrastructure/Web) over the project-reference graph. Exhaustive over all projects, deterministic.
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
Explain in the README how to run the tests. Add a section called Testing to the README in the repository's top folder, saying how to run the test suite.
Maturity · Maturity — Whether key decisions (ADRs) and the high-level shape (C4/diagrams) are written down.
Method: Filesystem scan: ADR folder/naming conventions or content, plus Mermaid/PlantUML/C4/architecture.md discovery. Exhaustive, deterministic.
No Architecture Decision Records found — no conventional ADR directory, no numbered `NNNN-title` documents in any markup this check reads, and nothing ADR-shaped by content. Design rationale recorded elsewhere (a design-notes tree, a mailing list, pull-request discussion) is not visible to this check and is not re-findable per decision, so a future maintainer cannot ask why one choice was made and get an answer.
No C4/Structurizr/PlantUML/Mermaid/Graphviz/D2 diagram, no drawn diagram named for the architecture, no file named `architecture` or `design` in any markup this check reads, and nothing in the README, docs or contributor guides that announces the shape — no `## Architecture` heading, no "architecture overview"/"high-level design" phrasing, no "the architecture is …" introduction, no guided code tour. A shape laid out in prose that never names itself as the architecture is not visible to this check, and neither is one kept outside the repository, so this row reports the absence of a re-findable shape document — not evidence that nobody wrote the shape down.
What to do
Record 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 C4 context/container diagram (Structurizr, PlantUML or Mermaid) or an architecture.md overview.
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.
Readiness · Readiness — Whether an automated pipeline builds and tests every change.
Method: Filesystem scan: CI workflow files (.github/workflows, .gitlab-ci.yml, etc.) for build and test stages. Exhaustive, deterministic.
Do you agree with this assessment?
P10 · Library API & versioning10.0 / 10Exemplary○ Nothing flagged
Readiness · Readiness — For a library: a deliberate (small) public API surface and explicit semantic versioning so consumers can depend on it safely.
Method: Roslyn scan: public API surface area and semantic-versioning markers (SemVer attributes, changelog entries) for libraries; off .NET, a library is the ecosystem's publication act (an npm package that is not private and names an entry point, a PyPI distribution with a build system, a Rust library crate, a Maven/Gradle module that publishes, a Go module with no package main, a gemspec, a Composer library, a SwiftPM library product, a pub.dev or Hex package), its surface is the share of types the language's code model records as public (Rust, Swift, Java, Kotlin, Go, Dart; not measured where the model records no type visibility or, as in TypeScript, only module-level export), and its version is read from the manifest, a semver CHANGELOG, release tooling or semver git tags. Exhaustive, deterministic.
Do you agree with this assessment?
P2 · Observability7.0 / 10Strong✓ Tool-verified
Readiness · Readiness — Whether the code is diagnosable in production — structured logging, tracing/metrics, health checks.
Readiness · Readiness — Whether SAST, secret/dependency scanning and performance benchmarking are wired in (presence, not runtime).
Method: Filesystem scan: SAST configuration, dependency-update automation, secret scanning, and a benchmark harness or benchmark step — in this repository's own ecosystem. Exhaustive, deterministic.
No static application security testing detected. For this repository's stack, add bandit, `semgrep --config=p/python`, or CodeQL's python pack as a CI step. What was searched, so you can tell an absence from a miss: the 4 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:2
What to do
Add a SAST step to CI running what this repository's stack ships: bandit, `semgrep --config=p/python`, or CodeQL's python pack — so a security regression fails the build instead of landing.
Enable Dependabot/Renovate or a dependency-review gate.
Add gitleaks/trufflehog in CI to block PRs that introduce committed secrets.
Readiness · Readiness — Whether releases are automated and safely reversible (probes, rolling updates, approval gates) — from manifests/pipeline files, not the live environment.
Method: Filesystem scan: deployment manifests/IaC (K8s YAML, Helm, Terraform) for rolling updates, probes, approval gates, migration hooks. Exhaustive, deterministic.
What to do
Make sure a person approves each release. The release job names an environment, but its approval rules live in the code host's settings, where we can't see them. Check that a reviewer must approve each release, or publish releases as drafts first, so a bad build can be stopped before anyone downloads it.
Readiness · Readiness — Whether releases are traceable — a maintained changelog and explicit version stamping.
Method: Filesystem scan: changelog file presence and version tags in csproj or git tags. Exhaustive, deterministic.
No CHANGELOG/HISTORY/RELEASES file — what shipped when isn't easy to reconstruct for support or audit. (Versioning/tagging makes releases traceable, but a changelog records the what.)
What to do
Keep a changelog (e.g. Keep-a-Changelog) recording what shipped in each release.
Do you agree with this assessment?
X27 · Collection changed while being enumerated10.0 / 10Exemplary○ Nothing flagged
Other · Code Health — Whether a `for … in` loop leaves the mutable .NET collection it is walking alone — F#'s own lists, arrays, maps and sets cannot be changed by a loop body, but a `ResizeArray`, `Dictionary`, `Queue` or other BCL collection walked by `for x in c do` is walked through its enumerator, so a body that adds to or removes from `c` makes the next `MoveNext` throw `InvalidOperationException` and the remaining items are never seen. Whether a `for` loop leaves the `dict`, `set` or `deque` it is walking alone — CPython's iterators over those check that the collection has not changed size since the loop began, so a body that removes from (or empties) the very collection the loop is walking makes the next step raise `RuntimeError: dictionary changed size during iteration` and the remaining items are never seen.
Method: Roslyn syntax + semantics: `foreach` statements whose body calls a structural mutator (`Add`/`Remove`/`Clear`/`Insert`/…) on the very expression the loop is enumerating. Two arms. ARM A — the source is a concrete fragile BCL collection, or a live `Keys`/`Values` view over one, and the mutator resolves to that same collection's own member; concurrent and immutable collections and arrays are outside the population by construction, since their enumerators survive a structural change. ARM B — the source is an argument-less accessor CALL on a receiver whose body is in source: the accessor must return a stored field VERBATIM and a sibling member must structurally change that same field, both read off the implementations rather than from the members' names. A mutation the loop provably exits immediately after (`break`/`return`/`throw`/`goto`), or one written inside a nested loop or a lambda, is counted and never reported. Deterministic, provable per finding. Advisory.
Do you agree with this assessment?
Reference — by lens
The score is the rank-weighted fold of these lenses (worst-heaviest), each including its meta-dimensions; a lens with a Critical contributor is capped at Fair (its band reads "gated by …") and is never the strongest area however high its average.
Capped at Fair by a Critical contributor — resolve it before relying on this lens.
Unscored — 1 check(s) recorded observations but carry no score
These checks ran and found something, but they do not carry a score — either by design (an advisory check reports evidence rather than grading it) or because they could not be scored here. They are excluded from the score for that reason, not because there was nothing to see.
X10 Duplicated predicate — 6 observation(s) recorded · Advisory — this card reports evidence and never carries a score.
Not evidenced — 1 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.
P5 DR & Backup — not evidenced — repo shows no backup/RTO/RPO controls; absence of evidence is not evidence of a working control
Not included — 83 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 F# imports no dependency-injection container and defines no container of its own — nothing that both registers and resolves bindings, and nothing that names two lifetimes — so nothing holds one lifetime's instance while handing out another's; this repository's Python imports no dependency-injection container and defines no container of its own — nothing that both registers and resolves bindings, and nothing that names two lifetimes — so nothing holds one lifetime's instance while handing out another's.
AX2 Stateful singletons — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
AX5 Architecture & structure — not assessed — architecture style/structure is computed from a project graph (projects, types, module namespaces) that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
AX6 Interface segregation — not assessed — interface segregation is computed over a type surface that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
AX7 Slice cohesion — not applicable — not a vertical-slice architecture
AX8 Test isolation — no test/production split to check
AX9 CQS / query purity — no CQRS query handlers detected — query purity is not applicable to this codebase
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.
AXB2 Runtime readiness — Advisory — this card reports evidence and never carries a score, so there is nothing missing here.
C1 Data Protection — Not assessed: these personal data controls are read from a source model (declarative annotations, request middleware, entity/column names, guard methods) that was not loaded for this repository — because the repository is written in a language this check does not yet model, or because its projects failed to load. Absence of an idiom this check recognises is NOT evidence that this repository lacks personal data controls: it may implement them entirely in its own ecosystem. This is a gap in the analyzer's language coverage, not a finding about this repository.
C2 Access Controls — No access-control surface detected in the analyzed source — this repository registers no route and starts no server another machine can reach (no Flask/FastAPI/Starlette route, Django urlpatterns or class-based view, Tornado handler). Access control is therefore N/A here — a library or command-line tool is authorized by the application that serves it, not by itself. If this codebase grows request handlers, the dimension reactivates and a default-deny posture is expected then.
C3 Audit Trail — No personal data detected in a persisted data model — no PII-named field (email, first_name, date_of_birth, phone, …) or stored credential in a Django, SQLAlchemy, SQLModel, Peewee, Tortoise or MongoEngine model, a migration or a SQL schema — and no database or data-store client (Django ORM, SQLAlchemy, psycopg, PyMongo, …) in the source either, so this repository keeps no sensitive data whose changes an audit trail would record. If it does (through a store configured outside this repository, for instance), the trail belongs to wherever that data is stored.
C4 Data Retention — No personal data detected in a persisted data model — no PII-named field (email, first_name, date_of_birth, phone, …) or stored credential on a Django, SQLAlchemy, SQLModel, Peewee, Tortoise or mongoengine model, in a migration or in a SQL schema — and no database or data-store client (django.db, sqlalchemy, psycopg2, pymongo, sqlite3, …) 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 field (email, first_name, date_of_birth, phone, …) or stored credential on a Django, SQLAlchemy, SQLModel, Peewee, Tortoise or mongoengine model, in a migration or in a SQL schema — and no database or data-store client (django.db, sqlalchemy, psycopg2, pymongo, sqlite3, …) imported either, so this repository keeps no personal data for a data subject to erase, export or consent over.
D10 Test Quality — ~8970 lines of test source are present (.py, .fs) but no test cases reached the test census for this repository — no test root we could resolve declared them, or the files we read declare no cases in a test framework we recognise — so skipped/assertion-free tests couldn't be counted. Not scored — this is a gap in the analyzer, not a finding about this repository.
D11 Test Reliability — Test reliability not included — the .py suite was found but not re-run
D12 Dependency Hygiene — Dependency currency not established — no declaration carries an exact pin to grade
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 case and prefix conventions rows: 1 candidate(s) found and not reported.
D22 Internal API Consistency — API consistency is measured on C# only; the exposed Python surface was not measured.
D23 Boundary Type-Coupling — No bounded-context organisation was detected either — neither a context-shaped layout, nor 2+ sibling source directories each declaring an aggregate root, nor 2+ 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 .fs, .py, 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.
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.
D34 Knowledge Freshness — knowledge concentrated in recent work — freshness signal contradicted by repo activity
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.
D5 Coupling — Not applicable — this Python build ships 1 production module(s), so there is no coupling BETWEEN modules to measure. (Its test and non-production modules are not part of the shipped graph.)
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 included — suite not readable by the collector
DM1 Domain Modelling — not scored — this repository shows none of the 3 signals this lens looks for
ED1 Event-Driven — not scored — this repository shows none of the 3 signals this lens looks for
ED5 Idempotency — no mutating command handlers or message consumers detected — idempotency check not applicable
ES1 Event Sourcing — not scored — this repository shows none of the 3 signals this lens looks for
GD1 Unfinished & placeholder code — no source files were read — this check reads C#, F#, JavaScript/TypeScript, Dart, Ruby and Scala, and none was read for this repository's product. That is a limit of the analyzer, not a finding about your code.
IC1 Incompleteness & stubs — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
M4 Documentation accuracy — Not applicable: the 23 current-state document(s) make no claim of a kind M4 checks. 8 claim(s) of kinds M4 does not check were not checked (path 4, environment variable 4); M4 checks only links and versions and artefact counts.
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'.
P7 Outbound HTTP resilience — not measured — the application kind could not be determined for this repo
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 a BenchmarkDotNet reference in an .fsproj or .vbproj, 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 — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
X13 Undrained process stream — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
X14 Bypassable address classification — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
X15 Unvalidated length from an untrusted reader — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
X16 Unfloored truncation loop — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
X17 Uncapped recursion over a caller-supplied document — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
X18 Disposal-pattern correctness — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
X19 Unrestored process-global state — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
X2 Cancellation propagation — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
X20 Mistyped argument guard — not applicable — the code was read and holds no site of this kind, so there is nothing for this check to judge
X21 Side-effecting pattern guard — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
X22 Contradicted release guard — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
X23 Unguarded diagnostic materialisation — not applicable — the code was read and holds no site of this kind, so there is nothing for this check to judge
X24 Document value interpolated into markup unescaped — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
X25 Inert configuration knob — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
X26 Unsynchronised callback handoff — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
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 — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
X3 Exception handling — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
X30 Support guard that admits what it rejects — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
X32 Type resolved by simple name across every loaded assembly — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
X4 Structured logging — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
X5 Nullable reference types — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
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.
FileTooLong: LD/Matrices.py moments/LD/Matrices.py— FileTooLong — 3658 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 3158 over it, 7.32× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: LD/stats_from_genotype_counts.py moments/LD/stats_from_genotype_counts.py— FileTooLong — 1279 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 779 over it, 2.56× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: REDACTED REDACTED— FileTooLong — 1161 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 661 over it, 2.32× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: LD/Parsing.py moments/LD/Parsing.py— FileTooLong — 1093 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 593 over it, 2.19× 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: Demes/Demes.py moments/Demes/Demes.py— FileTooLong — 1088 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 588 over it, 2.18× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: Demes/Inference.py moments/Demes/Inference.py— FileTooLong — 1011 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 511 over it, 2.02× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: REDACTED REDACTED— FileTooLong — 906 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 406 over it, 1.81× 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: TwoLocus/Numerics.py moments/TwoLocus/Numerics.py— FileTooLong — 879 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 379 over it, 1.76× 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: moments/Plotting.py moments/Plotting.py— FileTooLong — 757 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 257 over it, 1.51× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: REDACTED REDACTED— FileTooLong — 744 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 244 over it, 1.49× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: LD/Inference.py moments/LD/Inference.py— FileTooLong — 637 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 137 over it, 1.27× 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: moments/Inference.py moments/Inference.py— FileTooLong — 616 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 116 over it, 1.23× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: moments/Parsing.py moments/Parsing.py— FileTooLong — 585 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 85 over it, 1.17× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: REDACTED REDACTED— FileTooLong — 542 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 42 over it, 1.08× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
Duplicated block (10 lines × 2) moments/Demes/Demes.py:960— moments/Demes/Demes.py:960-969 | moments/Demes/Demes.py:973-982 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/Demes/Demes.py:960` it begins part-way through the construct above it, so those exact lines 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) moments/Demes/Inference.py:505— moments/Demes/Inference.py:505-514 | moments/Demes/Inference.py:1108-1117 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (10 lines × 2) REDACTED:1152— REDACTED:1152-1161 | REDACTED:615-624 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 7 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. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:1152` it begins part-way through the construct above it, so those exact lines 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) moments/LD/Matrices.py:681— moments/LD/Matrices.py:681-690 | moments/LD/Matrices.py:762-771 — both copies are in the same file, so extract the 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) moments/LD/stats_from_genotype_counts.py:167— moments/LD/stats_from_genotype_counts.py:167-176 | moments/LD/stats_from_genotype_counts.py:417-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. Read the line range as the matched WINDOW rather than a finished unit: at `moments/LD/stats_from_genotype_counts.py:167` it does not close everything it opens, so those exact lines 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) moments/LD/stats_from_genotype_counts.py:524— moments/LD/stats_from_genotype_counts.py:524-533 | moments/LD/stats_from_genotype_counts.py:550-559 — both copies are in the same file, so extract the 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) moments/LD/stats_from_genotype_counts.py:586— moments/LD/stats_from_genotype_counts.py:586-595 | moments/LD/stats_from_genotype_counts.py:626-635 — both copies are in the same file, so extract the 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) moments/LD/stats_from_genotype_counts.py:951— moments/LD/stats_from_genotype_counts.py:951-960 | moments/LD/stats_from_genotype_counts.py:1197-1206 — both copies are in the same file, so extract the 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) moments/Misc.py:569— moments/Misc.py:569-578 | moments/Misc.py:580-589 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (10 lines × 2) moments/Triallele/Numerics.py:346— moments/Triallele/Numerics.py:346-355 | moments/Triallele/Numerics.py:448-457 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/Triallele/Numerics.py:346` it begins part-way through the construct above it, so those exact lines 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) moments/Triallele/Numerics.py:434— moments/Triallele/Numerics.py:434-443 | moments/Triallele/Numerics.py:480-489 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/Triallele/Numerics.py:434` it begins part-way through the construct above it, so those exact lines 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) moments/TwoLocus/Numerics.py:538— moments/TwoLocus/Numerics.py:538-547 | moments/TwoLocus/Numerics.py:576-585 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (10 lines × 2) moments/LD/stats_from_genotype_counts.py:1242— moments/LD/stats_from_genotype_counts.py:1242-1251 | moments/LD/stats_from_genotype_counts.py:1407-1416 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/LD/stats_from_genotype_counts.py:1242` it begins part-way through the construct above it, so those exact lines 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) moments/Demes/Inference.py:138— moments/Demes/Inference.py:138-150 | moments/Demes/Inference.py:205-217 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (13 lines × 2) moments/Inference.py:703— moments/Inference.py:703-715 | moments/TwoLocus/Inference.py:282-295 — before extracting anything, compare `moments/Inference.py` and `moments/TwoLocus/Inference.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 141 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 `moments/Inference.py:703` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (13 lines × 2) moments/LD/Plotting.py:114— moments/LD/Plotting.py:114-126 | moments/LD/Plotting.py:324-336 — both copies are in the same file, so extract the 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) moments/LD/stats_from_genotype_counts.py:542— moments/LD/stats_from_genotype_counts.py:542-554 | moments/LD/stats_from_genotype_counts.py:573-585 — both copies are in the same file, so extract the 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) moments/LD/stats_from_haplotype_counts.py:215— moments/LD/stats_from_haplotype_counts.py:215-227 | moments/LD/stats_from_haplotype_counts.py:232-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. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `moments/LD/stats_from_haplotype_counts.py:246` calls `elif` and `moments/LD/stats_from_haplotype_counts.py:229` 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) moments/Manips.py:393— moments/Manips.py:393-405 | moments/Manips.py:409-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. 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) moments/Manips.py:425— moments/Manips.py:425-437 | moments/Manips.py:441-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. 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) moments/Reversible.py:98— moments/Reversible.py:98-110 | moments/Reversible.py:168-180 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (13 lines × 2) moments/Triallele/Numerics.py:77— moments/Triallele/Numerics.py:77-89 | moments/Triallele/Numerics.py:100-112 — both copies are in the same file, so extract the 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) moments/TwoLocus/Numerics.py:1110— moments/TwoLocus/Numerics.py:1110-1122 | moments/TwoLocus/Numerics.py:1124-1136 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (13 lines × 2) REDACTED:1053— REDACTED:1053-1065 | REDACTED:1068-1080 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:1053` it begins part-way through the construct above it, so those exact lines 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) REDACTED:218— REDACTED:218-230 | REDACTED:266-278 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:218` it begins part-way through the construct above it, so those exact lines 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) REDACTED:793— REDACTED:793-798 | REDACTED:804-809 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (6 lines × 2) REDACTED:625— REDACTED:625-630 | REDACTED:795-800 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (6 lines × 2) moments/LD/Matrices.py:86— moments/LD/Matrices.py:86-91 | moments/LD/Matrices.py:185-192 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/LD/Matrices.py:185` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (6 lines × 2) moments/LD/Matrices.py:524— moments/LD/Matrices.py:524-529 | moments/LD/Matrices.py:548-553 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/LD/Matrices.py:524` it begins part-way through the construct above it, so those exact lines 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) moments/LD/stats_from_genotype_counts.py:365— moments/LD/stats_from_genotype_counts.py:365-370 | moments/LD/stats_from_genotype_counts.py:412-417 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/LD/stats_from_genotype_counts.py:365` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (6 lines × 2) moments/LD/stats_from_genotype_counts.py:1071— moments/LD/stats_from_genotype_counts.py:1071-1076 | moments/LD/stats_from_genotype_counts.py:1413-1418 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/LD/stats_from_genotype_counts.py:1071` it begins part-way through the construct above it, so those exact lines 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) REDACTED:275— REDACTED:275-280 | REDACTED:285-290 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (6 lines × 2) moments/TwoLocus/Numerics.py:893— moments/TwoLocus/Numerics.py:893-898 | moments/TwoLocus/Numerics.py:1176-1181 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (6 lines × 2) moments/TwoLocus/Numerics.py:1187— moments/TwoLocus/Numerics.py:1187-1192 | moments/TwoLocus/Numerics.py:1208-1213 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/TwoLocus/Numerics.py:1187` it begins part-way through the construct above it, so those exact lines 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) moments/Triallele/Jackknife.py:62— moments/Triallele/Jackknife.py:62-67 | moments/Triallele/Jackknife.py:122-127 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (6 lines × 2) moments/LD/Parsing.py:1516— moments/LD/Parsing.py:1516-1521 | moments/LD/Parsing.py:1624-1629 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (6 lines × 2) moments/LD/stats_from_haplotype_counts.py:163— moments/LD/stats_from_haplotype_counts.py:163-168 | moments/LD/stats_from_haplotype_counts.py:315-320 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/LD/stats_from_haplotype_counts.py: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. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `moments/LD/stats_from_haplotype_counts.py:313` calls `sum` and `moments/LD/stats_from_haplotype_counts.py:162` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (9 lines × 2) moments/Demes/Demes.py:1332— moments/Demes/Demes.py:1332-1340 | moments/Demes/Demes.py:1617-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.
Duplicated block (9 lines × 2) moments/LD/Matrices.py:518— moments/LD/Matrices.py:518-526 | moments/LD/Matrices.py: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. Read the line range as the matched WINDOW rather than a finished unit: at `moments/LD/Matrices.py:518` it begins part-way through the construct above it, so those exact lines 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) moments/LD/stats_from_genotype_counts.py:323— moments/LD/stats_from_genotype_counts.py:323-331 | moments/LD/stats_from_genotype_counts.py:370-378 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/LD/stats_from_genotype_counts.py:323` it does not close everything it opens, so those exact lines 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) moments/LD/stats_from_genotype_counts.py:555— moments/LD/stats_from_genotype_counts.py:555-563 | moments/LD/stats_from_genotype_counts.py:594-602 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (9 lines × 2) moments/Manips.py:313— moments/Manips.py:313-321 | moments/Manips.py:375-383 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/Manips.py:313` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (9 lines × 2) moments/Misc.py:392— moments/Misc.py:392-400 | REDACTED:1742-1752 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (9 lines × 2) moments/Triallele/Jackknife.py:188— moments/Triallele/Jackknife.py:188-196 | moments/Triallele/Jackknife.py:206-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 (9 lines × 2) moments/Triallele/Numerics.py:370— moments/Triallele/Numerics.py:370-378 | moments/Triallele/Numerics.py:408-416 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/Triallele/Numerics.py:370` it begins part-way through the construct above it, so those exact lines 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) moments/TwoLocus/Numerics.py:609— moments/TwoLocus/Numerics.py:609-617 | moments/TwoLocus/Numerics.py:647-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 `moments/TwoLocus/Numerics.py:609` it begins part-way through the construct above it, so those exact lines 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) moments/TwoLocus/Numerics.py:657— moments/TwoLocus/Numerics.py:657-665 | moments/TwoLocus/Numerics.py:716-724 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/TwoLocus/Numerics.py:657` it does not close everything it opens, so those exact lines 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) moments/TwoLocus/Util.py:216— moments/TwoLocus/Util.py:216-224 | moments/TwoLocus/Util.py:239-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 `moments/TwoLocus/Util.py:216` it begins part-way through the construct above it, so those exact lines 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) moments/LD/Godambe.py:356— moments/LD/Godambe.py:356-366 | moments/LD/Godambe.py:461-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.
Duplicated block (11 lines × 2) moments/LD/stats_from_genotype_counts.py:581— moments/LD/stats_from_genotype_counts.py:581-591 | moments/LD/stats_from_genotype_counts.py:611-621 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (11 lines × 2) moments/Manips.py:753— moments/Manips.py:753-763 | moments/Manips.py:883-893 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (11 lines × 2) moments/Misc.py:831— moments/Misc.py:831-841 | REDACTED:1758-1768 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (11 lines × 2) moments/TwoLocus/Numerics.py:526— moments/TwoLocus/Numerics.py:526-536 | moments/TwoLocus/Numerics.py:564-574 — both copies are in the same file, so extract the 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) moments/Demes/Demes.py:1402— moments/Demes/Demes.py:1402-1412 | moments/Demes/Demes.py:1662-1672 — both copies are in the same file, so extract the 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) moments/LD/stats_from_genotype_counts.py:1253— moments/LD/stats_from_genotype_counts.py:1253-1263 | moments/LD/stats_from_genotype_counts.py:1419-1429 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/LD/stats_from_genotype_counts.py:1253` it begins part-way through the construct above it, so those exact lines 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) moments/LD/stats_from_genotype_counts.py:661— moments/LD/stats_from_genotype_counts.py:661-671 | moments/LD/stats_from_genotype_counts.py:1351-1361 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/LD/stats_from_genotype_counts.py:661` it begins part-way through the construct above it, so those exact lines 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) moments/LD/__init__.py:28— moments/LD/__init__.py:28-38 | moments/__init__.py:46-56 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (7 lines × 2) moments/Demes/Demes.py:162— moments/Demes/Demes.py:162-168 | moments/Demes/Demes.py:442-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. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `moments/Demes/Demes.py:160` calls `ValueError` and `moments/Demes/Demes.py:440` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (7 lines × 2) moments/Godambe.py:30— moments/Godambe.py:30-36 | moments/LD/Godambe.py:71-77 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (7 lines × 2) REDACTED:33— REDACTED:33-39 | REDACTED:37-43 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 7 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. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (7 lines × 2) moments/LD/Matrices.py:958— moments/LD/Matrices.py:958-964 | moments/LD/Matrices.py:1000-1006 — both copies are in the same file, so extract the 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, `moments/LD/Matrices.py:1007` calls `split` and `moments/LD/Matrices.py:965` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (7 lines × 2) moments/Manips.py:118— moments/Manips.py:118-124 | moments/Manips.py:176-182 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/Manips.py: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 (7 lines × 2) moments/Manips.py:303— moments/Manips.py:303-309 | moments/Manips.py:365-371 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/Manips.py:303` it does not close everything it opens, so those exact lines 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) moments/Triallele/Numerics.py:338— moments/Triallele/Numerics.py:338-344 | moments/Triallele/Numerics.py:440-446 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/Triallele/Numerics.py:338` it begins part-way through the construct above it, so those exact lines 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) moments/TwoLocus/Numerics.py:94— moments/TwoLocus/Numerics.py:94-100 | moments/TwoLocus/Numerics.py:111-117 — both copies are in the same file, so extract the 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) moments/LD/Parsing.py:447— moments/LD/Parsing.py:447-453 | moments/LD/Parsing.py:543-549 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/LD/Parsing.py:447` it begins part-way through the construct above it, so those 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. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `moments/LD/Parsing.py:542` calls `compute_D` and `moments/LD/Parsing.py:446` 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 × 2) moments/Demes/Inference.py:546— moments/Demes/Inference.py:546-550 | moments/Demes/Inference.py:1156-1160 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (5 lines × 2) REDACTED:206— REDACTED:206-210 | REDACTED:251-255 — both copies are in the same file, so extract the 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) moments/LD/Matrices.py:546— moments/LD/Matrices.py:546-550 | moments/LD/Matrices.py:570-574 — both copies are in the same file, so extract the 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) moments/LD/stats_from_genotype_counts.py:687— moments/LD/stats_from_genotype_counts.py:687-691 | moments/LD/stats_from_genotype_counts.py:1112-1116 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/LD/stats_from_genotype_counts.py:687` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (5 lines × 2) moments/LD/stats_from_genotype_counts.py:1057— moments/LD/stats_from_genotype_counts.py:1057-1061 | moments/LD/stats_from_genotype_counts.py:1247-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 `moments/LD/stats_from_genotype_counts.py:1057` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (5 lines × 2) moments/TwoLocus/Numerics.py:1194— moments/TwoLocus/Numerics.py:1194-1198 | moments/TwoLocus/Numerics.py:1215-1219 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/TwoLocus/Numerics.py:1194` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (5 lines × 2) REDACTED:73— REDACTED:73-77 | REDACTED:116-120 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (5 lines × 2) REDACTED:223— REDACTED:223-227 | REDACTED:123-127 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (5 lines × 2) moments/TwoLocus/Numerics.py:408— moments/TwoLocus/Numerics.py:408-412 | moments/TwoLocus/Numerics.py:418-422 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (8 lines × 2) moments/Godambe.py:38— moments/Godambe.py:38-45 | moments/LD/Godambe.py:79-86 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (8 lines × 2) moments/Inference.py:76— moments/Inference.py:76-83 | moments/TwoLocus/Inference.py:183-190 — before extracting anything, compare `moments/Inference.py` and `moments/TwoLocus/Inference.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 141 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 × 2) moments/LD/stats_from_genotype_counts.py:344— moments/LD/stats_from_genotype_counts.py:344-351 | moments/LD/stats_from_genotype_counts.py:391-398 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/LD/stats_from_genotype_counts.py:344` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8 lines × 2) moments/LD/stats_from_genotype_counts.py:646— moments/LD/stats_from_genotype_counts.py:646-653 | moments/LD/stats_from_genotype_counts.py:829-836 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/LD/stats_from_genotype_counts.py:646` it does not close everything it opens, so those exact lines 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) moments/Triallele/Numerics.py:444— moments/Triallele/Numerics.py:444-451 | moments/Triallele/Numerics.py:508-515 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/Triallele/Numerics.py:444` it begins part-way through the construct above it, so those exact lines 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) moments/Triallele/Numerics.py:470— moments/Triallele/Numerics.py:470-477 | moments/Triallele/Numerics.py:489-496 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/Triallele/Numerics.py:470` it begins part-way through the construct above it, so those exact lines 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) moments/Triallele/Numerics.py:507— moments/Triallele/Numerics.py:507-514 | moments/Triallele/Numerics.py:526-533 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/Triallele/Numerics.py:507` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8 lines × 2) moments/Plotting.py:1074— moments/Plotting.py:1074-1081 | moments/Plotting.py:1085-1092 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/Plotting.py:1074` it begins part-way through the construct above it, so those exact lines 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) moments/Demes/Demes.py:1065— moments/Demes/Demes.py:1065-1076 | moments/Demes/Demes.py:1131-1142 — both copies are in the same file, so extract the 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) REDACTED:1107— REDACTED:1107-1118 | REDACTED:583-594 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 7 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. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:1107` it does not close everything it opens, so those exact lines 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) moments/Triallele/Numerics.py:397— moments/Triallele/Numerics.py:397-408 | moments/Triallele/Numerics.py:499-510 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/Triallele/Numerics.py:397` it begins part-way through the construct above it, so those 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, `moments/Triallele/Numerics.py:396` calls `choose` and `moments/Triallele/Numerics.py:498` 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 × 2) moments/TwoLocus/Numerics.py:635— moments/TwoLocus/Numerics.py:635-646 | moments/TwoLocus/Numerics.py:716-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. Read the line range as the matched WINDOW rather than a finished unit: at `moments/TwoLocus/Numerics.py:635` it does not close everything it opens, so those exact lines 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) moments/TwoLocus/Numerics.py:728— moments/TwoLocus/Numerics.py:728-739 | moments/TwoLocus/Numerics.py:749-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. Read the line range as the matched WINDOW rather than a finished unit: at `moments/TwoLocus/Numerics.py:728` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12 lines × 2) REDACTED:161— REDACTED:161-172 | REDACTED:175-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. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (12 lines × 2) moments/LD/stats_from_genotype_counts.py:1118— moments/LD/stats_from_genotype_counts.py:1118-1129 | moments/LD/stats_from_genotype_counts.py:1363-1374 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/LD/stats_from_genotype_counts.py:1118` it begins part-way through the construct above it, so those exact lines 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) moments/Demes/Demes.py:1119— moments/Demes/Demes.py:1119-1133 | moments/Demes/Demes.py:1134-1148 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/Demes/Demes.py:1119` it begins part-way through the construct above it, so those exact lines 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) moments/Demes/Inference.py:655— moments/Demes/Inference.py:655-669 | moments/Demes/Inference.py:1271-1285 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/Demes/Inference.py:655` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (15 lines × 2) REDACTED:1010— REDACTED:1010-1024 | REDACTED:510-524 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 7 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 (15 lines × 2) moments/LD/Inference.py:448— moments/LD/Inference.py:448-462 | moments/TwoLocus/Inference.py:144-158 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (15 lines × 2) moments/LD/Matrices.py:1132— moments/LD/Matrices.py:1132-1146 | moments/LD/Matrices.py:2525-2539 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/LD/Matrices.py:1132` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (15 lines × 2) moments/TwoLocus/Util.py:291— moments/TwoLocus/Util.py:291-305 | moments/TwoLocus/Util.py:334-348 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/TwoLocus/Util.py:291` it begins part-way through the construct above it, so those exact lines 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) moments/Demes/Inference.py:119— moments/Demes/Inference.py:119-132 | moments/Demes/Inference.py:188-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.
Duplicated block (14 lines × 2) moments/LD/Matrices.py:1036— moments/LD/Matrices.py:1036-1049 | moments/LD/Matrices.py:1060-1073 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/LD/Matrices.py:1036` it does not close everything it opens, so those exact lines 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) moments/LD/stats_from_genotype_counts.py:491— moments/LD/stats_from_genotype_counts.py:491-504 | moments/LD/stats_from_genotype_counts.py:559-572 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (14 lines × 2) moments/Manips.py:219— moments/Manips.py:219-232 | moments/Manips.py:282-295 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (14 lines × 2) REDACTED:1603— REDACTED:1603-1616 | REDACTED:405-418 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `REDACTED:1601` calls `write` and `REDACTED:403` 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) moments/Triallele/Numerics.py:551— moments/Triallele/Numerics.py:551-564 | moments/Triallele/Numerics.py:579-592 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/Triallele/Numerics.py:551` it begins part-way through the construct above it, so those 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) · ×5
Members sharing a duplicated core (4 members, 50+ identical tokens) moments/Inference.py:115— moments/Inference.py:115-220 | moments/Inference.py:739-842 | moments/Inference.py:971-1060 | moments/TwoLocus/Inference.py:222-295 — 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) moments/Triallele/Jackknife.py:23— moments/Triallele/Jackknife.py:23-58 | moments/Triallele/Jackknife.py:83-118 | REDACTED:143-264 | REDACTED:269-392 — 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) moments/TwoLocus/Demographics.py:145— moments/TwoLocus/Demographics.py:145-187 | moments/TwoLocus/Demographics.py:191-233 | moments/TwoLocus/Demographics.py:237-279 | moments/TwoLocus/Demographics.py:283-325 — 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) moments/TwoLocus/Util.py:164— moments/TwoLocus/Util.py:164-194 | moments/TwoLocus/Util.py:198-251 | moments/TwoLocus/Util.py:255-350 | moments/TwoLocus/Util.py:354-465 — 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) moments/TwoLocus/Util.py:559— moments/TwoLocus/Util.py:559-580 | moments/TwoLocus/Util.py:586-607 | moments/TwoLocus/Util.py:613-634 | moments/TwoLocus/Util.py:640-661 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
Duplicated block (8 lines × 3) moments/LD/Matrices.py:652— moments/LD/Matrices.py:652-659 | moments/LD/Matrices.py:672-679 | moments/LD/Matrices.py:733-740 — 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 `moments/LD/Matrices.py:652` it begins part-way through the construct above it, so those exact lines 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) moments/LD/Parsing.py:882— moments/LD/Parsing.py:882-889 | moments/LD/Parsing.py:906-913 | moments/LD/Parsing.py:929-936 — 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 `moments/LD/Parsing.py:882` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (8 lines × 3) moments/Triallele/Numerics.py:369— moments/Triallele/Numerics.py:369-376 | moments/Triallele/Numerics.py:388-395 | moments/Triallele/Numerics.py:407-414 — 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 `moments/Triallele/Numerics.py:369` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `moments/Triallele/Numerics.py:396` calls `choose` and `moments/Triallele/Numerics.py: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 (8 lines × 3) moments/Triallele/Numerics.py:429— moments/Triallele/Numerics.py:429-436 | moments/Triallele/Numerics.py:522-529 | moments/Triallele/Numerics.py:570-577 — 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 `moments/Triallele/Numerics.py:429` it begins part-way through the construct above it, so those exact lines 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) moments/Triallele/Numerics.py:466— moments/Triallele/Numerics.py:466-473 | moments/Triallele/Numerics.py:551-558 | moments/Triallele/Numerics.py:579-586 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/Triallele/Numerics.py:466` it begins part-way through the construct above it, so those exact lines 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) moments/LD/Godambe.py:377— moments/LD/Godambe.py:377-383 | moments/LD/Godambe.py:482-488 | moments/LD/Godambe.py:575-581 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (7 lines × 3) moments/Triallele/Numerics.py:338— moments/Triallele/Numerics.py:338-344 | moments/Triallele/Numerics.py:372-378 | moments/Triallele/Numerics.py:512-518 — 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 `moments/Triallele/Numerics.py:338` it begins part-way through the construct above it, so those exact lines 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) moments/Triallele/Numerics.py:445— moments/Triallele/Numerics.py:445-451 | moments/Triallele/Numerics.py:491-497 | moments/Triallele/Numerics.py:509-515 — 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 `moments/Triallele/Numerics.py:445` it begins part-way through the construct above it, so those exact lines 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) moments/Triallele/Numerics.py:444— moments/Triallele/Numerics.py:444-450 | moments/Triallele/Numerics.py:508-514 | moments/Triallele/Numerics.py:527-533 — 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 `moments/Triallele/Numerics.py:444` it begins part-way through the construct above it, so those 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, `moments/Triallele/Numerics.py:526` calls `choose` and `moments/Triallele/Numerics.py:443` 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) moments/LD/Matrices.py:503— moments/LD/Matrices.py:503-509 | moments/LD/Matrices.py:525-531 | moments/LD/Matrices.py:549-555 — 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.
Hotspot: moments/Demes/Inference.py moments/Demes/Inference.py:560— moments/Demes/Inference.py changed 15 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 21 in Inference.optimize at line 560. 2 of those changes were fix/bug commits, and the other 13 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-08-15..2026-11-13, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-15 15:20:42 -06:00' --until='2026-11-13 15:20:42 -06:00' --full-history --no-merges -- moments/Demes/Inference.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Hotspot: moments/LD/Parsing.py moments/LD/Parsing.py:96— moments/LD/Parsing.py changed 7 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 20 in Parsing.get_genotypes at line 96. 2 of those changes were fix/bug commits, and the other 5 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-08-15..2026-11-13, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-15 15:20:42 -06:00' --until='2026-11-13 15:20:42 -06:00' --full-history --no-merges -- moments/LD/Parsing.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Hotspot: moments/LD/Plotting.py moments/LD/Plotting.py:140— moments/LD/Plotting.py changed 3 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 35 in Plotting.plot_ld_curves_comp at line 140. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-08-15..2026-11-13, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-15 15:20:42 -06:00' --until='2026-11-13 15:20:42 -06:00' --full-history --no-merges -- moments/LD/Plotting.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Hotspot: moments/Misc.py moments/Misc.py:409— moments/Misc.py changed 2 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 37 in Misc.make_data_dict_vcf at line 409. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-08-15..2026-11-13, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-15 15:20:42 -06:00' --until='2026-11-13 15:20:42 -06:00' --full-history --no-merges -- moments/Misc.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
D4 · Code Duplication· Edited copy of a member (5 corresponding lines) · ×4
Edited copy of a member (5 corresponding lines) REDACTED:153— REDACTED:153-157 | REDACTED:219-224 — These two members are one piece of code written twice and then edited apart: 5 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (5 corresponding lines) REDACTED:161— REDACTED:161-165 | REDACTED:228-233 — These two members are one piece of code written twice and then edited apart: 5 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (5 corresponding lines) REDACTED:306— REDACTED:306-310 | REDACTED:331-335 — These two members are one piece of code written twice and then edited apart: 5 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (5 corresponding lines) moments/Triallele/Numerics.py:13— moments/Triallele/Numerics.py:13-21 | moments/Triallele/Numerics.py:25-29 — 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.
Duplicated block (16 lines × 2) moments/LinearSystem.py:112— moments/LinearSystem.py:112-127 | moments/LinearSystem.py:273-288 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (16 lines × 2) moments/Misc.py:473— moments/Misc.py:473-488 | moments/Misc.py:495-510 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (16 lines × 2) moments/TwoLocus/Numerics.py:509— moments/TwoLocus/Numerics.py:509-524 | moments/TwoLocus/Numerics.py:547-562 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (16 lines × 2) moments/Plotting.py:689— moments/Plotting.py:689-704 | moments/Plotting.py:1052-1067 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (11–12 lines × 2) moments/Demes/Inference.py:817— moments/Demes/Inference.py:817-828 | moments/Demes/Inference.py:1433-1443 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/Demes/Inference.py:817` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (11–12 lines × 2) moments/LD/Parsing.py:877— moments/LD/Parsing.py:877-888 | moments/LD/Parsing.py:925-935 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/LD/Parsing.py:877` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `moments/LD/Parsing.py:923` calls `pi2` and `moments/LD/Parsing.py:877` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (11–12 lines × 2) moments/LD/stats_from_genotype_counts.py:877— moments/LD/stats_from_genotype_counts.py:877-888 | moments/LD/stats_from_genotype_counts.py:989-999 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (11–12 lines × 2) moments/LD/stats_from_genotype_counts.py:863— moments/LD/stats_from_genotype_counts.py:863-874 | moments/LD/stats_from_genotype_counts.py:1170-1180 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/LD/stats_from_genotype_counts.py:863` it begins part-way through the construct above it, so those exact lines 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) moments/LD/Matrices.py:702— moments/LD/Matrices.py:702-707 | moments/LD/Matrices.py:789-794 | moments/LD/Matrices.py:816-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 `moments/LD/Matrices.py:702` it begins part-way through the construct above it, so those exact lines 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) moments/LD/stats_from_genotype_counts.py:154— moments/LD/stats_from_genotype_counts.py:154-159 | moments/LD/stats_from_genotype_counts.py:344-351 | moments/LD/stats_from_genotype_counts.py:391-398 — 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 `moments/LD/stats_from_genotype_counts.py:154` it begins part-way through the construct above it, so those exact lines 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) moments/LD/stats_from_genotype_counts.py:349— moments/LD/stats_from_genotype_counts.py:349-354 | moments/LD/stats_from_genotype_counts.py:359-364 | moments/LD/stats_from_genotype_counts.py:431-436 — 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 `moments/LD/stats_from_genotype_counts.py:349` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (6 lines × 3) moments/LD/stats_from_genotype_counts.py:396— moments/LD/stats_from_genotype_counts.py:396-401 | moments/LD/stats_from_genotype_counts.py:406-411 | moments/LD/stats_from_genotype_counts.py:456-461 — 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 `moments/LD/stats_from_genotype_counts.py:396` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (5 lines × 3) moments/LD/Parsing.py:899— moments/LD/Parsing.py:899-903 | moments/LD/Parsing.py:923-927 | moments/LD/Parsing.py:954-958 — 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 `moments/LD/Parsing.py:899` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (5 lines × 3) moments/LD/stats_from_genotype_counts.py:662— moments/LD/stats_from_genotype_counts.py:662-666 | moments/LD/stats_from_genotype_counts.py:1090-1094 | moments/LD/stats_from_genotype_counts.py:1352-1356 — 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 `moments/LD/stats_from_genotype_counts.py:662` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (5 lines × 3) moments/LinearSystem.py:113— moments/LinearSystem.py:113-117 | moments/LinearSystem.py:187-191 | moments/LinearSystem.py:274-278 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (5 lines × 3) REDACTED:87— REDACTED:87-91 | REDACTED:230-234 | REDACTED:130-134 — 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.
D4 · Code Duplication· Members sharing a duplicated core (5 members, 50+ identical tokens) · ×3
Members sharing a duplicated core (5 members, 50+ identical tokens) REDACTED:599— REDACTED:599-669 | moments/Numerics.py:140-184 | REDACTED:1467-1543 | REDACTED:186-248 | REDACTED:322-370 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
Members sharing a duplicated core (5 members, 50+ identical tokens) moments/Manips.py:80— moments/Manips.py:80-134 | moments/Manips.py:138-192 | moments/Manips.py:196-255 | moments/Manips.py:259-321 | moments/Manips.py:325-383 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
Members sharing a duplicated core (5 members, 50+ identical tokens) REDACTED:216— REDACTED:216-229 | REDACTED:232-251 | REDACTED:254-273 | REDACTED:276-295 | REDACTED:298-317 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
D4 · Code Duplication· Edited copy of a member (22 corresponding lines) · ×3
Edited copy of a member (22 corresponding lines) moments/Godambe.py:89— moments/Godambe.py:89-122 | moments/LD/Godambe.py:130-151 — 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) moments/LD/Demographics1D.py:76— moments/LD/Demographics1D.py:76-97 | moments/LD/Demographics1D.py:101-122 — 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) moments/Demographics1D.py:26— moments/Demographics1D.py:26-47 | moments/Demographics1D.py:104-126 — 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.
Duplicated block (27 lines × 2) moments/Plotting.py:718— moments/Plotting.py:718-744 | moments/Plotting.py:1090-1116 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/Plotting.py:718` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (27 lines × 2) REDACTED:844— REDACTED:844-870 | REDACTED:884-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.
Duplicated block (27 lines × 2) moments/Parsing.py:840— moments/Parsing.py:840-866 | moments/Parsing.py:879-905 — both copies are in the same file, so extract the 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) moments/Inference.py:1225— moments/Inference.py:1225-1242 | moments/TwoLocus/Inference.py:89-106 — before extracting anything, compare `moments/Inference.py` and `moments/TwoLocus/Inference.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 141 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (18 lines × 2) moments/LD/Matrices.py:1723— moments/LD/Matrices.py:1723-1740 | moments/LD/Matrices.py:2693-2710 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/LD/Matrices.py:1723` it does not close everything it opens, so those exact lines 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) moments/LD/stats_from_genotype_counts.py:511— moments/LD/stats_from_genotype_counts.py:511-528 | moments/LD/stats_from_genotype_counts.py:598-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.
Duplicated block (12 lines × 3) moments/Godambe.py:430— moments/Godambe.py:430-441 | moments/Godambe.py:562-573 | moments/Godambe.py:638-649 — 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, `moments/Godambe.py:561` calls `concatenate` and `moments/Godambe.py:429` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (12 lines × 3) REDACTED:1083— REDACTED:1083-1094 | REDACTED:569-580 | REDACTED:758-769 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 7 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. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `REDACTED:566` calls `any`, `ValueError` and `REDACTED:1082` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (12 lines × 3) moments/TwoLocus/Util.py:167— moments/TwoLocus/Util.py:167-178 | moments/TwoLocus/Util.py:201-212 | moments/TwoLocus/Util.py:258-269 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (11 lines × 3) moments/LD/stats_from_genotype_counts.py:518— moments/LD/stats_from_genotype_counts.py:518-528 | moments/LD/stats_from_genotype_counts.py:568-578 | moments/LD/stats_from_genotype_counts.py:605-615 — 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 (11 lines × 3) moments/LD/stats_from_genotype_counts.py:695— moments/LD/stats_from_genotype_counts.py:695-705 | moments/LD/stats_from_genotype_counts.py:715-725 | moments/LD/stats_from_genotype_counts.py:735-745 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (11 lines × 3) moments/LD/stats_from_haplotype_counts.py:212— moments/LD/stats_from_haplotype_counts.py:212-222 | moments/LD/stats_from_haplotype_counts.py:229-239 | moments/LD/stats_from_haplotype_counts.py:261-271 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/LD/stats_from_haplotype_counts.py:212` it begins part-way through the construct above it, so those exact lines 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) moments/LD/stats_from_genotype_counts.py:519— moments/LD/stats_from_genotype_counts.py:519-527 | moments/LD/stats_from_genotype_counts.py:544-552 | moments/LD/stats_from_genotype_counts.py:569-577 | moments/LD/stats_from_genotype_counts.py:606-614 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (9 lines × 4) moments/LD/stats_from_haplotype_counts.py:86— moments/LD/stats_from_haplotype_counts.py:86-94 | moments/LD/stats_from_haplotype_counts.py:213-221 | moments/LD/stats_from_haplotype_counts.py:230-238 | moments/LD/stats_from_haplotype_counts.py:262-270 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (9 lines × 4) moments/Triallele/Numerics.py:414— moments/Triallele/Numerics.py:414-422 | moments/Triallele/Numerics.py:434-442 | moments/Triallele/Numerics.py:480-488 | moments/Triallele/Numerics.py:536-544 — 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 `moments/Triallele/Numerics.py:414` it begins part-way through the construct above it, so those 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, `moments/Triallele/Numerics.py:478` calls `choose` and `moments/Triallele/Numerics.py:412` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (8 lines × 4) moments/Triallele/Numerics.py:342— moments/Triallele/Numerics.py:342-349 | moments/Triallele/Numerics.py:406-413 | moments/Triallele/Numerics.py:425-432 | moments/Triallele/Numerics.py:547-554 — 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 `moments/Triallele/Numerics.py:342` it begins part-way through the construct above it, so those 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, `moments/Triallele/Numerics.py:423` calls `choose` and `moments/Triallele/Numerics.py:340` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (8 lines × 4) moments/TwoLocus/Util.py:164— moments/TwoLocus/Util.py:164-171 | moments/TwoLocus/Util.py:198-205 | moments/TwoLocus/Util.py:255-262 | moments/TwoLocus/Util.py:354-361 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (8 lines × 4) moments/TwoLocus/Util.py:183— moments/TwoLocus/Util.py:183-190 | moments/TwoLocus/Util.py:229-236 | moments/TwoLocus/Util.py:306-313 | moments/TwoLocus/Util.py:413-420 — 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 `moments/TwoLocus/Util.py:183` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7 lines × 4) moments/LD/Matrices.py:650— moments/LD/Matrices.py:650-656 | moments/LD/Matrices.py:670-676 | moments/LD/Matrices.py:731-737 | moments/LD/Matrices.py:758-764 — 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 `moments/LD/Matrices.py:650` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7 lines × 4) moments/Triallele/Numerics.py:343— moments/Triallele/Numerics.py:343-349 | moments/Triallele/Numerics.py:369-375 | moments/Triallele/Numerics.py:388-394 | moments/Triallele/Numerics.py:407-413 — 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 `moments/Triallele/Numerics.py:343` it begins part-way through the construct above it, so those 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, `moments/Triallele/Numerics.py:396` calls `choose` and `moments/Triallele/Numerics.py: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 (7 lines × 4) moments/Triallele/Numerics.py:372— moments/Triallele/Numerics.py:372-378 | moments/Triallele/Numerics.py:410-416 | moments/Triallele/Numerics.py:494-500 | moments/Triallele/Numerics.py:512-518 — 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 `moments/Triallele/Numerics.py:372` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
XxxComment moments/Plotting.py:946— # XXX: I can't set the axis ticks to be just the endpoints. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
XxxComment REDACTED:313— # XXX don't think this is needed — 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 (36 corresponding lines) · ×2
Edited copy of a member (36 corresponding lines) moments/Parsing.py:840— moments/Parsing.py:840-875 | moments/Parsing.py:879-914 — 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) moments/Godambe.py:289— moments/Godambe.py:289-334 | moments/Godambe.py:338-373 — These two members are one piece of code written twice and then edited apart: 36 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (46 corresponding lines) · ×2
Edited copy of a member (46 corresponding lines) moments/Demes/Inference.py:505— moments/Demes/Inference.py:505-550 | moments/Demes/Inference.py:1108-1160 — 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) moments/Demographics3D.py:10— moments/Demographics3D.py:10-60 | moments/LD/Demographics3D.py:10-55 — 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 (5 members, 5+ corresponding lines) · ×2
Edited copies of one member (5 members, 5+ corresponding lines) REDACTED:301— REDACTED:301-305 | REDACTED:309-313 | REDACTED:334-339 | REDACTED:343-348 | REDACTED:352-357 — These 5 members are one piece of code written 5 times and then edited apart: every two of them correspond over at least 5 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, 5+ corresponding lines) REDACTED:246— REDACTED:246-251 | REDACTED:255-260 | REDACTED:325-329 | REDACTED:361-366 | REDACTED:370-375 — These 5 members are one piece of code written 5 times and then edited apart: every two of them correspond over at least 5 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 (8 members, 6+ corresponding lines) · ×2
Edited copies of one member (8 members, 6+ corresponding lines) REDACTED:344— REDACTED:344-351 | REDACTED:413-418 | REDACTED:532-540 | REDACTED:568-576 | REDACTED:580-588 | REDACTED:643-649 | REDACTED:673-679 | REDACTED:683-689 — These 8 members are one piece of code written 8 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 8 times and the copies will drift further apart.
Edited copies of one member (8 members, 6+ corresponding lines) REDACTED:399— REDACTED:399-406 | REDACTED:458-463 | REDACTED:472-480 | REDACTED:484-492 | REDACTED:496-504 | REDACTED:593-599 | REDACTED:603-609 | REDACTED:613-619 — These 8 members are one piece of code written 8 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 8 times and the copies will drift further apart.
D4 · Code Duplication· Edited copies of one member (6 members, 6+ corresponding lines) · ×2
Edited copies of one member (6 members, 6+ corresponding lines) REDACTED:355— REDACTED:355-362 | REDACTED:422-427 | REDACTED:520-528 | REDACTED:556-564 | REDACTED:633-639 | REDACTED:663-669 — These 6 members are one piece of code written 6 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 6 times and the copies will drift further apart.
Edited copies of one member (6 members, 6+ corresponding lines) REDACTED:366— REDACTED:366-373 | REDACTED:431-436 | REDACTED:508-516 | REDACTED:544-552 | REDACTED:623-629 | REDACTED:653-659 — These 6 members are one piece of code written 6 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 6 times and the copies will drift further apart.
D4 · Code Duplication· Edited copies of one member (4 members, 5+ corresponding lines) · ×2
Edited copies of one member (4 members, 5+ corresponding lines) REDACTED:290— REDACTED:290-294 | REDACTED:315-319 | REDACTED:377-384 | REDACTED:440-445 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 5 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, 5+ corresponding lines) REDACTED:298— REDACTED:298-302 | REDACTED:323-327 | REDACTED:388-395 | REDACTED:449-454 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 5 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 (4 corresponding lines) · ×2
Edited copy of a member (4 corresponding lines) REDACTED:80— REDACTED:80-84 | REDACTED:98-101 — These two members are one piece of code written twice and then edited apart: 4 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (4 corresponding lines) REDACTED:216— REDACTED:216-220 | REDACTED:92-95 — These two members are one piece of code written twice and then edited apart: 4 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Duplicated block (37 lines × 2) moments/Godambe.py:49— moments/Godambe.py:49-85 | moments/LD/Godambe.py:90-126 — 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 (37 lines × 2) moments/Manips.py:80— moments/Manips.py:80-116 | moments/Manips.py:138-174 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (35 lines × 2) moments/LD/Matrices.py:4123— moments/LD/Matrices.py:4123-4157 | moments/LD/Matrices.py:4880-4914 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/LD/Matrices.py:4123` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (35 lines × 2) moments/LinearSystem.py:141— moments/LinearSystem.py:141-175 | moments/LinearSystem.py:224-258 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (25 lines × 2) moments/LD/Util.py:122— moments/LD/Util.py:122-146 | moments/Misc.py:125-149 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (25 lines × 2) moments/Manips.py:259— moments/Manips.py:259-287 | moments/Manips.py:325-349 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (22–23 lines × 4) moments/LD/Matrices.py:2761— moments/LD/Matrices.py:2761-2783 | moments/LD/Matrices.py:2851-2873 | moments/LD/Matrices.py:3069-3090 | moments/LD/Matrices.py:3177-3198 — 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 `moments/LD/Matrices.py:2761` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (22–23 lines × 4) moments/LD/Matrices.py:2791— moments/LD/Matrices.py:2791-2813 | moments/LD/Matrices.py:2881-2903 | moments/LD/Matrices.py:3105-3126 | moments/LD/Matrices.py:3213-3234 — 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 `moments/LD/Matrices.py:2791` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (21–22 lines × 2) moments/LD/Matrices.py:2821— moments/LD/Matrices.py:2821-2842 | moments/LD/Matrices.py:3141-3161 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/LD/Matrices.py:2821` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (21–22 lines × 2) moments/TwoLocus/Util.py:372— moments/TwoLocus/Util.py:372-392 | moments/TwoLocus/Util.py:423-444 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/TwoLocus/Util.py:372` it begins part-way through the construct above it, so those 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 (19 lines × 3) REDACTED:106— REDACTED:106-124 | REDACTED:166-186 | REDACTED:195-214 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:166` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (19 lines × 3) moments/LD/Matrices.py:1377— moments/LD/Matrices.py:1377-1395 | moments/LD/Matrices.py:1562-1580 | moments/LD/Matrices.py:1639-1657 — 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 `moments/LD/Matrices.py:1377` it does not close everything it opens, so those exact lines 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) moments/LD/stats_from_genotype_counts.py:1309— moments/LD/stats_from_genotype_counts.py:1309-1327 | moments/LD/stats_from_haplotype_counts.py:246-264 — 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 `moments/LD/stats_from_genotype_counts.py:1309` it begins part-way through the construct above it, so those exact lines 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) moments/TwoLocus/Util.py:394— moments/TwoLocus/Util.py:394-412 | moments/TwoLocus/Util.py:445-463 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/TwoLocus/Util.py:394` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (17–18 lines × 2) moments/Triallele/Integration.py:59— moments/Triallele/Integration.py:59-75 | moments/Triallele/Integration.py:101-118 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (17–18 lines × 2) moments/TwoLocus/Util.py:273— moments/TwoLocus/Util.py:273-289 | moments/TwoLocus/Util.py:316-333 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/TwoLocus/Util.py:273` it begins part-way through the construct above it, so those 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) REDACTED:469— REDACTED:469-483 | REDACTED:691-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. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED: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.
Duplicated block (14–15 lines × 2) moments/LD/Parsing.py:339— moments/LD/Parsing.py:339-353 | moments/LD/Parsing.py:357-370 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (13–14 lines × 3) REDACTED:991— REDACTED:991-1004 | REDACTED:1022-1034 | REDACTED:1037-1049 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (13–14 lines × 3) moments/TwoLocus/Util.py:227— moments/TwoLocus/Util.py:227-239 | moments/TwoLocus/Util.py:303-316 | moments/TwoLocus/Util.py:410-423 — 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 `moments/TwoLocus/Util.py:227` it begins part-way through the construct above it, so those exact lines 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 × 9) moments/LD/Matrices.py:1327— moments/LD/Matrices.py:1327-1339 | moments/LD/Matrices.py:1458-1470 | moments/LD/Matrices.py:1486-1498 | moments/LD/Matrices.py:1542-1554 | moments/LD/Matrices.py:1619-1631 | moments/LD/Matrices.py:3043-3059 | moments/LD/Matrices.py:3079-3095 | moments/LD/Matrices.py:3151-3167 | moments/LD/Matrices.py:3187-3203 — all 9 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/LD/Matrices.py:1327` it does not close everything it opens, so those exact lines 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 × 9) moments/LD/Matrices.py:1542— moments/LD/Matrices.py:1542-1554 | moments/LD/Matrices.py:1619-1631 | moments/LD/Matrices.py:2772-2788 | moments/LD/Matrices.py:2832-2848 | moments/LD/Matrices.py:2862-2878 | moments/LD/Matrices.py:3043-3059 | moments/LD/Matrices.py:3079-3095 | moments/LD/Matrices.py:3151-3167 | moments/LD/Matrices.py:3187-3203 — all 9 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/LD/Matrices.py:1542` it does not close everything it opens, so those exact lines 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 × 4) moments/LD/Matrices.py:1028— moments/LD/Matrices.py:1028-1041 | moments/LD/Matrices.py:1376-1389 | moments/LD/Matrices.py:1562-1574 | moments/LD/Matrices.py:1639-1651 — 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 `moments/LD/Matrices.py:1028` it begins part-way through the construct above it, so those exact lines 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 × 4) moments/LD/Matrices.py:1347— moments/LD/Matrices.py:1347-1359 | moments/LD/Matrices.py:1361-1373 | moments/LD/Matrices.py:2586-2603 | moments/LD/Matrices.py:2644-2661 — 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 `moments/LD/Matrices.py:1347` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12–13 lines × 2) moments/Triallele/Numerics.py:517— moments/Triallele/Numerics.py:517-529 | moments/Triallele/Numerics.py:566-577 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/Triallele/Numerics.py:517` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12–13 lines × 2) moments/LD/stats_from_genotype_counts.py:842— moments/LD/stats_from_genotype_counts.py:842-854 | moments/LD/stats_from_genotype_counts.py:1281-1292 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/LD/stats_from_genotype_counts.py:842` it begins part-way through the construct above it, so those exact lines 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) moments/LD/Matrices.py:80— moments/LD/Matrices.py:80-89 | moments/LD/Matrices.py:99-108 | moments/LD/Matrices.py:116-125 — 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) moments/LD/Matrices.py:459— moments/LD/Matrices.py:459-468 | moments/LD/Matrices.py:475-484 | moments/LD/Matrices.py:489-498 — 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–10 lines × 3) moments/LinearSystem.py:120— moments/LinearSystem.py:120-129 | moments/LinearSystem.py:194-202 | moments/LinearSystem.py:281-290 — 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–10 lines × 3) REDACTED:1008— REDACTED:1008-1016 | REDACTED:1053-1062 | REDACTED:1068-1077 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:1008` it begins part-way through the construct above it, so those 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 × 5) moments/LD/Matrices.py:750— moments/LD/Matrices.py:750-758 | moments/LD/Matrices.py:773-781 | moments/LD/Matrices.py:847-855 | moments/LD/Matrices.py:874-882 | moments/LD/Matrices.py:908-916 — 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 `moments/LD/Matrices.py:750` it begins part-way through the construct above it, so those exact lines 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 × 5) moments/LD/Matrices.py:783— moments/LD/Matrices.py:783-791 | moments/LD/Matrices.py:810-818 | moments/LD/Matrices.py:837-845 | moments/LD/Matrices.py:864-872 | moments/LD/Matrices.py:891-899 — 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 `moments/LD/Matrices.py:783` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (6–7 lines × 3) moments/LD/stats_from_genotype_counts.py:659— moments/LD/stats_from_genotype_counts.py:659-665 | moments/LD/stats_from_genotype_counts.py:1240-1245 | moments/LD/stats_from_genotype_counts.py:1405-1410 — 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 `moments/LD/stats_from_genotype_counts.py:659` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (6–7 lines × 3) moments/LD/stats_from_haplotype_counts.py:51— moments/LD/stats_from_haplotype_counts.py:51-57 | moments/LD/stats_from_haplotype_counts.py:63-69 | moments/LD/stats_from_haplotype_counts.py:75-80 — 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 `moments/LD/stats_from_haplotype_counts.py:51` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (6–7 lines × 2) moments/LD/stats_from_genotype_counts.py:680— moments/LD/stats_from_genotype_counts.py:680-686 | moments/LD/stats_from_genotype_counts.py:1377-1382 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/LD/stats_from_genotype_counts.py:680` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (6–7 lines × 2) moments/LD/stats_from_genotype_counts.py:1137— moments/LD/stats_from_genotype_counts.py:1137-1142 | moments/LD/stats_from_genotype_counts.py:1144-1150 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/LD/stats_from_genotype_counts.py:1137` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (5 lines × 5) moments/LD/stats_from_genotype_counts.py:447— moments/LD/stats_from_genotype_counts.py:447-451 | moments/LD/stats_from_genotype_counts.py:1232-1236 | moments/LD/stats_from_genotype_counts.py:1273-1277 | moments/LD/stats_from_genotype_counts.py:1329-1333 | moments/LD/stats_from_genotype_counts.py:1395-1399 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `moments/LD/stats_from_genotype_counts.py:1400` calls `sum` and `moments/LD/stats_from_genotype_counts.py:452` 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 × 5) moments/Manips.py:122— moments/Manips.py:122-126 | moments/Manips.py:180-184 | moments/Manips.py:243-247 | moments/Manips.py:307-311 | moments/Manips.py:369-373 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (3–5 lines × 3) moments/LD/Parsing.py:1096— moments/LD/Parsing.py:1096-1100 | moments/LD/Parsing.py:1104-1108 | moments/LD/Parsing.py:1111-1113 — 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 `moments/LD/Parsing.py:1096` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (3–5 lines × 3) moments/LD/stats_from_genotype_counts.py:1040— moments/LD/stats_from_genotype_counts.py:1040-1042 | moments/LD/stats_from_genotype_counts.py:1260-1264 | moments/LD/stats_from_genotype_counts.py:1426-1430 — 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 `moments/LD/stats_from_genotype_counts.py:1040` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Matrices.admix_ld (cyclomatic 216) moments/LD/Matrices.py:999— Matrices.admix_ld has cyclomatic complexity 216 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages. This file is where this pass's cyclomatic complexity CONCENTRATES: moments/LD/Matrices.py holds 4 of the 58 methods over the threshold — including the worst — and 315 of the 928 points over it (34%), 2.2× the next-largest file (moments/Demes/Demes.py at 142). No single row can show this, because each is measured only against the threshold: reducing this one file moves this dimension further than any other file in the repository.
Matrices.migration_ld (cyclomatic 103) moments/LD/Matrices.py:415— Matrices.migration_ld has cyclomatic complexity 103 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This file is where this pass's cyclomatic complexity CONCENTRATES: moments/LD/Matrices.py holds 4 of the 58 methods over the threshold — including the worst — and 315 of the 928 points over it (34%), 2.2× the next-largest file (moments/Demes/Demes.py at 142). No single row can show this, because each is measured only against the threshold: reducing this one file moves this dimension further than any other file in the repository.
Demes.SFS (cyclomatic 82) moments/Demes/Demes.py:17— Demes.SFS has cyclomatic complexity 82 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Parsing._tally_vcf (cyclomatic 72) moments/Parsing.py:307— Parsing._tally_vcf has cyclomatic complexity 72 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Parsing._count_types_sparse (cyclomatic 43) moments/LD/Parsing.py:568— Parsing._count_types_sparse has cyclomatic complexity 43 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Demes._get_deme_sample_sizes (cyclomatic 40) moments/Demes/Demes.py:1033— Demes._get_deme_sample_sizes has cyclomatic complexity 40 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Matrices.drift_ld (cyclomatic 40) moments/LD/Matrices.py:35— Matrices.drift_ld has cyclomatic complexity 40 (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 file is where this pass's cyclomatic complexity CONCENTRATES: moments/LD/Matrices.py holds 4 of the 58 methods over the threshold — including the worst — and 315 of the 928 points over it (34%), 2.2× the next-largest file (moments/Demes/Demes.py at 142). No single row can show this, because each is measured only against the threshold: reducing this one file moves this dimension further than any other file in the repository.
Jackknife.closest_ijk_edges (cyclomatic 39) REDACTED:267— Jackknife.closest_ijk_edges has cyclomatic complexity 39 (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.
Integration.integrate_nD (cyclomatic 37) REDACTED:889— Integration.integrate_nD has cyclomatic complexity 37 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Misc.make_data_dict_vcf (cyclomatic 37) moments/Misc.py:409— Misc.make_data_dict_vcf has cyclomatic complexity 37 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Plotting.plot_ld_curves_comp (cyclomatic 35) moments/LD/Plotting.py:140— Plotting.plot_ld_curves_comp has cyclomatic complexity 35 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ModelPlot.plot_model (cyclomatic 35) moments/ModelPlot.py:85— ModelPlot.plot_model has cyclomatic complexity 35 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Jackknife.calc_jk (cyclomatic 34) REDACTED:892— Jackknife.calc_jk 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.
Demes.LD (cyclomatic 31) moments/Demes/Demes.py:387— Demes.LD has cyclomatic complexity 31 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Integration.integrate (cyclomatic 31) moments/TwoLocus/Integration.py:45— Integration.integrate has cyclomatic complexity 31 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Parsing._check_ld_statistics_args (cyclomatic 28) moments/LD/Parsing.py:1251— Parsing._check_ld_statistics_args has cyclomatic complexity 28 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Demes.LDdecay (cyclomatic 27) moments/Demes/Demes.py:543— Demes.LDdecay has cyclomatic complexity 27 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
LDstats.integrate (cyclomatic 27) REDACTED:953— LDstats.integrate has cyclomatic complexity 27 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
Misc.bootstrap (cyclomatic 27) moments/Misc.py:672— Misc.bootstrap has cyclomatic complexity 27 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Jackknife.closest_ijk (cyclomatic 27) REDACTED:51— Jackknife.closest_ijk has cyclomatic complexity 27 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Demes._get_demographic_events (cyclomatic 26) moments/Demes/Demes.py:747— Demes._get_demographic_events has cyclomatic complexity 26 (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.
Demes._compute_sfs (cyclomatic 26) moments/Demes/Demes.py:1175— Demes._compute_sfs has cyclomatic complexity 26 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Integration_nomig.integrate_nomig (cyclomatic 26) REDACTED:402— Integration_nomig.integrate_nomig has cyclomatic complexity 26 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Numerics.integrate (cyclomatic 26) moments/LD/Numerics.py:192— Numerics.integrate has cyclomatic complexity 26 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Jackknife.closest_ijk_sides (cyclomatic 25) REDACTED:141— Jackknife.closest_ijk_sides has cyclomatic complexity 25 (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.
Inference._set_value (cyclomatic 24) moments/Demes/Inference.py:187— Inference._set_value has cyclomatic complexity 24 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Numerics.steady_state (cyclomatic 24) moments/LD/Numerics.py:380— Numerics.steady_state has cyclomatic complexity 24 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
stats_from_genotype_counts.pi2 (cyclomatic 24) moments/LD/stats_from_genotype_counts.py:468— stats_from_genotype_counts.pi2 has cyclomatic complexity 24 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
Spectrum.integrate (cyclomatic 24) REDACTED:710— Spectrum.integrate has cyclomatic complexity 24 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
Spectrum.f4 (cyclomatic 24) REDACTED:1251— Spectrum.f4 has cyclomatic complexity 24 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Numerics.drift (cyclomatic 24) moments/TwoLocus/Numerics.py:68— Numerics.drift has cyclomatic complexity 24 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Inference._get_value (cyclomatic 23) moments/Demes/Inference.py:114— Inference._get_value has cyclomatic complexity 23 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Inference._object_func (cyclomatic 23) moments/LD/Inference.py:421— Inference._object_func has cyclomatic complexity 23 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
stats_from_haplotype_counts.pi2 (cyclomatic 23) moments/LD/stats_from_haplotype_counts.py:105— stats_from_haplotype_counts.pi2 has cyclomatic complexity 23 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
Plotting.plot_3d_spectrum (cyclomatic 23) moments/Plotting.py:810— Plotting.plot_3d_spectrum has cyclomatic complexity 23 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Inference.optimize (cyclomatic 21) moments/Demes/Inference.py:560— Inference.optimize has cyclomatic complexity 21 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
Plotting.plot_4d_comp_Poisson (cyclomatic 21) moments/Plotting.py:1004— Plotting.plot_4d_comp_Poisson has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Integration.integrate_cn (cyclomatic 21) moments/Triallele/Integration.py:29— Integration.integrate_cn has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Integration_nomig.integrate_neutral (cyclomatic 20) REDACTED:644— Integration_nomig.integrate_neutral has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Parsing.get_genotypes (cyclomatic 20) moments/LD/Parsing.py:96— Parsing.get_genotypes has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Util.rescale_params (cyclomatic 20) moments/LD/Util.py:149— Util.rescale_params has cyclomatic complexity 20 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
Parsing._parse_filters (cyclomatic 20) moments/Parsing.py:657— Parsing._parse_filters has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Plotting.plot_3d_comp_Poisson (cyclomatic 20) moments/Plotting.py:641— Plotting.plot_3d_comp_Poisson has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Spectrum.__new__ (cyclomatic 20) REDACTED:116— Spectrum.__new__ has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Parsing._call_sgc (cyclomatic 19) moments/LD/Parsing.py:809— Parsing._call_sgc 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.
Spectrum.f3 (cyclomatic 19) REDACTED:1179— Spectrum.f3 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.
Inference.optimize_LD (cyclomatic 18) moments/Demes/Inference.py:1170— Inference.optimize_LD has cyclomatic complexity 18 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
LDstats.to_file (cyclomatic 18) REDACTED:671— LDstats.to_file has cyclomatic complexity 18 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
Parsing.subset_data (cyclomatic 17) moments/LD/Parsing.py:1647— Parsing.subset_data has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Util._compute_D (cyclomatic 17) moments/TwoLocus/Util.py:163— Util._compute_D has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This shape REPEATS in the file: 3 other methods here (Util._compute_D2, Util._compute_Dz, Util._compute_pi2) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 4 times rather than 4 independent problems. Splitting this body alone leaves the other 3 exactly as they are. Where these are variations on one operation, the change that clears all 4 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.
Util._compute_D2 (cyclomatic 17) moments/TwoLocus/Util.py:197— Util._compute_D2 has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This shape REPEATS in the file: 3 other methods here (Util._compute_D, Util._compute_Dz, Util._compute_pi2) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 4 times rather than 4 independent problems. Splitting this body alone leaves the other 3 exactly as they are. Where these are variations on one operation, the change that clears all 4 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.
Util._compute_Dz (cyclomatic 17) moments/TwoLocus/Util.py:254— Util._compute_Dz has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This shape REPEATS in the file: 3 other methods here (Util._compute_D, Util._compute_D2, Util._compute_pi2) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 4 times rather than 4 independent problems. Splitting this body alone leaves the other 3 exactly as they are. Where these are variations on one operation, the change that clears all 4 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.
Util._compute_pi2 (cyclomatic 17) moments/TwoLocus/Util.py:353— Util._compute_pi2 has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This shape REPEATS in the file: 3 other methods here (Util._compute_D, Util._compute_D2, Util._compute_Dz) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 4 times rather than 4 independent problems. Splitting this body alone leaves the other 3 exactly as they are. Where these are variations on one operation, the change that clears all 4 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.
Matrices.mutation_ld (cyclomatic 16) moments/LD/Matrices.py:258— Matrices.mutation_ld has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This file is where this pass's cyclomatic complexity CONCENTRATES: moments/LD/Matrices.py holds 4 of the 58 methods over the threshold — including the worst — and 315 of the 928 points over it (34%), 2.2× the next-largest file (moments/Demes/Demes.py at 142). No single row can show this, because each is measured only against the threshold: reducing this one file moves this dimension further than any other file in the repository.
Plotting.plot_ld_curves (cyclomatic 16) moments/LD/Plotting.py:21— Plotting.plot_ld_curves 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.
Plotting.plot_2d_comp_Poisson (cyclomatic 16) moments/Plotting.py:446— Plotting.plot_2d_comp_Poisson has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
TriSpectrum.fold_ancestral (cyclomatic 16) REDACTED:347— TriSpectrum.fold_ancestral 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.
Numerics.drift_reversible (cyclomatic 16) moments/TwoLocus/Numerics.py:960— Numerics.drift_reversible 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.
Matrices.migration_ld (cognitive 358) moments/LD/Matrices.py:415— Matrices.migration_ld has cognitive complexity 358 (threshold 15). Drivers by points: if/else 59 (264 pts), loops 25 (92 pts), boolean chains 2 (nesting depth added 272). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Parsing._tally_vcf (cognitive 158) moments/Parsing.py:307— Parsing._tally_vcf has cognitive complexity 158 (threshold 15). Drivers by points: if/else 57 (130 pts), loops 8 (20 pts), boolean chains 8 (nesting depth added 85). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Demes.SFS (cognitive 152) moments/Demes/Demes.py:17— Demes.SFS has cognitive complexity 152 (threshold 15). Drivers by points: if/else 65 (113 pts), loops 13 (27 pts), boolean chains 12 (nesting depth added 62). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Matrices.admix_ld (cognitive 134) moments/LD/Matrices.py:999— Matrices.admix_ld has cognitive complexity 134 (threshold 15). Drivers by points: boolean chains 82, if/else 19 (51 pts), loops 1 (nesting depth added 32). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
Demes._get_deme_sample_sizes (cognitive 123) moments/Demes/Demes.py:1033— Demes._get_deme_sample_sizes has cognitive complexity 123 (threshold 15). Drivers by points: if/else 13 (65 pts), loops 15 (52 pts), boolean chains 6 (nesting depth added 89). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Jackknife.calc_jk (cognitive 116) REDACTED:892— Jackknife.calc_jk has cognitive complexity 116 (threshold 15). Drivers by points: loops 28 (108 pts), if/else 4 (5 pts), ternaries 1 (2 pts), error handling 1 (nesting depth added 82). 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.
Parsing._count_types_sparse (cognitive 99) moments/LD/Parsing.py:568— Parsing._count_types_sparse has cognitive complexity 99 (threshold 15). Drivers by points: if/else 31 (53 pts), loops 18 (44 pts), error handling 1 (2 pts) (nesting depth added 49). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Inference._set_value (cognitive 88) moments/Demes/Inference.py:187— Inference._set_value has cognitive complexity 88 (threshold 15). Drivers by points: if/else 13 (48 pts), loops 7 (27 pts), error handling 2 (13 pts) (nesting depth added 66). 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.
Numerics.drift (cognitive 84) moments/TwoLocus/Numerics.py:68— Numerics.drift has cognitive complexity 84 (threshold 15). Drivers by points: if/else 16 (75 pts), loops 3 (6 pts), boolean chains 3 (nesting depth added 62). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Misc.make_data_dict_vcf (cognitive 81) moments/Misc.py:409— Misc.make_data_dict_vcf has cognitive complexity 81 (threshold 15). Drivers by points: if/else 24 (63 pts), loops 4 (7 pts), boolean chains 6, ternaries 1 (3 pts), error handling 1 (2 pts) (nesting depth added 45). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Integration.integrate_nD (cognitive 80) REDACTED:889— Integration.integrate_nD has cognitive complexity 80 (threshold 15). Drivers by points: if/else 39 (61 pts), loops 5 (17 pts), boolean chains 2 (nesting depth added 34). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Inference._get_value (cognitive 76) moments/Demes/Inference.py:114— Inference._get_value has cognitive complexity 76 (threshold 15). Drivers by points: if/else 13 (36 pts), loops 7 (27 pts), error handling 2 (13 pts) (nesting depth added 54). 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.
ModelPlot.plot_model (cognitive 73) moments/ModelPlot.py:85— ModelPlot.plot_model has cognitive complexity 73 (threshold 15). Drivers by points: if/else 26 (42 pts), ternaries 5 (15 pts), loops 6 (13 pts), boolean chains 3 (nesting depth added 33). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Numerics.integrate (cognitive 65) moments/LD/Numerics.py:192— Numerics.integrate has cognitive complexity 65 (threshold 15). Drivers by points: if/else 30 (61 pts), boolean chains 3, loops 1 (nesting depth added 31). 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.
Parsing._parse_filters (cognitive 65) moments/Parsing.py:657— Parsing._parse_filters has cognitive complexity 65 (threshold 15). Drivers by points: if/else 17 (53 pts), loops 3 (9 pts), error handling 1 (3 pts) (nesting depth added 44). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Misc.bootstrap (cognitive 62) moments/Misc.py:672— Misc.bootstrap has cognitive complexity 62 (threshold 15). Drivers by points: if/else 14 (33 pts), loops 9 (22 pts), ternaries 2 (5 pts), boolean chains 2 (nesting depth added 35). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Matrices.drift_ld (cognitive 61) moments/LD/Matrices.py:35— Matrices.drift_ld has cognitive complexity 61 (threshold 15). Drivers by points: loops 11 (39 pts), if/else 10 (20 pts), boolean chains 2 (nesting depth added 38). 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.
Demes._compute_sfs (cognitive 58) moments/Demes/Demes.py:1175— Demes._compute_sfs has cognitive complexity 58 (threshold 15). Drivers by points: if/else 21 (34 pts), loops 5 (15 pts), ternaries 2 (8 pts), boolean chains 1 (nesting depth added 29). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Integration.integrate (cognitive 58) moments/TwoLocus/Integration.py:45— Integration.integrate has cognitive complexity 58 (threshold 15). Drivers by points: if/else 32 (55 pts), boolean chains 2, loops 1 (nesting depth added 23). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Integration_nomig.integrate_nomig (cognitive 56) REDACTED:402— Integration_nomig.integrate_nomig has cognitive complexity 56 (threshold 15). Drivers by points: if/else 28 (47 pts), loops 3 (8 pts), boolean chains 1 (nesting depth added 24). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Plotting.plot_ld_curves_comp (cognitive 55) moments/LD/Plotting.py:140— Plotting.plot_ld_curves_comp has cognitive complexity 55 (threshold 15). Drivers by points: if/else 23 (36 pts), loops 7 (14 pts), boolean chains 4, ternaries 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.
Plotting.plot_3d_spectrum (cognitive 54) moments/Plotting.py:810— Plotting.plot_3d_spectrum has cognitive complexity 54 (threshold 15). Drivers by points: if/else 20 (42 pts), boolean chains 6, loops 3 (6 pts) (nesting depth added 25). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Numerics.drift_reversible (cognitive 54) moments/TwoLocus/Numerics.py:960— Numerics.drift_reversible has cognitive complexity 54 (threshold 15). Drivers by points: if/else 12 (48 pts), loops 3 (6 pts) (nesting depth added 39). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
LinearSystem.calcM_jk3 (cognitive 52) moments/LinearSystem.py:264— LinearSystem.calcM_jk3 has cognitive complexity 52 (threshold 15). Drivers by points: if/else 10 (45 pts), loops 4 (7 pts) (nesting depth added 38). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Integration_nomig.integrate_neutral (cognitive 48) REDACTED:644— Integration_nomig.integrate_neutral has cognitive complexity 48 (threshold 15). Drivers by points: if/else 20 (36 pts), loops 4 (11 pts), boolean chains 1 (nesting depth added 23). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Util._compute_D (cognitive 48) moments/TwoLocus/Util.py:163— Util._compute_D has cognitive complexity 48 (threshold 15). Drivers by points: if/else 10 (32 pts), loops 4 (11 pts), boolean chains 5 (nesting depth added 29). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: 3 other methods here (Util._compute_D2, Util._compute_Dz, Util._compute_pi2) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 4 times rather than 4 independent problems. Splitting this body alone leaves the other 3 exactly as they are. Where these are variations on one operation, the change that clears all 4 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.
Util._compute_D2 (cognitive 48) moments/TwoLocus/Util.py:197— Util._compute_D2 has cognitive complexity 48 (threshold 15). Drivers by points: if/else 10 (32 pts), loops 4 (11 pts), boolean chains 5 (nesting depth added 29). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: 3 other methods here (Util._compute_D, Util._compute_Dz, Util._compute_pi2) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 4 times rather than 4 independent problems. Splitting this body alone leaves the other 3 exactly as they are. Where these are variations on one operation, the change that clears all 4 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.
Util._compute_Dz (cognitive 48) moments/TwoLocus/Util.py:254— Util._compute_Dz has cognitive complexity 48 (threshold 15). Drivers by points: if/else 10 (32 pts), loops 4 (11 pts), boolean chains 5 (nesting depth added 29). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: 3 other methods here (Util._compute_D, Util._compute_D2, Util._compute_pi2) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 4 times rather than 4 independent problems. Splitting this body alone leaves the other 3 exactly as they are. Where these are variations on one operation, the change that clears all 4 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.
Util._compute_pi2 (cognitive 48) moments/TwoLocus/Util.py:353— Util._compute_pi2 has cognitive complexity 48 (threshold 15). Drivers by points: if/else 10 (32 pts), loops 4 (11 pts), boolean chains 5 (nesting depth added 29). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: 3 other methods here (Util._compute_D, Util._compute_D2, Util._compute_Dz) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 4 times rather than 4 independent problems. Splitting this body alone leaves the other 3 exactly as they are. Where these are variations on one operation, the change that clears all 4 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.
Integration.integrate_cn (cognitive 46) moments/Triallele/Integration.py:29— Integration.integrate_cn has cognitive complexity 46 (threshold 15). Drivers by points: if/else 18 (38 pts), boolean chains 4, loops 2 (4 pts) (nesting depth added 22). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Demes.LD (cognitive 44) moments/Demes/Demes.py:387— Demes.LD has cognitive complexity 44 (threshold 15). Drivers by points: if/else 22 (35 pts), boolean chains 5, loops 4 (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.
Jackknife.closest_ijk_edges (cognitive 41) REDACTED:267— Jackknife.closest_ijk_edges has cognitive complexity 41 (threshold 15). Drivers by points: loops 12 (24 pts), boolean chains 14, if/else 3 (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.
Matrices.mutation_ld (cognitive 40) moments/LD/Matrices.py:258— Matrices.mutation_ld has cognitive complexity 40 (threshold 15). Drivers by points: if/else 13 (29 pts), loops 4 (10 pts), boolean chains 1 (nesting depth added 22). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Parsing._check_ld_statistics_args (cognitive 40) moments/LD/Parsing.py:1251— Parsing._check_ld_statistics_args has cognitive complexity 40 (threshold 15). Drivers by points: if/else 18 (29 pts), boolean chains 6, loops 2 (3 pts), ternaries 1 (2 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Jackknife.closest_ijk (cognitive 40) REDACTED:51— Jackknife.closest_ijk has cognitive complexity 40 (threshold 15). Drivers by points: if/else 8 (18 pts), boolean chains 12, loops 6 (10 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.
Inference._object_func (cognitive 39) moments/LD/Inference.py:421— Inference._object_func has cognitive complexity 39 (threshold 15). Drivers by points: if/else 22 (32 pts), loops 2 (4 pts), boolean chains 3 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Matrices.migration_h (cognitive 39) moments/LD/Matrices.py:367— Matrices.migration_h has cognitive complexity 39 (threshold 15). Drivers by points: if/else 10 (22 pts), loops 7 (17 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.
Jackknife.closest_ijk_sides (cognitive 38) REDACTED:141— Jackknife.closest_ijk_sides has cognitive complexity 38 (threshold 15). Drivers by points: loops 12 (28 pts), if/else 6, boolean chains 4 (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.
Parsing._call_sgc (cognitive 37) moments/LD/Parsing.py:809— Parsing._call_sgc has cognitive complexity 37 (threshold 15). Drivers by points: if/else 21 (37 pts) (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Demes._get_demographic_events (cognitive 35) moments/Demes/Demes.py:747— Demes._get_demographic_events has cognitive complexity 35 (threshold 15). Drivers by points: loops 16 (22 pts), if/else 6 (10 pts), boolean chains 3 (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.
Inference._get_value_locations (cognitive 35) moments/Demes/Inference.py:56— Inference._get_value_locations has cognitive complexity 35 (threshold 15). Drivers by points: loops 7 (21 pts), if/else 6 (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.
Plotting.plot_4d_comp_Poisson (cognitive 35) moments/Plotting.py:1004— Plotting.plot_4d_comp_Poisson has cognitive complexity 35 (threshold 15). Drivers by points: if/else 19 (28 pts), loops 3 (6 pts), boolean chains 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Numerics.drift (cognitive 33) moments/Triallele/Numerics.py:57— Numerics.drift has cognitive complexity 33 (threshold 15). Drivers by points: if/else 7 (26 pts), boolean chains 4, loops 2 (3 pts) (nesting depth added 20). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Parsing.subset_data (cognitive 31) moments/LD/Parsing.py:1647— Parsing.subset_data has cognitive complexity 31 (threshold 15). Drivers by points: if/else 13 (26 pts), loops 4 (5 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.
Util.ld_names (cognitive 31) moments/LD/Util.py:21— Util.ld_names has cognitive complexity 31 (threshold 15). Drivers by points: loops 9 (19 pts), if/else 2 (10 pts), boolean chains 2 (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.
Spectrum.integrate (cognitive 31) REDACTED:710— Spectrum.integrate has cognitive complexity 31 (threshold 15). Drivers by points: if/else 18 (23 pts), boolean chains 8 (nesting depth added 5). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
Util._compute_S (cognitive 31) moments/TwoLocus/Util.py:144— Util._compute_S has cognitive complexity 31 (threshold 15). Drivers by points: if/else 6 (16 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.
DemesUtil.slice (cognitive 30) moments/Demes/DemesUtil.py:6— DemesUtil.slice has cognitive complexity 30 (threshold 15). Drivers by points: if/else 11 (22 pts), loops 3 (8 pts) (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Numerics.steady_state (cognitive 30) moments/LD/Numerics.py:380— Numerics.steady_state has cognitive complexity 30 (threshold 15). Drivers by points: if/else 14 (20 pts), loops 3 (6 pts), boolean chains 4 (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.
Plotting.plot_3d_comp_Poisson (cognitive 30) moments/Plotting.py:641— Plotting.plot_3d_comp_Poisson has cognitive complexity 30 (threshold 15). Drivers by points: if/else 19 (26 pts), loops 2 (3 pts), boolean chains 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Demes.LDdecay (cognitive 28) moments/Demes/Demes.py:543— Demes.LDdecay has cognitive complexity 28 (threshold 15). Drivers by points: if/else 15 (20 pts), boolean chains 4, loops 2 (4 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
LDstats.integrate (cognitive 28) REDACTED:953— LDstats.integrate has cognitive complexity 28 (threshold 15). Drivers by points: if/else 16 (21 pts), boolean chains 7 (nesting depth added 5). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
Matrices.mutation_h (cognitive 28) moments/LD/Matrices.py:234— Matrices.mutation_h has cognitive complexity 28 (threshold 15). Drivers by points: if/else 8 (19 pts), loops 3 (8 pts), boolean chains 1 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Inference.uncerts_LD (cognitive 27) moments/Demes/Inference.py:1446— Inference.uncerts_LD has cognitive complexity 27 (threshold 15). Drivers by points: if/else 11 (20 pts), loops 2 (7 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.
Parsing.get_genotypes (cognitive 27) moments/LD/Parsing.py:96— Parsing.get_genotypes has cognitive complexity 27 (threshold 15). Drivers by points: if/else 13 (19 pts), ternaries 2 (3 pts), error handling 2, loops 1 (2 pts), boolean chains 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
_ModelInfo.determine_framesizes (cognitive 27) moments/ModelPlot.py:641— _ModelInfo.determine_framesizes has cognitive complexity 27 (threshold 15). Drivers by points: if/else 6 (17 pts), loops 4 (10 pts) (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Spectrum.f3 (cognitive 27) REDACTED:1179— Spectrum.f3 has cognitive complexity 27 (threshold 15). Drivers by points: if/else 11 (18 pts), boolean chains 5, loops 2 (4 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Numerics.recombination (cognitive 27) moments/TwoLocus/Numerics.py:311— Numerics.recombination has cognitive complexity 27 (threshold 15). Drivers by points: if/else 5 (20 pts), loops 3 (6 pts), boolean chains 1 (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Numerics.selection_two_locus (cognitive 27) moments/TwoLocus/Numerics.py:375— Numerics.selection_two_locus has cognitive complexity 27 (threshold 15). Drivers by points: if/else 5 (20 pts), loops 3 (6 pts), boolean chains 1 (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: one other method here (Numerics.selection_general) 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.
Numerics.selection_general (cognitive 27) moments/TwoLocus/Numerics.py:459— Numerics.selection_general has cognitive complexity 27 (threshold 15). Drivers by points: if/else 5 (20 pts), loops 3 (6 pts), boolean chains 1 (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: one other method here (Numerics.selection_two_locus) 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.
Matrices.recombination (cognitive 26) moments/LD/Matrices.py:322— Matrices.recombination has cognitive complexity 26 (threshold 15). Drivers by points: if/else 9 (17 pts), loops 3 (8 pts), boolean chains 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Parsing._get_ld_stat_sums (cognitive 26) moments/LD/Parsing.py:985— Parsing._get_ld_stat_sums has cognitive complexity 26 (threshold 15). Drivers by points: loops 7 (17 pts), if/else 4 (9 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.
Spectrum.__new__ (cognitive 26) REDACTED:116— Spectrum.__new__ has cognitive complexity 26 (threshold 15). Drivers by points: if/else 14 (21 pts), boolean chains 5 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Spectrum.f4 (cognitive 26) REDACTED:1251— Spectrum.f4 has cognitive complexity 26 (threshold 15). Drivers by points: if/else 9 (15 pts), boolean chains 6, loops 3 (5 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Demes._apply_event (cognitive 25) moments/Demes/Demes.py:1331— Demes._apply_event has cognitive complexity 25 (threshold 15). Drivers by points: if/else 8 (18 pts), loops 3 (7 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.
Integration._apply_frozen_pops (cognitive 25) REDACTED:845— Integration._apply_frozen_pops has cognitive complexity 25 (threshold 15). Drivers by points: if/else 10 (18 pts), loops 2 (7 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
LDstats.to_file (cognitive 25) REDACTED:671— LDstats.to_file has cognitive complexity 25 (threshold 15). Drivers by points: if/else 12 (13 pts), loops 8 (12 pts) (nesting depth added 5). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
Inference._perturb_params_constrained (cognitive 24) moments/Demes/Inference.py:336— Inference._perturb_params_constrained has cognitive complexity 24 (threshold 15). Drivers by points: if/else 5 (14 pts), loops 3 (8 pts), boolean chains 2 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Inference.optimize (cognitive 24) moments/Demes/Inference.py:560— Inference.optimize has cognitive complexity 24 (threshold 15). Drivers by points: if/else 18 (22 pts), boolean chains 2 (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
Plotting.plot_ld_curves (cognitive 24) moments/LD/Plotting.py:21— Plotting.plot_ld_curves has cognitive complexity 24 (threshold 15). Drivers by points: if/else 11 (17 pts), loops 3 (5 pts), boolean chains 2 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Misc.make_fux_table (cognitive 23) moments/Misc.py:152— Misc.make_fux_table has cognitive complexity 23 (threshold 15). Drivers by points: loops 6 (16 pts), if/else 3 (7 pts) (nesting depth added 14). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
Demes._get_integration_parameters (cognitive 22) moments/Demes/Demes.py:853— Demes._get_integration_parameters has cognitive complexity 22 (threshold 15). Drivers by points: if/else 4 (12 pts), loops 4 (8 pts), ternaries 1 (2 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Demes._compute_LD (cognitive 22) moments/Demes/Demes.py:1545— Demes._compute_LD has cognitive complexity 22 (threshold 15). Drivers by points: if/else 6 (13 pts), loops 3 (6 pts), ternaries 1 (3 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Numerics.project (cognitive 22) moments/Triallele/Numerics.py:275— Numerics.project has cognitive complexity 22 (threshold 15). Drivers by points: if/else 4 (10 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.
TriSpectrum.fold_ancestral (cognitive 22) REDACTED:347— TriSpectrum.fold_ancestral has cognitive complexity 22 (threshold 15). Drivers by points: if/else 6 (13 pts), loops 4 (6 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.
Numerics.mutations_reversible (cognitive 22) moments/TwoLocus/Numerics.py:886— Numerics.mutations_reversible has cognitive complexity 22 (threshold 15). Drivers by points: if/else 4 (16 pts), loops 3 (6 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 (Numerics.recombination_reversible) 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.
Numerics.recombination_reversible (cognitive 22) moments/TwoLocus/Numerics.py:1088— Numerics.recombination_reversible has cognitive complexity 22 (threshold 15). Drivers by points: if/else 4 (16 pts), loops 3 (6 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 (Numerics.mutations_reversible) 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.
Demes._augment_with_ancient_samples (cognitive 21) moments/Demes/Demes.py:683— Demes._augment_with_ancient_samples has cognitive complexity 21 (threshold 15). Drivers by points: if/else 6 (13 pts), loops 4 (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.
DemesUtil.swipe (cognitive 21) moments/Demes/DemesUtil.py:97— DemesUtil.swipe has cognitive complexity 21 (threshold 15). Drivers by points: if/else 11 (16 pts), loops 3 (5 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Plotting.plot_2d_comp_Poisson (cognitive 21) moments/Plotting.py:446— Plotting.plot_2d_comp_Poisson has cognitive complexity 21 (threshold 15). Drivers by points: if/else 17 (20 pts), boolean chains 1 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
Reversible._calc_FB_5pop (cognitive 21) moments/Reversible.py:161— Reversible._calc_FB_5pop has cognitive complexity 21 (threshold 15). Drivers by points: if/else 10 (20 pts), loops 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Numerics.project (cognitive 21) moments/TwoLocus/Numerics.py:836— Numerics.project has cognitive complexity 21 (threshold 15). Drivers by points: loops 5 (13 pts), if/else 4 (8 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.
Inference._object_func (cognitive 20) moments/Inference.py:26— Inference._object_func has cognitive complexity 20 (threshold 15). Drivers by points: if/else 9 (13 pts), loops 2 (4 pts), boolean chains 3 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
LDstats.swap_pops (cognitive 20) REDACTED:384— LDstats.swap_pops has cognitive complexity 20 (threshold 15). Drivers by points: if/else 10 (12 pts), loops 3 (7 pts), boolean chains 1 (nesting depth added 6). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
Plotting.plot_single_2d_sfs (cognitive 20) moments/Plotting.py:201— Plotting.plot_single_2d_sfs has cognitive complexity 20 (threshold 15). Drivers by points: if/else 14 (17 pts), error handling 1 (2 pts), loops 1 (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
Demes._migration_rate_in_interval (cognitive 19) moments/Demes/Demes.py:987— Demes._migration_rate_in_interval has cognitive complexity 19 (threshold 15). Drivers by points: if/else 4 (12 pts), boolean chains 4, error handling 1 (2 pts), loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Util.rescale_params (cognitive 19) moments/LD/Util.py:149— Util.rescale_params has cognitive complexity 19 (threshold 15). Drivers by points: if/else 11 (14 pts), loops 2 (3 pts), boolean chains 2 (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
Parsing._check_anc (cognitive 19) moments/Parsing.py:732— Parsing._check_anc has cognitive complexity 19 (threshold 15). Drivers by points: if/else 9 (19 pts) (nesting depth added 10). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
Spectrum.f2 (cognitive 19) REDACTED:1125— Spectrum.f2 has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (12 pts), loops 2 (4 pts), boolean chains 3 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Spectrum.from_data_dict (cognitive 19) REDACTED:1672— Spectrum.from_data_dict has cognitive complexity 19 (threshold 15). Drivers by points: if/else 8 (13 pts), loops 3 (5 pts), boolean chains 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Inference._object_func (cognitive 19) moments/TwoLocus/Inference.py:129— Inference._object_func has cognitive complexity 19 (threshold 15). Drivers by points: if/else 8 (12 pts), loops 2 (4 pts), boolean chains 3 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Inference.optimize_LD (cognitive 18) moments/Demes/Inference.py:1170— Inference.optimize_LD has cognitive complexity 18 (threshold 15). Drivers by points: if/else 14 (16 pts), boolean chains 2 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
Integration._make_array_sel_dom (cognitive 18) REDACTED:772— Integration._make_array_sel_dom has cognitive complexity 18 (threshold 15). Drivers by points: if/else 15 (18 pts) (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
Parsing._get_H_statistics (cognitive 18) moments/LD/Parsing.py:1033— Parsing._get_H_statistics has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (11 pts), loops 4 (6 pts), boolean chains 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Manips.admix_inplace (cognitive 18) moments/Manips.py:769— Manips.admix_inplace has cognitive complexity 18 (threshold 15). Drivers by points: if/else 14 (16 pts), loops 2 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
Parsing._spectrum_from_tally (cognitive 18) moments/Parsing.py:955— Parsing._spectrum_from_tally has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (14 pts), loops 2 (4 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Spectrum.marginalize (cognitive 18) REDACTED:372— Spectrum.marginalize has cognitive complexity 18 (threshold 15). Drivers by points: if/else 12 (14 pts), loops 2 (3 pts), boolean chains 1 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
Numerics.cached_projection (cognitive 18) moments/TwoLocus/Numerics.py:785— Numerics.cached_projection has cognitive complexity 18 (threshold 15). Drivers by points: loops 3 (9 pts), if/else 2 (7 pts), boolean chains 1, error handling 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.
stats_from_genotype_counts.pi2 (cognitive 17) moments/LD/stats_from_genotype_counts.py:468— stats_from_genotype_counts.pi2 has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (10 pts), boolean chains 7 (nesting depth added 3). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Plotting.plot_2d_resid (cognitive 17) moments/Plotting.py:307— Plotting.plot_2d_resid has cognitive complexity 17 (threshold 15). Drivers by points: if/else 11 (14 pts), error handling 1 (2 pts), loops 1 (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
Reversible._calc_FB_4pop (cognitive 17) moments/Reversible.py:94— Reversible._calc_FB_4pop has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (16 pts), loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Spectrum.from_file (cognitive 17) REDACTED:1466— Spectrum.from_file has cognitive complexity 17 (threshold 15). Drivers by points: if/else 11 (13 pts), loops 2 (3 pts), boolean chains 1 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
TLSpectrum.fold (cognitive 17) REDACTED:420— TLSpectrum.fold has cognitive complexity 17 (threshold 15). Drivers by points: if/else 4 (10 pts), loops 3 (6 pts), boolean chains 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Inference.uncerts (cognitive 16) moments/Demes/Inference.py:831— Inference.uncerts has cognitive complexity 16 (threshold 15). Drivers by points: if/else 13 (16 pts) (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
Inference.optimize_log_lbfgsb (cognitive 16) moments/LD/Inference.py:958— Inference.optimize_log_lbfgsb has cognitive complexity 16 (threshold 15). Drivers by points: if/else 12 (14 pts), error handling 1 (2 pts) (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
LDstats.f3 (cognitive 16) REDACTED:188— LDstats.f3 has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (11 pts), boolean chains 3, loops 1 (2 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: one other method here (LDstats.f4) 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.
LDstats.f4 (cognitive 16) REDACTED:234— LDstats.f4 has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (11 pts), boolean chains 3, loops 1 (2 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: one other method here (LDstats.f3) 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.
Spectrum.genotype_matrix (cognitive 16) REDACTED:1397— Spectrum.genotype_matrix has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (8 pts), loops 4 (8 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
TooManyMethods: Spectrum REDACTED:73— TooManyMethods — 49 methods. The bar is 30 methods; this is 19 over it, 1.63× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
D4 · Code Duplication· Near-duplicate member family (3 members, 38 shared lines) · ×1
Near-duplicate member family (3 members, 38 shared lines) REDACTED:905— REDACTED:905-1196 | REDACTED:417-641 | REDACTED:656-810 — These 3 members are variants of one another: a block of 38 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 3 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 3 times.
Near-duplicate member pair (120 shared lines) moments/Plotting.py:654— moments/Plotting.py:654-807 | moments/Plotting.py:1017-1184 — These two members are variants of one another: 120 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Near-duplicate member pair (104 shared lines) REDACTED:414— REDACTED:414-541 | REDACTED:545-799 — These two members are variants of one another: 104 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Near-duplicate member pair (52 shared lines) moments/Godambe.py:14— moments/Godambe.py:14-85 | moments/LD/Godambe.py:50-126 — These two members are variants of one another: 52 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Near-duplicate member pair (49 shared lines) moments/LinearSystem.py:108— moments/LinearSystem.py:108-175 | moments/LinearSystem.py:182-258 — These two members are variants of one another: 49 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication· Edited copy of a member (44 corresponding lines) · ×1
Edited copy of a member (44 corresponding lines) REDACTED:189— REDACTED:189-232 | REDACTED:235-280 — These two members are one piece of code written twice and then edited apart: 44 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Members sharing a duplicated core (6 members, 50+ identical tokens) · ×1
Members sharing a duplicated core (6 members, 50+ identical tokens) moments/TwoLocus/Numerics.py:69— moments/TwoLocus/Numerics.py:69-240 | moments/TwoLocus/Numerics.py:312-372 | moments/TwoLocus/Numerics.py:376-456 | moments/TwoLocus/Numerics.py:460-774 | moments/TwoLocus/Numerics.py:961-1085 | moments/TwoLocus/Numerics.py:1089-1166 — 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 (63 corresponding lines) · ×1
Edited copy of a member (63 corresponding lines) moments/Reversible.py:95— moments/Reversible.py:95-157 | moments/Reversible.py:162-238 — These two members are one piece of code written twice and then edited apart: 63 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 (183 corresponding lines) · ×1
Edited copy of a member (183 corresponding lines) moments/Demes/Inference.py:576— moments/Demes/Inference.py:576-758 | moments/Demes/Inference.py:1188-1376 — These two members are one piece of code written twice and then edited apart: 183 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (70 corresponding lines) · ×1
Edited copy of a member (70 corresponding lines) moments/Demes/Inference.py:115— moments/Demes/Inference.py:115-184 | moments/Demes/Inference.py:188-262 — These two members are one piece of code written twice and then edited apart: 70 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (69 corresponding lines) · ×1
Edited copy of a member (69 corresponding lines) moments/Plotting.py:213— moments/Plotting.py:213-304 | moments/Plotting.py:317-385 — These two members are one piece of code written twice and then edited apart: 69 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 (15 corresponding lines) · ×1
Edited copy of a member (15 corresponding lines) moments/Triallele/Jackknife.py:62— moments/Triallele/Jackknife.py:62-76 | moments/Triallele/Jackknife.py:122-136 — These two members are one piece of code written twice and then edited apart: 15 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (86 corresponding lines) · ×1
Edited copy of a member (86 corresponding lines) moments/LD/Godambe.py:305— moments/LD/Godambe.py:305-400 | moments/LD/Godambe.py:416-501 — These two members are one piece of code written twice and then edited apart: 86 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, 47+ corresponding lines) · ×1
Edited copies of one member (4 members, 47+ corresponding lines) moments/Demes/Inference.py:778— moments/Demes/Inference.py:778-828 | moments/Demes/Inference.py:1397-1443 | moments/Godambe.py:169-227 | moments/LD/Godambe.py:194-256 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 47 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 (53 corresponding lines) · ×1
Edited copy of a member (53 corresponding lines) moments/Demes/DemesUtil.py:7— moments/Demes/DemesUtil.py:7-59 | moments/Demes/DemesUtil.py:98-152 — These two members are one piece of code written twice and then edited apart: 53 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) moments/Godambe.py:520— moments/Godambe.py:520-590 | moments/Godambe.py:603-659 — 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 (120 corresponding lines) · ×1
Edited copy of a member (120 corresponding lines) moments/Inference.py:242— moments/Inference.py:242-374 | moments/Inference.py:1082-1201 — These two members are one piece of code written twice and then edited apart: 120 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (34 corresponding lines) · ×1
Edited copy of a member (34 corresponding lines) moments/Godambe.py:126— moments/Godambe.py:126-165 | moments/LD/Godambe.py:155-188 — 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 (30 corresponding lines) · ×1
Edited copy of a member (30 corresponding lines) moments/Demographics2D.py:144— moments/Demographics2D.py:144-173 | moments/Demographics2D.py:177-212 — 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 copies of one member (3 members, 46+ corresponding lines) · ×1
Edited copies of one member (3 members, 46+ corresponding lines) REDACTED:1548— REDACTED:1548-1616 | REDACTED:251-313 | REDACTED:373-418 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 46 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 (18 corresponding lines) · ×1
Edited copy of a member (18 corresponding lines) moments/Demes/Demes.py:1490— moments/Demes/Demes.py:1490-1508 | moments/Demes/Demes.py:1688-1705 — 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 copies of one member (4 members, 20+ corresponding lines) · ×1
Edited copies of one member (4 members, 20+ corresponding lines) REDACTED:62— REDACTED:62-81 | REDACTED:106-127 | REDACTED:166-191 | REDACTED:195-217 — 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 copy of a member (23 corresponding lines) · ×1
Edited copy of a member (23 corresponding lines) moments/Demographics1D.py:51— moments/Demographics1D.py:51-73 | moments/Demographics1D.py:77-100 — 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, 5+ corresponding lines) · ×1
Edited copies of one member (3 members, 5+ corresponding lines) REDACTED:169— REDACTED:169-173 | REDACTED:237-242 | REDACTED:317-321 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 5 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 (6 corresponding lines) · ×1
Edited copy of a member (6 corresponding lines) moments/TwoLocus/Numerics.py:37— moments/TwoLocus/Numerics.py:37-47 | moments/TwoLocus/Numerics.py:51-56 — 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· Edited copy of a member (155 corresponding lines) · ×1
Edited copy of a member (155 corresponding lines) moments/Parsing.py:57— moments/Parsing.py:57-211 | REDACTED:2023-2177 — These two members are one piece of code written twice and then edited apart: 155 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, 17+ corresponding lines) · ×1
Edited copies of one member (3 members, 17+ corresponding lines) moments/Inference.py:1205— moments/Inference.py:1205-1221 | moments/LD/Inference.py:1212-1228 | moments/TwoLocus/Inference.py:110-126 — 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 copy of a member (10 corresponding lines) · ×1
Edited copy of a member (10 corresponding lines) moments/Manips.py:541— moments/Manips.py:541-550 | moments/Manips.py:555-564 — 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 (48 corresponding lines) · ×1
Edited copy of a member (48 corresponding lines) REDACTED:2191— REDACTED:2191-2273 | REDACTED:792-839 — 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 (4 members, 18+ corresponding lines) · ×1
Edited copies of one member (4 members, 18+ corresponding lines) moments/TwoLocus/Util.py:475— moments/TwoLocus/Util.py:475-492 | moments/TwoLocus/Util.py:496-513 | moments/TwoLocus/Util.py:517-534 | moments/TwoLocus/Util.py:538-555 — 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 copy of a member (17 corresponding lines) · ×1
Edited copy of a member (17 corresponding lines) moments/LD/Demographics1D.py:7— moments/LD/Demographics1D.py:7-23 | moments/LD/Demographics2D.py:7-24 — 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.
Duplicated block (126–147 lines × 2) moments/LD/Inference.py:772— moments/LD/Inference.py:772-897 | moments/LD/Inference.py:985-1131 — both copies are in the same file, so extract the 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 (118 lines × 2) moments/TwoLocus/Numerics.py:123— moments/TwoLocus/Numerics.py:123-240 | moments/TwoLocus/Numerics.py:968-1085 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (91–93 lines × 2) moments/Inference.py:242— moments/Inference.py:242-334 | moments/Inference.py:1082-1172 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (49–79 lines × 2) moments/LinearSystem.py:322— moments/LinearSystem.py:322-370 | moments/LinearSystem.py:373-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.
Duplicated block (73 lines × 2) moments/Demes/Inference.py:681— moments/Demes/Inference.py:681-753 | moments/Demes/Inference.py:1300-1372 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/Demes/Inference.py:681` it begins part-way through the construct above it, so those 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, `moments/Demes/Inference.py:754` calls `delayed_flush` and `moments/Demes/Inference.py:1373` 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 (70 lines × 2) moments/Inference.py:627— moments/Inference.py:627-696 | moments/Inference.py:861-931 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/Inference.py:861` it does not close everything it opens, so those exact lines 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–65 lines × 2) moments/Demes/Inference.py:576— moments/Demes/Inference.py:576-640 | moments/Demes/Inference.py:909-922 — both copies are in the same file, so extract the 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 (59 lines × 3) moments/LD/Inference.py:669— moments/LD/Inference.py:669-727 | moments/LD/Inference.py:881-939 | moments/LD/Inference.py:1115-1173 — 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 `moments/LD/Inference.py:669` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (58 lines × 2) moments/LD/Matrices.py:1559— moments/LD/Matrices.py:1559-1616 | moments/LD/Matrices.py:1636-1693 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/LD/Matrices.py:1559` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (54 lines × 4) moments/Inference.py:115— moments/Inference.py:115-200 | moments/Inference.py:739-815 | moments/Inference.py:971-1040 | moments/TwoLocus/Inference.py:222-275 — before extracting anything, compare `moments/Inference.py` and `moments/TwoLocus/Inference.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 141 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 (48 lines × 5) moments/LD/Matrices.py:1988— moments/LD/Matrices.py:1988-2035 | moments/LD/Matrices.py:2045-2092 | moments/LD/Matrices.py:2102-2149 | moments/LD/Matrices.py:2159-2206 | moments/LD/Matrices.py:2218-2265 — 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 `moments/LD/Matrices.py:1988` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (34–46 lines × 4) moments/Godambe.py:289— moments/Godambe.py:289-328 | moments/Godambe.py:338-371 | moments/Godambe.py:386-431 | moments/Godambe.py:603-639 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (42–43 lines × 2) moments/Plotting.py:759— moments/Plotting.py:759-800 | moments/Plotting.py:1134-1176 — both copies are in the same file, so extract the 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 (41 lines × 4) moments/LD/Matrices.py:1791— moments/LD/Matrices.py:1791-1831 | moments/LD/Matrices.py:1840-1880 | moments/LD/Matrices.py:1889-1929 | moments/LD/Matrices.py:1938-1978 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (31–41 lines × 2) moments/Manips.py:667— moments/Manips.py:667-707 | moments/Manips.py:770-800 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (40 lines × 2) moments/LD/Matrices.py:2580— moments/LD/Matrices.py:2580-2619 | moments/LD/Matrices.py:2638-2677 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/LD/Matrices.py:2580` it begins part-way through the construct above it, so those exact lines 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–40 lines × 2) REDACTED:251— REDACTED:251-290 | REDACTED:373-399 — 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 (37–39 lines × 3) moments/Plotting.py:459— moments/Plotting.py:459-497 | moments/Plotting.py:654-690 | moments/Plotting.py:1017-1053 — 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 `moments/Plotting.py:459` it does not close everything it opens, so those 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 (38 lines × 2) moments/TwoLocus/Demographics.py:145— moments/TwoLocus/Demographics.py:145-183 | moments/TwoLocus/Demographics.py:237-274 — both copies are in the same file, so extract the 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, `moments/TwoLocus/Demographics.py:277` calls `exp`, `log` and `moments/TwoLocus/Demographics.py:186` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (34–35 lines × 2) moments/Plotting.py:270— moments/Plotting.py:270-304 | moments/Plotting.py:352-385 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (26–34 lines × 8) moments/LD/Matrices.py:1458— moments/LD/Matrices.py:1458-1483 | moments/LD/Matrices.py:1486-1511 | moments/LD/Matrices.py:1542-1567 | moments/LD/Matrices.py:1619-1644 | moments/LD/Matrices.py:3043-3076 | moments/LD/Matrices.py:3079-3112 | moments/LD/Matrices.py:3151-3184 | moments/LD/Matrices.py:3187-3220 — all 8 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (26–34 lines × 7) moments/LD/Matrices.py:1514— moments/LD/Matrices.py:1514-1539 | moments/LD/Matrices.py:1696-1721 | moments/LD/Matrices.py:3115-3148 | moments/LD/Matrices.py:3223-3256 | moments/LD/Matrices.py:3259-3292 | moments/LD/Matrices.py:3295-3328 | moments/LD/Matrices.py:3331-3364 — 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.
Duplicated block (29–34 lines × 3) moments/Reversible.py:62— moments/Reversible.py:62-90 | moments/Reversible.py:125-157 | moments/Reversible.py:205-238 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (32 lines × 2) moments/LD/Matrices.py:4003— moments/LD/Matrices.py:4003-4034 | moments/LD/Matrices.py:4760-4791 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/LD/Matrices.py:4003` it begins part-way through the construct above it, so those exact lines 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 × 4) moments/LD/Matrices.py:3449— moments/LD/Matrices.py:3449-3478 | moments/LD/Matrices.py:3657-3686 | moments/LD/Matrices.py:4206-4235 | moments/LD/Matrices.py:4414-4443 — 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 `moments/LD/Matrices.py:3449` it begins part-way through the construct above it, so those exact lines 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–29 lines × 5) REDACTED:599— REDACTED:599-623 | moments/Numerics.py:140-168 | REDACTED:1467-1495 | REDACTED:186-209 | REDACTED:322-343 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 5 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 5 times. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:599` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (22–28 lines × 11) moments/LD/Matrices.py:2456— moments/LD/Matrices.py:2456-2477 | moments/LD/Matrices.py:3575-3602 | moments/LD/Matrices.py:3783-3810 | moments/LD/Matrices.py:3863-3890 | moments/LD/Matrices.py:3943-3970 | moments/LD/Matrices.py:4023-4050 | moments/LD/Matrices.py:4332-4359 | moments/LD/Matrices.py:4540-4567 | moments/LD/Matrices.py:4620-4647 | moments/LD/Matrices.py:4700-4727 | moments/LD/Matrices.py:4780-4807 — all 11 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 `moments/LD/Matrices.py:2456` it begins part-way through the construct above it, so those exact lines 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–28 lines × 10) moments/LD/Matrices.py:2344— moments/LD/Matrices.py:2344-2365 | moments/LD/Matrices.py:2392-2413 | moments/LD/Matrices.py:3431-3458 | moments/LD/Matrices.py:3495-3522 | moments/LD/Matrices.py:3639-3666 | moments/LD/Matrices.py:3703-3730 | moments/LD/Matrices.py:4188-4215 | moments/LD/Matrices.py:4252-4279 | moments/LD/Matrices.py:4396-4423 | moments/LD/Matrices.py:4460-4487 — all 10 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 `moments/LD/Matrices.py:2344` it begins part-way through the construct above it, so those exact lines 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–28 lines × 5) moments/LD/Matrices.py:1013— moments/LD/Matrices.py:1013-1034 | moments/LD/Matrices.py:2742-2769 | moments/LD/Matrices.py:2772-2799 | moments/LD/Matrices.py:2832-2859 | moments/LD/Matrices.py:2862-2889 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (22–28 lines × 3) moments/LD/Matrices.py:2494— moments/LD/Matrices.py:2494-2515 | moments/LD/Matrices.py:2567-2594 | moments/LD/Matrices.py:2625-2652 — 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 `moments/LD/Matrices.py:2494` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (27–28 lines × 2) moments/LD/Matrices.py:3001— moments/LD/Matrices.py:3001-3028 | moments/LD/Matrices.py:3357-3383 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/LD/Matrices.py:3001` it begins part-way through the construct above it, so those exact lines 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–27 lines × 2) moments/Misc.py:800— moments/Misc.py:800-823 | REDACTED:1720-1746 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (26 lines × 5) moments/LD/Matrices.py:2804— moments/LD/Matrices.py:2804-2829 | moments/LD/Matrices.py:2894-2919 | moments/LD/Matrices.py:2924-2949 | moments/LD/Matrices.py:2954-2979 | moments/LD/Matrices.py:2984-3009 — 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 `moments/LD/Matrices.py:2804` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (22–23 lines × 6) moments/LD/Matrices.py:2911— moments/LD/Matrices.py:2911-2933 | moments/LD/Matrices.py:2941-2963 | moments/LD/Matrices.py:2971-2993 | moments/LD/Matrices.py:3249-3270 | moments/LD/Matrices.py:3285-3306 | moments/LD/Matrices.py:3321-3342 — 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 `moments/LD/Matrices.py:2911` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (24 lines × 4) REDACTED:554— REDACTED:554-577 | REDACTED:617-640 | REDACTED:680-703 | REDACTED:743-766 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED: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.
Duplicated block (20–22 lines × 6) moments/LD/Matrices.py:1274— moments/LD/Matrices.py:1274-1293 | moments/LD/Matrices.py:1982-2003 | moments/LD/Matrices.py:2039-2060 | moments/LD/Matrices.py:2096-2117 | moments/LD/Matrices.py:2153-2174 | moments/LD/Matrices.py:2212-2233 — 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 `moments/LD/Matrices.py:1274` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (22 lines × 2) REDACTED:560— REDACTED:560-581 | REDACTED:749-770 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (21 lines × 10) moments/LD/Matrices.py:2797— moments/LD/Matrices.py:2797-2817 | moments/LD/Matrices.py:2887-2907 | moments/LD/Matrices.py:2917-2937 | moments/LD/Matrices.py:2947-2967 | moments/LD/Matrices.py:2977-2997 | moments/LD/Matrices.py:3110-3130 | moments/LD/Matrices.py:3218-3238 | moments/LD/Matrices.py:3254-3274 | moments/LD/Matrices.py:3290-3310 | moments/LD/Matrices.py:3326-3346 — all 10 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 `moments/LD/Matrices.py:2797` it begins part-way through the construct above it, so those exact lines 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 × 8) moments/LD/Matrices.py:3405— moments/LD/Matrices.py:3405-3425 | moments/LD/Matrices.py:3469-3489 | moments/LD/Matrices.py:3613-3633 | moments/LD/Matrices.py:3677-3697 | moments/LD/Matrices.py:4162-4182 | moments/LD/Matrices.py:4226-4246 | moments/LD/Matrices.py:4370-4390 | moments/LD/Matrices.py:4434-4454 — all 8 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/LD/Matrices.py:3405` it begins part-way through the construct above it, so those exact lines 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 × 6) moments/LD/Matrices.py:2767— moments/LD/Matrices.py:2767-2787 | moments/LD/Matrices.py:2827-2847 | moments/LD/Matrices.py:2857-2877 | moments/LD/Matrices.py:3074-3094 | moments/LD/Matrices.py:3146-3166 | moments/LD/Matrices.py:3182-3202 — 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 `moments/LD/Matrices.py:2767` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (18–21 lines × 2) REDACTED:144— REDACTED:144-164 | REDACTED:66-83 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:144` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (20–21 lines × 2) moments/TwoLocus/Numerics.py:387— moments/TwoLocus/Numerics.py:387-406 | moments/TwoLocus/Numerics.py:493-513 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (18–20 lines × 10) moments/LD/Matrices.py:1994— moments/LD/Matrices.py:1994-2013 | moments/LD/Matrices.py:2051-2070 | moments/LD/Matrices.py:2108-2127 | moments/LD/Matrices.py:2165-2184 | moments/LD/Matrices.py:2224-2243 | moments/LD/Matrices.py:2811-2828 | moments/LD/Matrices.py:2901-2918 | moments/LD/Matrices.py:2931-2948 | moments/LD/Matrices.py:2961-2978 | moments/LD/Matrices.py:2991-3008 — all 10 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 `moments/LD/Matrices.py:1994` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. 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 (20 lines × 4) moments/TwoLocus/Util.py:559— moments/TwoLocus/Util.py:559-578 | moments/TwoLocus/Util.py:586-605 | moments/TwoLocus/Util.py:613-632 | moments/TwoLocus/Util.py:640-659 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (20 lines × 2) moments/LD/Godambe.py:371— moments/LD/Godambe.py:371-390 | moments/LD/Godambe.py:476-495 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/LD/Godambe.py:371` it begins part-way through the construct above it, so those exact lines 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–20 lines × 2) moments/LD/Matrices.py:2281— moments/LD/Matrices.py:2281-2300 | moments/LD/Matrices.py:3021-3038 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/LD/Matrices.py:2281` it begins part-way through the construct above it, so those 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 (19 lines × 8) moments/LD/Matrices.py:4045— moments/LD/Matrices.py:4045-4063 | moments/LD/Matrices.py:4065-4083 | moments/LD/Matrices.py:4085-4103 | moments/LD/Matrices.py:4105-4123 | moments/LD/Matrices.py:4802-4820 | moments/LD/Matrices.py:4822-4840 | moments/LD/Matrices.py:4842-4860 | moments/LD/Matrices.py:4862-4880 — all 8 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/LD/Matrices.py:4045` it begins part-way through the construct above it, so those exact lines 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–19 lines × 3) moments/Triallele/Numerics.py:413— moments/Triallele/Numerics.py:413-427 | moments/Triallele/Numerics.py:475-488 | moments/Triallele/Numerics.py:531-549 — 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 `moments/Triallele/Numerics.py:413` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (17–19 lines × 2) moments/TwoLocus/Numerics.py:312— moments/TwoLocus/Numerics.py:312-330 | moments/TwoLocus/Numerics.py:1089-1105 — both copies are in the same file, so extract the 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–18 lines × 45) moments/LD/Matrices.py:1978— moments/LD/Matrices.py:1978-1991 | moments/LD/Matrices.py:2035-2048 | moments/LD/Matrices.py:2092-2105 | moments/LD/Matrices.py:2149-2162 | moments/LD/Matrices.py:2354-2367 | moments/LD/Matrices.py:2402-2415 | moments/LD/Matrices.py:2418-2431 | moments/LD/Matrices.py:2434-2447 | moments/LD/Matrices.py:2450-2463 | moments/LD/Matrices.py:3445-3462 | moments/LD/Matrices.py:3509-3526 | moments/LD/Matrices.py:3529-3546 | moments/LD/Matrices.py:3549-3566 | moments/LD/Matrices.py:3569-3586 | moments/LD/Matrices.py:3653-3670 | moments/LD/Matrices.py:3717-3734 | moments/LD/Matrices.py:3737-3754 | moments/LD/Matrices.py:3757-3774 | moments/LD/Matrices.py:3777-3794 | moments/LD/Matrices.py:3817-3834 | moments/LD/Matrices.py:3837-3854 | moments/LD/Matrices.py:3857-3874 | moments/LD/Matrices.py:3897-3914 | moments/LD/Matrices.py:3917-3934 | moments/LD/Matrices.py:3937-3954 | moments/LD/Matrices.py:3977-3994 | moments/LD/Matrices.py:3997-4014 | moments/LD/Matrices.py:4202-4219 | moments/LD/Matrices.py:4266-4283 | moments/LD/Matrices.py:4286-4303 | moments/LD/Matrices.py:4306-4323 | moments/LD/Matrices.py:4326-4343 | moments/LD/Matrices.py:4410-4427 | moments/LD/Matrices.py:4474-4491 | moments/LD/Matrices.py:4494-4511 | moments/LD/Matrices.py:4514-4531 | moments/LD/Matrices.py:4534-4551 | moments/LD/Matrices.py:4574-4591 | moments/LD/Matrices.py:4594-4611 | moments/LD/Matrices.py:4614-4631 | moments/LD/Matrices.py:4654-4671 | moments/LD/Matrices.py:4674-4691 | moments/LD/Matrices.py:4694-4711 | moments/LD/Matrices.py:4734-4751 | moments/LD/Matrices.py:4754-4771 — all 45 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 `moments/LD/Matrices.py:1978` it begins part-way through the construct above it, so those exact lines 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–18 lines × 9) moments/LD/Matrices.py:1020— moments/LD/Matrices.py:1020-1033 | moments/LD/Matrices.py:1798-1813 | moments/LD/Matrices.py:1847-1862 | moments/LD/Matrices.py:1896-1911 | moments/LD/Matrices.py:1945-1960 | moments/LD/Matrices.py:2751-2768 | moments/LD/Matrices.py:2781-2798 | moments/LD/Matrices.py:2841-2858 | moments/LD/Matrices.py:2871-2888 — all 9 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/LD/Matrices.py:1020` it begins part-way through the construct above it, so those 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–18 lines × 7) moments/LD/Matrices.py:1384— moments/LD/Matrices.py:1384-1397 | moments/LD/Matrices.py:1569-1582 | moments/LD/Matrices.py:1646-1659 | moments/LD/Matrices.py:2502-2515 | moments/LD/Matrices.py:2518-2531 | moments/LD/Matrices.py:2577-2594 | moments/LD/Matrices.py:2635-2652 — all 7 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/LD/Matrices.py:1384` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (18 lines × 6) moments/LD/Matrices.py:2683— moments/LD/Matrices.py:2683-2700 | moments/LD/Matrices.py:2802-2819 | moments/LD/Matrices.py:2892-2909 | moments/LD/Matrices.py:2922-2939 | moments/LD/Matrices.py:2952-2969 | moments/LD/Matrices.py:2982-2999 — 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 `moments/LD/Matrices.py:2683` it does not close everything it opens, so those exact lines 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 × 4) REDACTED:807— REDACTED:807-824 | REDACTED:826-843 | REDACTED:845-862 | REDACTED:864-881 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (14–17 lines × 4) moments/LD/Matrices.py:2533— moments/LD/Matrices.py:2533-2547 | moments/LD/Matrices.py:2549-2562 | moments/LD/Matrices.py:2605-2621 | moments/LD/Matrices.py:2663-2679 — 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 `moments/LD/Matrices.py:2533` it begins part-way through the construct above it, so those 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–17 lines × 2) moments/Demes/Demes.py:1095— moments/Demes/Demes.py:1095-1108 | moments/Demes/Demes.py:1110-1126 — both copies are in the same file, so extract the 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) moments/Godambe.py:149— moments/Godambe.py:149-165 | moments/LD/Godambe.py:172-188 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (16 lines × 8) moments/LD/Matrices.py:1782— moments/LD/Matrices.py:1782-1797 | moments/LD/Matrices.py:1831-1846 | moments/LD/Matrices.py:1880-1895 | moments/LD/Matrices.py:1929-1944 | moments/LD/Matrices.py:2322-2337 | moments/LD/Matrices.py:2338-2353 | moments/LD/Matrices.py:2370-2385 | moments/LD/Matrices.py:2386-2401 — all 8 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/LD/Matrices.py:1782` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (15–16 lines × 5) moments/LD/Matrices.py:1099— moments/LD/Matrices.py:1099-1114 | moments/LD/Matrices.py:1116-1130 | moments/LD/Matrices.py:1148-1162 | moments/LD/Matrices.py:2509-2523 | moments/LD/Matrices.py:2541-2555 — 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 `moments/LD/Matrices.py:1099` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (15–16 lines × 3) REDACTED:1067— REDACTED:1067-1082 | REDACTED:551-565 | REDACTED:739-754 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 7 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. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `REDACTED:566` calls `any`, `ValueError` and `REDACTED:1083` 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 (15–16 lines × 2) moments/LD/Matrices.py:1067— moments/LD/Matrices.py:1067-1081 | moments/LD/Matrices.py:1091-1106 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/LD/Matrices.py:1067` it begins part-way through the construct above it, so those exact lines 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 × 19) moments/LD/Matrices.py:2463— moments/LD/Matrices.py:2463-2477 | moments/LD/Matrices.py:3585-3603 | moments/LD/Matrices.py:3793-3811 | moments/LD/Matrices.py:3873-3891 | moments/LD/Matrices.py:3953-3971 | moments/LD/Matrices.py:4033-4051 | moments/LD/Matrices.py:4053-4071 | moments/LD/Matrices.py:4073-4091 | moments/LD/Matrices.py:4093-4111 | moments/LD/Matrices.py:4113-4131 | moments/LD/Matrices.py:4342-4360 | moments/LD/Matrices.py:4550-4568 | moments/LD/Matrices.py:4630-4648 | moments/LD/Matrices.py:4710-4728 | moments/LD/Matrices.py:4790-4808 | moments/LD/Matrices.py:4810-4828 | moments/LD/Matrices.py:4830-4848 | moments/LD/Matrices.py:4850-4868 | moments/LD/Matrices.py:4870-4888 — all 19 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 `moments/LD/Matrices.py:2463` it begins part-way through the construct above it, so those exact lines 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 × 6) moments/LD/Matrices.py:1108— moments/LD/Matrices.py:1108-1122 | moments/LD/Matrices.py:1124-1138 | moments/LD/Matrices.py:1140-1154 | moments/LD/Matrices.py:1156-1170 | moments/LD/Matrices.py:1399-1413 | moments/LD/Matrices.py:1431-1445 — 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 `moments/LD/Matrices.py:1108` it begins part-way through the construct above it, so those exact lines 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) moments/Inference.py:1205— moments/Inference.py:1205-1219 | moments/LD/Inference.py:1212-1226 | moments/TwoLocus/Inference.py:110-124 — before extracting anything, compare `moments/Inference.py` and `moments/TwoLocus/Inference.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 141 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 (12–15 lines × 3) moments/Misc.py:283— moments/Misc.py:283-295 | moments/Misc.py:469-483 | moments/Misc.py:494-505 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/Misc.py:283` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `moments/Misc.py:466` calls `ValueError` and `moments/Misc.py:282` 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 × 49) moments/LD/Matrices.py:1273— moments/LD/Matrices.py:1273-1286 | moments/LD/Matrices.py:1981-1994 | moments/LD/Matrices.py:2038-2051 | moments/LD/Matrices.py:2095-2108 | moments/LD/Matrices.py:2152-2165 | moments/LD/Matrices.py:2211-2224 | moments/LD/Matrices.py:2357-2370 | moments/LD/Matrices.py:2405-2418 | moments/LD/Matrices.py:2421-2434 | moments/LD/Matrices.py:2437-2450 | moments/LD/Matrices.py:2453-2466 | moments/LD/Matrices.py:3448-3465 | moments/LD/Matrices.py:3512-3529 | moments/LD/Matrices.py:3532-3549 | moments/LD/Matrices.py:3552-3569 | moments/LD/Matrices.py:3572-3589 | moments/LD/Matrices.py:3656-3673 | moments/LD/Matrices.py:3720-3737 | moments/LD/Matrices.py:3740-3757 | moments/LD/Matrices.py:3760-3777 | moments/LD/Matrices.py:3780-3797 | moments/LD/Matrices.py:3820-3837 | moments/LD/Matrices.py:3840-3857 | moments/LD/Matrices.py:3860-3877 | moments/LD/Matrices.py:3900-3917 | moments/LD/Matrices.py:3920-3937 | moments/LD/Matrices.py:3940-3957 | moments/LD/Matrices.py:3980-3997 | moments/LD/Matrices.py:4000-4017 | moments/LD/Matrices.py:4020-4037 | moments/LD/Matrices.py:4205-4222 | moments/LD/Matrices.py:4269-4286 | moments/LD/Matrices.py:4289-4306 | moments/LD/Matrices.py:4309-4326 | moments/LD/Matrices.py:4329-4346 | moments/LD/Matrices.py:4413-4430 | moments/LD/Matrices.py:4477-4494 | moments/LD/Matrices.py:4497-4514 | moments/LD/Matrices.py:4517-4534 | moments/LD/Matrices.py:4537-4554 | moments/LD/Matrices.py:4577-4594 | moments/LD/Matrices.py:4597-4614 | moments/LD/Matrices.py:4617-4634 | moments/LD/Matrices.py:4657-4674 | moments/LD/Matrices.py:4677-4694 | moments/LD/Matrices.py:4697-4714 | moments/LD/Matrices.py:4737-4754 | moments/LD/Matrices.py:4757-4774 | moments/LD/Matrices.py:4777-4794 — all 49 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, `moments/LD/Matrices.py:3467` calls `elif` and `moments/LD/Matrices.py:1288` 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 × 12) moments/LD/Matrices.py:2325— moments/LD/Matrices.py:2325-2338 | moments/LD/Matrices.py:2341-2354 | moments/LD/Matrices.py:2373-2386 | moments/LD/Matrices.py:2389-2402 | moments/LD/Matrices.py:3428-3445 | moments/LD/Matrices.py:3492-3509 | moments/LD/Matrices.py:3636-3653 | moments/LD/Matrices.py:3700-3717 | moments/LD/Matrices.py:4185-4202 | moments/LD/Matrices.py:4249-4266 | moments/LD/Matrices.py:4393-4410 | moments/LD/Matrices.py:4457-4474 — all 12 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (14 lines × 10) moments/LD/Matrices.py:1175— moments/LD/Matrices.py:1175-1188 | moments/LD/Matrices.py:1224-1237 | moments/LD/Matrices.py:1785-1798 | moments/LD/Matrices.py:1834-1847 | moments/LD/Matrices.py:1883-1896 | moments/LD/Matrices.py:1932-1945 | moments/LD/Matrices.py:2325-2338 | moments/LD/Matrices.py:2341-2354 | moments/LD/Matrices.py:2373-2386 | moments/LD/Matrices.py:2389-2402 — all 10 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (14 lines × 8) moments/LD/Matrices.py:1013— moments/LD/Matrices.py:1013-1026 | moments/LD/Matrices.py:2494-2507 | moments/LD/Matrices.py:2567-2584 | moments/LD/Matrices.py:2625-2642 | moments/LD/Matrices.py:2742-2759 | moments/LD/Matrices.py:2772-2789 | moments/LD/Matrices.py:2832-2849 | moments/LD/Matrices.py:2862-2879 — all 8 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/LD/Matrices.py:1013` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (13–14 lines × 4) moments/TwoLocus/Demographics.py:172— moments/TwoLocus/Demographics.py:172-185 | moments/TwoLocus/Demographics.py:218-230 | moments/TwoLocus/Demographics.py:263-276 | moments/TwoLocus/Demographics.py:310-322 — 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, `moments/TwoLocus/Demographics.py:277` calls `exp`, `log` and `moments/TwoLocus/Demographics.py:186` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (10–14 lines × 3) REDACTED:980— REDACTED:980-989 | REDACTED:486-499 | REDACTED:706-719 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 7 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. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:486` it begins part-way through the construct above it, so those exact lines 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) moments/Manips.py:99— moments/Manips.py:99-112 | moments/Manips.py:157-170 | moments/Manips.py:344-357 — 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 (3–14 lines × 4) moments/Triallele/Jackknife.py:34— moments/Triallele/Jackknife.py:34-47 | moments/Triallele/Jackknife.py:48-50 | moments/Triallele/Jackknife.py:94-107 | moments/Triallele/Jackknife.py:108-110 — 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. 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, `moments/Triallele/Jackknife.py:48` calls `array`, `sum` and `moments/Triallele/Jackknife.py:50` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (13 lines × 13) moments/LD/Matrices.py:1514— moments/LD/Matrices.py:1514-1526 | moments/LD/Matrices.py:1696-1708 | moments/LD/Matrices.py:2683-2699 | moments/LD/Matrices.py:2802-2818 | moments/LD/Matrices.py:2892-2908 | moments/LD/Matrices.py:2922-2938 | moments/LD/Matrices.py:2952-2968 | moments/LD/Matrices.py:2982-2998 | moments/LD/Matrices.py:3115-3131 | moments/LD/Matrices.py:3223-3239 | moments/LD/Matrices.py:3259-3275 | moments/LD/Matrices.py:3295-3311 | moments/LD/Matrices.py:3331-3347 — all 13 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 `moments/LD/Matrices.py:1514` it does not close everything it opens, so those exact lines 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) moments/LD/Matrices.py:1013— moments/LD/Matrices.py:1013-1025 | moments/LD/Matrices.py:1327-1339 | moments/LD/Matrices.py:1458-1470 | moments/LD/Matrices.py:1486-1498 | moments/LD/Matrices.py:2494-2506 | moments/LD/Matrices.py:2742-2758 — 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 `moments/LD/Matrices.py:1013` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (13 lines × 3) moments/LD/Parsing.py:888— moments/LD/Parsing.py:888-900 | moments/LD/Parsing.py:912-924 | moments/LD/Parsing.py:939-951 — 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 `moments/LD/Parsing.py:888` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (12–13 lines × 3) moments/Manips.py:226— moments/Manips.py:226-237 | moments/Manips.py:289-301 | moments/Manips.py:351-363 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (12 lines × 20) moments/LD/Matrices.py:2265— moments/LD/Matrices.py:2265-2276 | moments/LD/Matrices.py:2466-2477 | moments/LD/Matrices.py:3589-3604 | moments/LD/Matrices.py:3797-3812 | moments/LD/Matrices.py:3877-3892 | moments/LD/Matrices.py:3957-3972 | moments/LD/Matrices.py:4037-4052 | moments/LD/Matrices.py:4057-4072 | moments/LD/Matrices.py:4077-4092 | moments/LD/Matrices.py:4097-4112 | moments/LD/Matrices.py:4117-4132 | moments/LD/Matrices.py:4346-4361 | moments/LD/Matrices.py:4554-4569 | moments/LD/Matrices.py:4634-4649 | moments/LD/Matrices.py:4714-4729 | moments/LD/Matrices.py:4794-4809 | moments/LD/Matrices.py:4814-4829 | moments/LD/Matrices.py:4834-4849 | moments/LD/Matrices.py:4854-4869 | moments/LD/Matrices.py:4874-4889 — all 20 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 `moments/LD/Matrices.py:2265` it begins part-way through the construct above it, so those 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–12 lines × 14) REDACTED:464— REDACTED:464-475 | REDACTED:478-489 | REDACTED:492-503 | REDACTED:506-517 | REDACTED:520-531 | REDACTED:532-540 | REDACTED:579-590 | REDACTED:591-602 | REDACTED:642-653 | REDACTED:654-665 | REDACTED:705-716 | REDACTED:717-728 | REDACTED:768-779 | REDACTED:780-791 — all 14 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:464` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (13 lines × 8) REDACTED:184— REDACTED:184-196 | REDACTED:204-216 | REDACTED:224-236 | REDACTED:244-256 | REDACTED:317-329 | REDACTED:334-346 | REDACTED:351-363 | REDACTED:368-380 — all 8 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (12 lines × 5) REDACTED:216— REDACTED:216-227 | REDACTED:232-249 | REDACTED:254-271 | REDACTED:276-293 | REDACTED:298-315 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (12 lines × 4) moments/Manips.py:45— moments/Manips.py:45-56 | moments/Manips.py:99-110 | moments/Manips.py:157-168 | moments/Manips.py:344-355 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (11–12 lines × 3) REDACTED:935— REDACTED:935-946 | REDACTED:950-960 | REDACTED:964-974 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED: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–12 lines × 2) moments/Demes/Inference.py:920— moments/Demes/Inference.py:920-929 | moments/Demes/Inference.py:1534-1545 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/Demes/Inference.py:1534` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (4–12 lines × 5) REDACTED:549— REDACTED:549-552 | REDACTED:603-614 | REDACTED:666-677 | REDACTED:732-736 | REDACTED:738-741 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:603` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (10–11 lines × 4) moments/LD/Parsing.py:868— moments/LD/Parsing.py:868-878 | moments/LD/Parsing.py:890-899 | moments/LD/Parsing.py:914-923 | moments/LD/Parsing.py:941-950 — 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 `moments/LD/Parsing.py:868` it begins part-way through the construct above it, so those 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 × 4) moments/LD/stats_from_genotype_counts.py:443— moments/LD/stats_from_genotype_counts.py:443-453 | moments/LD/stats_from_genotype_counts.py:1228-1238 | moments/LD/stats_from_genotype_counts.py:1269-1279 | moments/LD/stats_from_genotype_counts.py:1325-1335 — 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 `moments/LD/stats_from_genotype_counts.py:443` it does not close everything it opens, so those exact lines 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) moments/Godambe.py:218— moments/Godambe.py:218-227 | moments/LD/Godambe.py:246-256 — 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 `moments/LD/Godambe.py:246` it begins part-way through the construct above it, so those 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 (7–10 lines × 16) REDACTED:422— REDACTED:422-428 | REDACTED:433-442 | REDACTED:444-453 | REDACTED:454-461 | REDACTED:572-581 | REDACTED:584-593 | REDACTED:596-605 | REDACTED:635-644 | REDACTED:647-656 | REDACTED:659-668 | REDACTED:698-707 | REDACTED:710-719 | REDACTED:722-731 | REDACTED:761-770 | REDACTED:773-782 | REDACTED:785-794 — all 16 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:422` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (5–10 lines × 4) moments/Triallele/Numerics.py:415— moments/Triallele/Numerics.py:415-424 | moments/Triallele/Numerics.py:537-546 | moments/Triallele/Numerics.py:557-561 | moments/Triallele/Numerics.py:585-589 — 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 `moments/Triallele/Numerics.py:415` it begins part-way through the construct above it, so those 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, `moments/Triallele/Numerics.py:534` calls `choose` and `moments/Triallele/Numerics.py:412` 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–10 lines × 4) moments/LD/Matrices.py:122— moments/LD/Matrices.py:122-131 | moments/LD/Matrices.py:133-142 | moments/LD/Matrices.py:143-148 | moments/LD/Matrices.py:163-172 — 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. 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, `moments/LD/Matrices.py:133` calls `zip` and `moments/LD/Matrices.py:143` does not — after which the two agree again for 5 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (8–10 lines × 2) moments/Inference.py:77— moments/Inference.py:77-84 | moments/LD/Inference.py:518-527 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (9 lines × 9) REDACTED:933— REDACTED:933-942 | REDACTED:948-956 | REDACTED:962-970 | REDACTED:990-1000 | REDACTED:1006-1015 | REDACTED:1021-1030 | REDACTED:1036-1045 | REDACTED:1051-1060 | REDACTED:1066-1075 — 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–9 lines × 6) moments/TwoLocus/Numerics.py:72— moments/TwoLocus/Numerics.py:72-78 | moments/TwoLocus/Numerics.py:319-326 | moments/TwoLocus/Numerics.py:388-395 | moments/TwoLocus/Numerics.py:494-502 | moments/TwoLocus/Numerics.py:961-967 | moments/TwoLocus/Numerics.py:1094-1101 — 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 (11 lines × 5) moments/LD/Matrices.py:510— moments/LD/Matrices.py:510-520 | moments/LD/Matrices.py:531-541 | moments/LD/Matrices.py:555-565 | moments/LD/Matrices.py:576-586 | moments/LD/Matrices.py:600-610 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/LD/Matrices.py:510` it does not close everything it opens, so those exact lines 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) moments/LD/Matrices.py:659— moments/LD/Matrices.py:659-667 | moments/LD/Matrices.py:720-728 | moments/LD/Matrices.py:740-748 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/LD/Matrices.py:659` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (13–14 lines × 2) moments/LD/stats_from_genotype_counts.py:1062— moments/LD/stats_from_genotype_counts.py:1062-1074 | moments/LD/stats_from_genotype_counts.py:1335-1348 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/LD/stats_from_genotype_counts.py:1062` it begins part-way through the construct above it, so those exact lines 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 × 11) REDACTED:932— REDACTED:932-939 | REDACTED:947-954 | REDACTED:961-968 | REDACTED:975-982 | REDACTED:989-996 | REDACTED:1005-1012 | REDACTED:1020-1027 | REDACTED:1035-1042 | REDACTED:1050-1057 | REDACTED:1065-1072 | REDACTED:1080-1087 — all 11 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 × 20) moments/LD/Matrices.py:657— moments/LD/Matrices.py:657-663 | moments/LD/Matrices.py:677-683 | moments/LD/Matrices.py:711-717 | moments/LD/Matrices.py:718-724 | moments/LD/Matrices.py:738-744 | moments/LD/Matrices.py:748-754 | moments/LD/Matrices.py:801-807 | moments/LD/Matrices.py:808-814 | moments/LD/Matrices.py:828-834 | moments/LD/Matrices.py:835-841 | moments/LD/Matrices.py:845-851 | moments/LD/Matrices.py:862-868 | moments/LD/Matrices.py:872-878 | moments/LD/Matrices.py:889-895 | moments/LD/Matrices.py:899-905 | moments/LD/Matrices.py:906-912 | moments/LD/Matrices.py:925-931 | moments/LD/Matrices.py:932-938 | moments/LD/Matrices.py:939-945 | moments/LD/Matrices.py:946-952 — all 20 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 × 6) moments/LD/Matrices.py:771— moments/LD/Matrices.py:771-777 | moments/LD/Matrices.py:781-787 | moments/LD/Matrices.py:794-800 | moments/LD/Matrices.py:821-827 | moments/LD/Matrices.py:855-861 | moments/LD/Matrices.py:882-888 — 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 `moments/LD/Matrices.py:771` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (6–7 lines × 6) moments/LD/stats_from_genotype_counts.py:323— moments/LD/stats_from_genotype_counts.py:323-329 | moments/LD/stats_from_genotype_counts.py:370-376 | moments/LD/stats_from_genotype_counts.py:646-652 | moments/LD/stats_from_genotype_counts.py:829-835 | moments/LD/stats_from_genotype_counts.py:1009-1014 | moments/LD/stats_from_genotype_counts.py:1050-1055 — 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 `moments/LD/stats_from_genotype_counts.py:323` it does not close everything it opens, so those exact lines 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) moments/LD/stats_from_genotype_counts.py:497— moments/LD/stats_from_genotype_counts.py:497-503 | moments/LD/stats_from_genotype_counts.py:520-526 | moments/LD/stats_from_genotype_counts.py:545-551 | moments/LD/stats_from_genotype_counts.py:565-571 | moments/LD/stats_from_genotype_counts.py:607-613 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (36 lines × 2) moments/Triallele/Jackknife.py:23— moments/Triallele/Jackknife.py:23-58 | moments/Triallele/Jackknife.py:83-118 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (6 lines × 16) moments/LD/Matrices.py:713— moments/LD/Matrices.py:713-718 | moments/LD/Matrices.py:750-755 | moments/LD/Matrices.py:773-778 | moments/LD/Matrices.py:796-801 | moments/LD/Matrices.py:803-808 | moments/LD/Matrices.py:823-828 | moments/LD/Matrices.py:830-835 | moments/LD/Matrices.py:847-852 | moments/LD/Matrices.py:857-862 | moments/LD/Matrices.py:874-879 | moments/LD/Matrices.py:884-889 | moments/LD/Matrices.py:901-906 | moments/LD/Matrices.py:908-913 | moments/LD/Matrices.py:927-932 | moments/LD/Matrices.py:934-939 | moments/LD/Matrices.py:941-946 — all 16 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 `moments/LD/Matrices.py:713` it begins part-way through the construct above it, so those exact lines 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 × 6) moments/LD/Matrices.py:539— moments/LD/Matrices.py:539-544 | moments/LD/Matrices.py:563-568 | moments/LD/Matrices.py:584-589 | moments/LD/Matrices.py:608-613 | moments/LD/Matrices.py:689-694 | moments/LD/Matrices.py:706-711 — 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 `moments/LD/Matrices.py:539` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (3–6 lines × 3) REDACTED:67— REDACTED:67-69 | REDACTED:171-176 | REDACTED:304-309 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED: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. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (6 lines × 14) moments/LD/Matrices.py:517— moments/LD/Matrices.py:517-522 | moments/LD/Matrices.py:538-543 | moments/LD/Matrices.py:562-567 | moments/LD/Matrices.py:583-588 | moments/LD/Matrices.py:607-612 | moments/LD/Matrices.py:635-640 | moments/LD/Matrices.py:648-653 | moments/LD/Matrices.py:668-673 | moments/LD/Matrices.py:688-693 | moments/LD/Matrices.py:695-700 | moments/LD/Matrices.py:705-710 | moments/LD/Matrices.py:729-734 | moments/LD/Matrices.py:756-761 | moments/LD/Matrices.py:914-919 — all 14 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 (5 lines × 11) moments/LD/stats_from_genotype_counts.py:155— moments/LD/stats_from_genotype_counts.py:155-159 | moments/LD/stats_from_genotype_counts.py:172-176 | moments/LD/stats_from_genotype_counts.py:179-183 | moments/LD/stats_from_genotype_counts.py:312-316 | moments/LD/stats_from_genotype_counts.py:347-351 | moments/LD/stats_from_genotype_counts.py:357-361 | moments/LD/stats_from_genotype_counts.py:394-398 | moments/LD/stats_from_genotype_counts.py:404-408 | moments/LD/stats_from_genotype_counts.py:422-426 | moments/LD/stats_from_genotype_counts.py:429-433 | moments/LD/stats_from_genotype_counts.py:453-458 — all 11 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 `moments/LD/stats_from_genotype_counts.py:453` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (5 lines × 9) moments/LD/Matrices.py:633— moments/LD/Matrices.py:633-637 | moments/LD/Matrices.py:646-650 | moments/LD/Matrices.py:666-670 | moments/LD/Matrices.py:686-690 | moments/LD/Matrices.py:703-707 | moments/LD/Matrices.py:727-731 | moments/LD/Matrices.py:767-771 | moments/LD/Matrices.py:790-794 | moments/LD/Matrices.py:817-821 — 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 (6 lines × 8) moments/LD/stats_from_genotype_counts.py:166— moments/LD/stats_from_genotype_counts.py:166-171 | moments/LD/stats_from_genotype_counts.py:322-327 | moments/LD/stats_from_genotype_counts.py:369-374 | moments/LD/stats_from_genotype_counts.py:416-421 | moments/LD/stats_from_genotype_counts.py:645-650 | moments/LD/stats_from_genotype_counts.py:828-833 | moments/LD/stats_from_genotype_counts.py:1008-1013 | moments/LD/stats_from_genotype_counts.py:1049-1054 — all 8 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `moments/LD/stats_from_genotype_counts.py:166` it does not close everything it opens, so those exact lines 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 × 5) moments/Triallele/Jackknife.py:50— moments/Triallele/Jackknife.py:50-57 | moments/Triallele/Jackknife.py:110-117 | REDACTED:194-201 | REDACTED:214-221 | REDACTED:234-241 — there are 5 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 5 sites; resolving a subset leaves the remainder to drift apart.
Duplicated block (5 lines × 4) moments/Triallele/Numerics.py:351— moments/Triallele/Numerics.py:351-355 | moments/Triallele/Numerics.py:377-385 | moments/Triallele/Numerics.py:453-457 | moments/Triallele/Numerics.py:462-469 — 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 `moments/Triallele/Numerics.py:351` it begins part-way through the construct above it, so those 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 (4–5 lines × 3) moments/Demes/Demes.py:1420— moments/Demes/Demes.py:1420-1423 | moments/Demes/Demes.py:1430-1434 | moments/Demes/Demes.py:1448-1454 — 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 `moments/Demes/Demes.py:1430` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (5–7 lines × 3) REDACTED:175— REDACTED:175-181 | REDACTED:257-261 | REDACTED:308-314 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated predicate moments/Misc.py:380— `"outgroup_allele" in snp_info and snp_info["outgroup_allele"] != "-" and snp_info["outgroup_allele"] in snp_info["segregating"]` appears character-identically in 2 files — moments/Misc.py, REDACTED. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate moments/LD/stats_from_genotype_counts.py:1310— `(pop1 == pop3) or (pop1 == pop4) or (pop2 == pop3) or (pop2 == pop4)` appears character-identically in 2 files — moments/LD/stats_from_genotype_counts.py, moments/LD/stats_from_haplotype_counts.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate moments/Inference.py:79— `(verbose > 0) and (_counter % verbose == 0)` appears character-identically in 3 files — moments/Inference.py, moments/LD/Inference.py, moments/TwoLocus/Inference.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate REDACTED:150— `data_folded is None or data_folded == data.folded` appears character-identically in 2 files — REDACTED, REDACTED. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate moments/Demographics3D.py:23— `pop_ids is not None and len(pop_ids) != 3` appears character-identically in 2 files — moments/Demographics3D.py, moments/LD/Demographics3D.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate moments/Triallele/Integration.py:75— `t_elapsed == 0 or N_old != N or dt != dt_old` appears character-identically in 2 files — moments/Triallele/Integration.py, moments/TwoLocus/Integration.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Off-boarding risk: anonymized user #1 — If anonymized user #1 becomes unavailable, 18 significant file(s) lose their only recent owner: REDACTED, moments/Demes/Demes.py, moments/Demes/Inference.py, moments/Inference.py, moments/LD/Inference.py, REDACTED, moments/Plotting.py, moments/Misc.py (+10 more). Pair on, review, or document these before any departure.
No ADRs — No Architecture Decision Records found — no conventional ADR directory, no numbered `NNNN-title` documents in any markup this check reads, and nothing ADR-shaped by content. Design rationale recorded elsewhere (a design-notes tree, a mailing list, pull-request discussion) is not visible to this check and is not re-findable per decision, so a future maintainer cannot ask why one choice was made and get an answer.
M2 · Architecture documentation· No architecture diagram/doc · ×1
No architecture diagram/doc — No C4/Structurizr/PlantUML/Mermaid/Graphviz/D2 diagram, no drawn diagram named for the architecture, no file named `architecture` or `design` in any markup this check reads, and nothing in the README, docs or contributor guides that announces the shape — no `## Architecture` heading, no "architecture overview"/"high-level design" phrasing, no "the architecture is …" introduction, no guided code tour. A shape laid out in prose that never names itself as the architecture is not visible to this check, and neither is one kept outside the repository, so this row reports the absence of a re-findable shape document — not evidence that nobody wrote the shape down.
No SAST REDACTED:2— No static application security testing detected. For this repository's stack, add bandit, `semgrep --config=p/python`, or CodeQL's python pack as a CI step. What was searched, so you can tell an absence from a miss: the 4 CI workflow file(s) in this repository, and the scanner and linter configuration checked in beside them. A scan that runs outside CI, one configured in your forge's web UI rather than in a committed file, or a tool whose name is none of those this check carries, is not seen — if that is your case the row is wrong, and saying so is more useful than adding a second scanner.
No changelog — No CHANGELOG/HISTORY/RELEASES file — what shipped when isn't easy to reconstruct for support or audit. (Versioning/tagging makes releases traceable, but a changelog records the what.)
Dependency hygiene PARTLY measured — Python dependencies read, no exact pin to grade for currency — This repository's Python dependencies were read: 11 shipped distribution(s) across 2 manifest(s) (0 development or optional declaration(s) excluded, because a consumer does not install them). Whether any of them is behind its current release is the dependency-CURRENCY question, and no declaration here carries an EXACT pin to ask it about — every one is a floor or a range, which installs the newest release it admits and therefore cannot be behind one. That is a healthy declaration style, NOT a defect and NOT a gap in this analyzer; there is simply no currency question to answer. This is NOT a finding that these dependencies are current or healthy. Lockfiles are deliberately not read (poetry.lock, uv.lock, Pipfile.lock, pdm.lock): the four disagree about dev/optional membership, and misreading one would charge a test-only package a consumer never receives. Known CVEs in the same dependency graph are a separate question, reported under D30.
Appendix B — Reproduction & audit trail
Every external tool invocation behind a deep-scan dimension — the tool, its captured version, the exact command, how many findings it yielded, and a link to the retained raw output. To reproduce any finding: check out the same commit and run the command shown (repo-relative — never an absolute scratch path). The complete raw scanner output is retained verbatim under artifacts/raw/ (indexed in artifacts/raw/index.json); per-invocation exit codes and wall-clock durations are in sidecar.json — kept out of this table so the rendered report stays byte-identical across runs of the same commit.
trivy: not applicable — No Infrastructure-as-Code or container manifests found (Dockerfile, Docker Compose, Terraform, Kubernetes/Helm, CloudFormation, ARM, Bicep, Ansible); nothing to scan.
semgrep: not applicable — No personal data was found crossing a boundary the PII/GDPR ruleset checks — nothing written to a log or console sink, placed in a URL or query string, or persisted to browser storage. That is a clean result for the LEAK surface only: this ruleset detects personal data escaping, it does not inventory the personal data a repository holds, so it is not evidence that this repository has no personal-data surface. The personal-data map (Appendix C) and the C1-C5 compliance cards are what speak to that.
disclosure: not applicable — No vulnerability-disclosure policy file found (SECURITY.md/.markdown/.rst/.txt at root or under .github/.forgejo/.gitea/docs, .well-known/security.txt). A coordinated-disclosure policy may live off-repo, so this is not evidenced rather than failed.
runtime-hardening: not applicable — No Kubernetes/orchestration workloads found in the repository manifests; network egress policy is a cluster-native control that may live at the platform/firewall layer, so there is nothing to assess here.
runtime-hardening: not applicable — No Kubernetes/orchestration workloads found in the repository manifests; seccomp/AppArmor/SELinux confinement is a workload-level control, so there is nothing to assess here.
runtime-hardening: not applicable — No Kubernetes/orchestration workloads found in the repository manifests; runtime threat-detection and admission-control policy are cluster-level controls, so there is nothing to assess here.
Run 01a1df01-5827-7eae-aba5-304ea4fe83ae · every finding is also locatable in findings.md, and the complete scoring record (with exit codes + durations) in sidecar.json.
Issues: 42 · Warnings: 564 · Recommendations: 13 · Info: 1 — Appendix A · all findings · full markdown report.
Generated by the Canine Code Analyzer: deterministic code-health analysis. 15-11-2026 @ 11:39 UTC.
Downloadable artifacts
Machine-readable and reproducible from this commit + frozen rubric — drop them straight into a contract appendix, a CRA dossier, or a downstream SCA / VEX tool.