Public report of facebook/pyrefly, published 14 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, 14 November 2026, 17:50 UTC · Survey ID cd_f1a3104d95a94f11a8264c8d0f0f01b3
facebook/pyrefly
Measured 14 November 2026, 17:49 UTC, at code version e4a2587
CAI scoreAt riskDown 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 large codebase: 349,391 lines of product code in 11 projects, tests not counted · Estimated rebuild effort: about 4.6 person-years · Weakest lens: Code Health, 55
Findings by how serious they are
140 critical1955 serious97 minor
15 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
14 November 2026, 17:49 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.
A critical security finding is open, such as a library with a known critical vulnerability or a password or key found in the code. The score itself is unchanged, but its band shows At risk until the finding is fixed. See the Security and Compliance lens.
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 ▸
63of 63 dimensions measured by tools.
2173of 2192 findings point to an exact file and line, so you can open each one in the code. The other 19 concern the repository as a whole, such as missing documentation.
63dimensions across 7 lenses, read from 349,391 lines of product code in 11 projects.
facebook/pyrefly is rated At risk because critical security findings are open, most of them in the build pipeline. It scores 62 out of 100, which the At risk rating leaves unchanged.
Code Health, at 55, is the weakest lens and counts most in the score. The best first step is writing log messages as searchable templates, worth about 5 points. Recording design decisions comes next, worth about 2 points. Raising Code Health to 70 would lift the score to about 67.
117 pipeline tools are referenced by a changeable name, so the build pipeline can be tampered with. Nine pipeline steps put outside input straight into a shell command, so an attacker can run commands in the build pipeline. Pinning each tool to an exact version and passing outside input through environment variables would close both risks. Updating the vulnerable packages would fix the six packages with a known security hole, and the four pipeline steps that install packages without pinning their versions need the packages they install pinned to exact versions. Moving the write out of the read operation would take care of the two read operations that also write data.
The product code is 349,391 lines, about €660,000 to rebuild.
A lens is capped at Adequate while one of its dimensions scores below 4 out of 10, however well the rest of the lens does. That way a serious problem in one place always shows in the lens's rating.
How the score is built: what each lens counts forThe lenses don't count equally. The weakest lens counts most, the next weakest a little less, and so on, so a weak area pulls the score down instead of being averaged away. In the bar below, each part's width shows how much that lens counts and its colour shows its rating. Improving the widest part moves the score most, and as that lens improves, it counts for less, because another lens becomes the weakest.
If Code Health rose from 55 to 70, the lowest score rated Strong, the score would rise from 62 to about 67.
Code composition: what the lines of code are
Product code 59%Tests 41%
New since the last survey: 500 findings
These 500 critical or serious findings weren't in the previous survey, on 27 October 2026. The first 100 are listed here, and the findings file in the download package lists them all.
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: 266 findings
These 266 critical or serious findings were in the previous survey, on 27 October 2026, and are gone from this one. The first 100 are listed here.
€220,000 to €1,100,000, for 3,668 to 11,636 hours of work, about 4.6 person-years for 2 to 9 engineers
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.9 at a score of 62. 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
Large: 349,391 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.
Each conclusion below combines several dimensions into one point that no single dimension shows, and lists the measurements it rests on.
Where the investment is most exposed · Value at risk
This code would cost about €660,000 to build again, about 4.6 person-years of work. Its weakest lens is Code Health, at 55 (Adequate). Code Health is about how easy the code is to read and change safely, and code that is hard to read is slow and risky to change, so every future change costs more than it should. Because the weakest lens counts most in the score, work on Code Health also moves the score most.
Based on: the rebuild estimate · the Code Health grade · how much each lens counts
What to do: Start with the Code Health actions in Top priorities.
If you do one thing first · First action
Interpolated log message defeats structured logging. Of all the actions in this report, it raises the score most for the work it takes: about 5 points for medium effort. The next survey will show the change in the score.
Based on: the ranked actions in Top priorities, by score gain and effort
What hard-to-read code costs each year · Cost
Four dimensions measure how easy the code is to work in: two measure how tangled its logic is, one how much of it is copied, and one how well each part sticks to a single job. In this codebase they average 6.1 out of 10. Code at that level is slower to change than clean code, and we estimate the extra work at 5% to 10% on every change. The history of the code shows how much it changes: about 350,054 lines over the last 90 days, which is about 1,419,663 lines a year. At that pace, the extra work comes to an estimated 164.6 to 987.7 engineer-days a year, and it grows as more code changes.
How this is estimated: The number of changed lines is measured from the history of the code. The rest rests on two assumptions of our own: code scoring 8 out of 10 or more adds no extra work, and each point below 8 adds 2.5% to 5.6% to every change, never less than 2% to 5% and never more than 40% to 60% in all; and an engineer changes 150 to 400 lines in a day. The result is a range for planning, not a measurement.
Based on: Cyclomatic Complexity · Cognitive Complexity · Code Duplication · Cohesion (LCOM4) · the code's change history
What to do: Start with the files listed under Churn × Complexity Hotspots, which change often and are hard to read, because that is where the extra work is paid most often.
Architecture: which parts of the code depend on which
The code is divided into modules, groups of code that each handle one part of the product, and a module depends on another when it uses code from it. The table lists the modules both down the side and across the top, in an order where each module should only use modules listed above it. A number in a cell means the module on that row uses the module in that column, and it counts the pairs of building blocks (types) that connect them. The one thing to look for is a mark above the diagonal line. It means two or more modules use each other in a loop (a dependency cycle), so none of them can be changed, tested or released on its own.
634 modules, with 1805 dependencies between them. 5 loops run through 126 of the modules, marked above the diagonal.
The table shows the 40 modules with the most connections; 594 more are left out to keep it readable.
Which modules use which. The module on each row uses the module in each column, and the number counts the pairs of types that connect them. A cell above the diagonal is part of a loop.
pyrefly_python.module_name uses pyrefly_util.visit, so a change to pyrefly_util.visit can break pyrefly_python.module_name, while a change to pyrefly_python.module_name can't break pyrefly_util.visit.
Position
Below the diagonal: pyrefly_python.module_name uses a module listed above it, which is the healthy direction.
pyrefly_python.module_path uses pyrefly_util.visit, so a change to pyrefly_util.visit can break pyrefly_python.module_path, while a change to pyrefly_python.module_path can't break pyrefly_util.visit.
Position
Below the diagonal: pyrefly_python.module_path uses a module listed above it, which is the healthy direction.
pyrefly_python.module_path uses pyrefly_python.module_name, so a change to pyrefly_python.module_name can break pyrefly_python.module_path, while a change to pyrefly_python.module_path can't break pyrefly_python.module_name.
Position
Below the diagonal: pyrefly_python.module_path uses a module listed above it, which is the healthy direction.
pyrefly_build.handle uses pyrefly_python.sys_info, so a change to pyrefly_python.sys_info can break pyrefly_build.handle, while a change to pyrefly_build.handle can't break pyrefly_python.sys_info.
Position
Below the diagonal: pyrefly_build.handle uses a module listed above it, which is the healthy direction.
pyrefly_build.handle uses pyrefly_python.module_name, so a change to pyrefly_python.module_name can break pyrefly_build.handle, while a change to pyrefly_build.handle can't break pyrefly_python.module_name.
Position
Below the diagonal: pyrefly_build.handle uses a module listed above it, which is the healthy direction.
pyrefly_build.handle uses pyrefly_python.module_path, so a change to pyrefly_python.module_path can break pyrefly_build.handle, while a change to pyrefly_build.handle can't break pyrefly_python.module_path.
Position
Below the diagonal: pyrefly_build.handle uses a module listed above it, which is the healthy direction.
pyrefly_python.module uses pyrefly_util.arc_id, so a change to pyrefly_util.arc_id can break pyrefly_python.module, while a change to pyrefly_python.module can't break pyrefly_util.arc_id.
Position
Below the diagonal: pyrefly_python.module uses a module listed above it, which is the healthy direction.
pyrefly_python.module uses pyrefly_python.module_name, so a change to pyrefly_python.module_name can break pyrefly_python.module, while a change to pyrefly_python.module can't break pyrefly_python.module_name.
Position
Below the diagonal: pyrefly_python.module uses a module listed above it, which is the healthy direction.
pyrefly_python.module uses pyrefly_python.module_path, so a change to pyrefly_python.module_path can break pyrefly_python.module, while a change to pyrefly_python.module can't break pyrefly_python.module_path.
Position
Below the diagonal: pyrefly_python.module uses a module listed above it, which is the healthy direction.
pyrefly_config.config uses pyrefly_config.error_kind, so a change to pyrefly_config.error_kind can break pyrefly_config.config, while a change to pyrefly_config.config can't break pyrefly_config.error_kind.
Position
Below the diagonal: pyrefly_config.config uses a module listed above it, which is the healthy direction.
pyrefly_config.config uses pyrefly_python.sys_info, so a change to pyrefly_python.sys_info can break pyrefly_config.config, while a change to pyrefly_config.config can't break pyrefly_python.sys_info.
Position
Below the diagonal: pyrefly_config.config uses a module listed above it, which is the healthy direction.
pyrefly_config.config uses pyrefly_util.arc_id, so a change to pyrefly_util.arc_id can break pyrefly_config.config, while a change to pyrefly_config.config can't break pyrefly_util.arc_id.
Position
Below the diagonal: pyrefly_config.config uses a module listed above it, which is the healthy direction.
pyrefly_config.config uses pyrefly_python.module_name, so a change to pyrefly_python.module_name can break pyrefly_config.config, while a change to pyrefly_config.config can't break pyrefly_python.module_name.
Position
Below the diagonal: pyrefly_config.config uses a module listed above it, which is the healthy direction.
pyrefly_config.config uses pyrefly_python.module_path, so a change to pyrefly_python.module_path can break pyrefly_config.config, while a change to pyrefly_config.config can't break pyrefly_python.module_path.
Position
Below the diagonal: pyrefly_config.config uses a module listed above it, which is the healthy direction.
pyrefly_config.config uses pyrefly_build.handle, so a change to pyrefly_build.handle can break pyrefly_config.config, while a change to pyrefly_config.config can't break pyrefly_build.handle.
Position
Below the diagonal: pyrefly_config.config uses a module listed above it, which is the healthy direction.
pyrefly_python.qname uses pyrefly_python.module_name, so a change to pyrefly_python.module_name can break pyrefly_python.qname, while a change to pyrefly_python.qname can't break pyrefly_python.module_name.
Position
Below the diagonal: pyrefly_python.qname uses a module listed above it, which is the healthy direction.
pyrefly_python.qname uses pyrefly_python.module_path, so a change to pyrefly_python.module_path can break pyrefly_python.qname, while a change to pyrefly_python.qname can't break pyrefly_python.module_path.
Position
Below the diagonal: pyrefly_python.qname uses a module listed above it, which is the healthy direction.
pyrefly_python.qname uses pyrefly_python.module, so a change to pyrefly_python.module can break pyrefly_python.qname, while a change to pyrefly_python.qname can't break pyrefly_python.module.
Position
Below the diagonal: pyrefly_python.qname uses a module listed above it, which is the healthy direction.
pyrefly_types.stdlib uses pyrefly_python.sys_info, so a change to pyrefly_python.sys_info can break pyrefly_types.stdlib, while a change to pyrefly_types.stdlib can't break pyrefly_python.sys_info.
Position
Below the diagonal: pyrefly_types.stdlib uses a module listed above it, which is the healthy direction.
pyrefly_types.stdlib uses pyrefly_python.qname, so a change to pyrefly_python.qname can break pyrefly_types.stdlib, while a change to pyrefly_types.stdlib can't break pyrefly_python.qname.
Position
Below the diagonal: pyrefly_types.stdlib uses a module listed above it, which is the healthy direction.
12→14 pyrefly_types.stdlib uses pyrefly_types.heappart of a loop✕
Connections
1 pair of types, where a type in pyrefly_types.stdlib uses a type in pyrefly_types.heap.
pyrefly_types.stdlib uses pyrefly_types.heap, so a change to pyrefly_types.heap can break pyrefly_types.stdlib, while a change to pyrefly_types.stdlib can't break pyrefly_types.heap.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
12→15 pyrefly_types.stdlib uses pyrefly_types.typespart of a loop✕
Connections
1 pair of types, where a type in pyrefly_types.stdlib uses a type in pyrefly_types.types.
pyrefly_types.stdlib uses pyrefly_types.types, so a change to pyrefly_types.types can break pyrefly_types.stdlib, while a change to pyrefly_types.stdlib can't break pyrefly_types.types.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
12→19 pyrefly_types.stdlib uses pyrefly_types.classpart of a loop✕
Connections
2 pairs of types, where a type in pyrefly_types.stdlib uses a type in pyrefly_types.class.
pyrefly_types.stdlib uses pyrefly_types.class, so a change to pyrefly_types.class can break pyrefly_types.stdlib, while a change to pyrefly_types.stdlib can't break pyrefly_types.class.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
pyrefly_types.type_var uses pyrefly_util.arc_id, so a change to pyrefly_util.arc_id can break pyrefly_types.type_var, while a change to pyrefly_types.type_var can't break pyrefly_util.arc_id.
Position
Below the diagonal: pyrefly_types.type_var uses a module listed above it, which is the healthy direction.
pyrefly_types.type_var uses pyrefly_util.visit, so a change to pyrefly_util.visit can break pyrefly_types.type_var, while a change to pyrefly_types.type_var can't break pyrefly_util.visit.
Position
Below the diagonal: pyrefly_types.type_var uses a module listed above it, which is the healthy direction.
pyrefly_types.type_var uses pyrefly_python.module, so a change to pyrefly_python.module can break pyrefly_types.type_var, while a change to pyrefly_types.type_var can't break pyrefly_python.module.
Position
Below the diagonal: pyrefly_types.type_var uses a module listed above it, which is the healthy direction.
pyrefly_types.type_var uses pyrefly_python.qname, so a change to pyrefly_python.qname can break pyrefly_types.type_var, while a change to pyrefly_types.type_var can't break pyrefly_python.qname.
Position
Below the diagonal: pyrefly_types.type_var uses a module listed above it, which is the healthy direction.
pyrefly_types.type_var uses pyrefly_types.stdlib, so a change to pyrefly_types.stdlib can break pyrefly_types.type_var, while a change to pyrefly_types.type_var can't break pyrefly_types.stdlib.
Position
Below the diagonal: pyrefly_types.type_var uses a module listed above it, which is the healthy direction.
13→14 pyrefly_types.type_var uses pyrefly_types.heappart of a loop✕
Connections
2 pairs of types, where a type in pyrefly_types.type_var uses a type in pyrefly_types.heap.
pyrefly_types.type_var uses pyrefly_types.heap, so a change to pyrefly_types.heap can break pyrefly_types.type_var, while a change to pyrefly_types.type_var can't break pyrefly_types.heap.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
13→15 pyrefly_types.type_var uses pyrefly_types.typespart of a loop✕
Connections
3 pairs of types, where a type in pyrefly_types.type_var uses a type in pyrefly_types.types.
pyrefly_types.type_var uses pyrefly_types.types, so a change to pyrefly_types.types can break pyrefly_types.type_var, while a change to pyrefly_types.type_var can't break pyrefly_types.types.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
13→21 pyrefly_types.type_var uses pyrefly_types.quantifiedpart of a loop✕
Connections
4 pairs of types, where a type in pyrefly_types.type_var uses a type in pyrefly_types.quantified.
pyrefly_types.type_var uses pyrefly_types.quantified, so a change to pyrefly_types.quantified can break pyrefly_types.type_var, while a change to pyrefly_types.type_var can't break pyrefly_types.quantified.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
pyrefly_types.heap uses pyrefly_types.type_var, so a change to pyrefly_types.type_var can break pyrefly_types.heap, while a change to pyrefly_types.heap can't break pyrefly_types.type_var.
Position
Below the diagonal: pyrefly_types.heap uses a module listed above it, which is the healthy direction.
14→15 pyrefly_types.heap uses pyrefly_types.typespart of a loop✕
Connections
9 pairs of types, where a type in pyrefly_types.heap uses a type in pyrefly_types.types.
pyrefly_types.heap uses pyrefly_types.types, so a change to pyrefly_types.types can break pyrefly_types.heap, while a change to pyrefly_types.heap can't break pyrefly_types.types.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
14→17 pyrefly_types.heap uses pyrefly_types.functionpart of a loop✕
Connections
1 pair of types, where a type in pyrefly_types.heap uses a type in pyrefly_types.function.
pyrefly_types.heap uses pyrefly_types.function, so a change to pyrefly_types.function can break pyrefly_types.heap, while a change to pyrefly_types.heap can't break pyrefly_types.function.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
14→19 pyrefly_types.heap uses pyrefly_types.classpart of a loop✕
Connections
2 pairs of types, where a type in pyrefly_types.heap uses a type in pyrefly_types.class.
pyrefly_types.heap uses pyrefly_types.class, so a change to pyrefly_types.class can break pyrefly_types.heap, while a change to pyrefly_types.heap can't break pyrefly_types.class.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
14→21 pyrefly_types.heap uses pyrefly_types.quantifiedpart of a loop✕
Connections
1 pair of types, where a type in pyrefly_types.heap uses a type in pyrefly_types.quantified.
pyrefly_types.heap uses pyrefly_types.quantified, so a change to pyrefly_types.quantified can break pyrefly_types.heap, while a change to pyrefly_types.heap can't break pyrefly_types.quantified.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
14→22 pyrefly_types.heap uses pyrefly_types.callablepart of a loop✕
Connections
4 pairs of types, where a type in pyrefly_types.heap uses a type in pyrefly_types.callable.
pyrefly_types.heap uses pyrefly_types.callable, so a change to pyrefly_types.callable can break pyrefly_types.heap, while a change to pyrefly_types.heap can't break pyrefly_types.callable.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
pyrefly_types.types uses pyrefly_util.visit, so a change to pyrefly_util.visit can break pyrefly_types.types, while a change to pyrefly_types.types can't break pyrefly_util.visit.
Position
Below the diagonal: pyrefly_types.types uses a module listed above it, which is the healthy direction.
pyrefly_types.types uses pyrefly_python.module_name, so a change to pyrefly_python.module_name can break pyrefly_types.types, while a change to pyrefly_types.types can't break pyrefly_python.module_name.
Position
Below the diagonal: pyrefly_types.types uses a module listed above it, which is the healthy direction.
pyrefly_types.types uses pyrefly_python.qname, so a change to pyrefly_python.qname can break pyrefly_types.types, while a change to pyrefly_types.types can't break pyrefly_python.qname.
Position
Below the diagonal: pyrefly_types.types uses a module listed above it, which is the healthy direction.
pyrefly_types.types uses pyrefly_types.stdlib, so a change to pyrefly_types.stdlib can break pyrefly_types.types, while a change to pyrefly_types.types can't break pyrefly_types.stdlib.
Position
Below the diagonal: pyrefly_types.types uses a module listed above it, which is the healthy direction.
pyrefly_types.types uses pyrefly_types.heap, so a change to pyrefly_types.heap can break pyrefly_types.types, while a change to pyrefly_types.types can't break pyrefly_types.heap.
Position
Below the diagonal: pyrefly_types.types uses a module listed above it, which is the healthy direction.
15→17 pyrefly_types.types uses pyrefly_types.functionpart of a loop✕
Connections
6 pairs of types, where a type in pyrefly_types.types uses a type in pyrefly_types.function.
pyrefly_types.types uses pyrefly_types.function, so a change to pyrefly_types.function can break pyrefly_types.types, while a change to pyrefly_types.types can't break pyrefly_types.function.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
15→21 pyrefly_types.types uses pyrefly_types.quantifiedpart of a loop✕
Connections
2 pairs of types, where a type in pyrefly_types.types uses a type in pyrefly_types.quantified.
pyrefly_types.types uses pyrefly_types.quantified, so a change to pyrefly_types.quantified can break pyrefly_types.types, while a change to pyrefly_types.types can't break pyrefly_types.quantified.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
15→22 pyrefly_types.types uses pyrefly_types.callablepart of a loop✕
Connections
2 pairs of types, where a type in pyrefly_types.types uses a type in pyrefly_types.callable.
pyrefly_types.types uses pyrefly_types.callable, so a change to pyrefly_types.callable can break pyrefly_types.types, while a change to pyrefly_types.types can't break pyrefly_types.callable.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
pyrefly.lib.state.lsp uses pyrefly_python.sys_info, so a change to pyrefly_python.sys_info can break pyrefly.lib.state.lsp, while a change to pyrefly.lib.state.lsp can't break pyrefly_python.sys_info.
Position
Below the diagonal: pyrefly.lib.state.lsp uses a module listed above it, which is the healthy direction.
pyrefly.lib.state.lsp uses pyrefly_python.module_name, so a change to pyrefly_python.module_name can break pyrefly.lib.state.lsp, while a change to pyrefly.lib.state.lsp can't break pyrefly_python.module_name.
Position
Below the diagonal: pyrefly.lib.state.lsp uses a module listed above it, which is the healthy direction.
pyrefly.lib.state.lsp uses pyrefly_build.handle, so a change to pyrefly_build.handle can break pyrefly.lib.state.lsp, while a change to pyrefly.lib.state.lsp can't break pyrefly_build.handle.
Position
Below the diagonal: pyrefly.lib.state.lsp uses a module listed above it, which is the healthy direction.
pyrefly.lib.state.lsp uses pyrefly_python.module, so a change to pyrefly_python.module can break pyrefly.lib.state.lsp, while a change to pyrefly.lib.state.lsp can't break pyrefly_python.module.
Position
Below the diagonal: pyrefly.lib.state.lsp uses a module listed above it, which is the healthy direction.
pyrefly.lib.state.lsp uses pyrefly_types.types, so a change to pyrefly_types.types can break pyrefly.lib.state.lsp, while a change to pyrefly.lib.state.lsp can't break pyrefly_types.types.
Position
Below the diagonal: pyrefly.lib.state.lsp uses a module listed above it, which is the healthy direction.
16→29 pyrefly.lib.state.lsp uses pyrefly.lib.report.debug_infopart of a loop✕
Connections
5 pairs of types, where a type in pyrefly.lib.state.lsp uses a type in pyrefly.lib.report.debug_info.
pyrefly.lib.state.lsp uses pyrefly.lib.report.debug_info, so a change to pyrefly.lib.report.debug_info can break pyrefly.lib.state.lsp, while a change to pyrefly.lib.state.lsp can't break pyrefly.lib.report.debug_info.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
16→38 pyrefly.lib.state.lsp uses pyrefly.lib.alt.answerspart of a loop✕
Connections
1 pair of types, where a type in pyrefly.lib.state.lsp uses a type in pyrefly.lib.alt.answers.
pyrefly.lib.state.lsp uses pyrefly.lib.alt.answers, so a change to pyrefly.lib.alt.answers can break pyrefly.lib.state.lsp, while a change to pyrefly.lib.state.lsp can't break pyrefly.lib.alt.answers.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
pyrefly_types.function uses pyrefly_util.visit, so a change to pyrefly_util.visit can break pyrefly_types.function, while a change to pyrefly_types.function can't break pyrefly_util.visit.
Position
Below the diagonal: pyrefly_types.function uses a module listed above it, which is the healthy direction.
pyrefly_types.function uses pyrefly_python.module_name, so a change to pyrefly_python.module_name can break pyrefly_types.function, while a change to pyrefly_types.function can't break pyrefly_python.module_name.
Position
Below the diagonal: pyrefly_types.function uses a module listed above it, which is the healthy direction.
pyrefly_types.function uses pyrefly_python.module_path, so a change to pyrefly_python.module_path can break pyrefly_types.function, while a change to pyrefly_types.function can't break pyrefly_python.module_path.
Position
Below the diagonal: pyrefly_types.function uses a module listed above it, which is the healthy direction.
pyrefly_types.function uses pyrefly_python.module, so a change to pyrefly_python.module can break pyrefly_types.function, while a change to pyrefly_types.function can't break pyrefly_python.module.
Position
Below the diagonal: pyrefly_types.function uses a module listed above it, which is the healthy direction.
pyrefly_types.function uses pyrefly_python.qname, so a change to pyrefly_python.qname can break pyrefly_types.function, while a change to pyrefly_types.function can't break pyrefly_python.qname.
Position
Below the diagonal: pyrefly_types.function uses a module listed above it, which is the healthy direction.
pyrefly_types.function uses pyrefly_types.types, so a change to pyrefly_types.types can break pyrefly_types.function, while a change to pyrefly_types.function can't break pyrefly_types.types.
Position
Below the diagonal: pyrefly_types.function uses a module listed above it, which is the healthy direction.
17→19 pyrefly_types.function uses pyrefly_types.classpart of a loop✕
Connections
4 pairs of types, where a type in pyrefly_types.function uses a type in pyrefly_types.class.
pyrefly_types.function uses pyrefly_types.class, so a change to pyrefly_types.class can break pyrefly_types.function, while a change to pyrefly_types.function can't break pyrefly_types.class.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
17→22 pyrefly_types.function uses pyrefly_types.callablepart of a loop✕
Connections
1 pair of types, where a type in pyrefly_types.function uses a type in pyrefly_types.callable.
pyrefly_types.function uses pyrefly_types.callable, so a change to pyrefly_types.callable can break pyrefly_types.function, while a change to pyrefly_types.function can't break pyrefly_types.callable.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
pyrefly.lib.report.pysa.context uses pyrefly_build.handle, so a change to pyrefly_build.handle can break pyrefly.lib.report.pysa.context, while a change to pyrefly.lib.report.pysa.context can't break pyrefly_build.handle.
Position
Below the diagonal: pyrefly.lib.report.pysa.context uses a module listed above it, which is the healthy direction.
pyrefly.lib.report.pysa.context uses pyrefly_types.stdlib, so a change to pyrefly_types.stdlib can break pyrefly.lib.report.pysa.context, while a change to pyrefly.lib.report.pysa.context can't break pyrefly_types.stdlib.
Position
Below the diagonal: pyrefly.lib.report.pysa.context uses a module listed above it, which is the healthy direction.
pyrefly.lib.report.pysa.context uses pyrefly.lib.state.lsp, so a change to pyrefly.lib.state.lsp can break pyrefly.lib.report.pysa.context, while a change to pyrefly.lib.report.pysa.context can't break pyrefly.lib.state.lsp.
Position
Below the diagonal: pyrefly.lib.report.pysa.context uses a module listed above it, which is the healthy direction.
18→27 pyrefly.lib.report.pysa.context uses pyrefly.lib.report.pysapart of a loop✕
Connections
1 pair of types, where a type in pyrefly.lib.report.pysa.context uses a type in pyrefly.lib.report.pysa.
pyrefly.lib.report.pysa.context uses pyrefly.lib.report.pysa, so a change to pyrefly.lib.report.pysa can break pyrefly.lib.report.pysa.context, while a change to pyrefly.lib.report.pysa.context can't break pyrefly.lib.report.pysa.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
18→28 pyrefly.lib.report.pysa.context uses pyrefly.lib.state.statepart of a loop✕
Connections
2 pairs of types, where a type in pyrefly.lib.report.pysa.context uses a type in pyrefly.lib.state.state.
pyrefly.lib.report.pysa.context uses pyrefly.lib.state.state, so a change to pyrefly.lib.state.state can break pyrefly.lib.report.pysa.context, while a change to pyrefly.lib.report.pysa.context can't break pyrefly.lib.state.state.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
18→29 pyrefly.lib.report.pysa.context uses pyrefly.lib.report.debug_infopart of a loop✕
Connections
2 pairs of types, where a type in pyrefly.lib.report.pysa.context uses a type in pyrefly.lib.report.debug_info.
pyrefly.lib.report.pysa.context uses pyrefly.lib.report.debug_info, so a change to pyrefly.lib.report.debug_info can break pyrefly.lib.report.pysa.context, while a change to pyrefly.lib.report.pysa.context can't break pyrefly.lib.report.debug_info.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
18→35 pyrefly.lib.report.pysa.context uses pyrefly.lib.binding.bindingspart of a loop✕
Connections
1 pair of types, where a type in pyrefly.lib.report.pysa.context uses a type in pyrefly.lib.binding.bindings.
pyrefly.lib.report.pysa.context uses pyrefly.lib.binding.bindings, so a change to pyrefly.lib.binding.bindings can break pyrefly.lib.report.pysa.context, while a change to pyrefly.lib.report.pysa.context can't break pyrefly.lib.binding.bindings.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
18→38 pyrefly.lib.report.pysa.context uses pyrefly.lib.alt.answerspart of a loop✕
Connections
1 pair of types, where a type in pyrefly.lib.report.pysa.context uses a type in pyrefly.lib.alt.answers.
pyrefly.lib.report.pysa.context uses pyrefly.lib.alt.answers, so a change to pyrefly.lib.alt.answers can break pyrefly.lib.report.pysa.context, while a change to pyrefly.lib.report.pysa.context can't break pyrefly.lib.alt.answers.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
pyrefly_types.class uses pyrefly_util.visit, so a change to pyrefly_util.visit can break pyrefly_types.class, while a change to pyrefly_types.class can't break pyrefly_util.visit.
Position
Below the diagonal: pyrefly_types.class uses a module listed above it, which is the healthy direction.
pyrefly_types.class uses pyrefly_python.module_name, so a change to pyrefly_python.module_name can break pyrefly_types.class, while a change to pyrefly_types.class can't break pyrefly_python.module_name.
Position
Below the diagonal: pyrefly_types.class uses a module listed above it, which is the healthy direction.
pyrefly_types.class uses pyrefly_python.module_path, so a change to pyrefly_python.module_path can break pyrefly_types.class, while a change to pyrefly_types.class can't break pyrefly_python.module_path.
Position
Below the diagonal: pyrefly_types.class uses a module listed above it, which is the healthy direction.
pyrefly_types.class uses pyrefly_python.module, so a change to pyrefly_python.module can break pyrefly_types.class, while a change to pyrefly_types.class can't break pyrefly_python.module.
Position
Below the diagonal: pyrefly_types.class uses a module listed above it, which is the healthy direction.
pyrefly_types.class uses pyrefly_python.qname, so a change to pyrefly_python.qname can break pyrefly_types.class, while a change to pyrefly_types.class can't break pyrefly_python.qname.
Position
Below the diagonal: pyrefly_types.class uses a module listed above it, which is the healthy direction.
pyrefly_types.class uses pyrefly_types.types, so a change to pyrefly_types.types can break pyrefly_types.class, while a change to pyrefly_types.class can't break pyrefly_types.types.
Position
Below the diagonal: pyrefly_types.class uses a module listed above it, which is the healthy direction.
pyrefly_types.class uses pyrefly_types.function, so a change to pyrefly_types.function can break pyrefly_types.class, while a change to pyrefly_types.class can't break pyrefly_types.function.
Position
Below the diagonal: pyrefly_types.class uses a module listed above it, which is the healthy direction.
pyrefly.lib.binding.scope uses pyrefly_python.sys_info, so a change to pyrefly_python.sys_info can break pyrefly.lib.binding.scope, while a change to pyrefly.lib.binding.scope can't break pyrefly_python.sys_info.
Position
Below the diagonal: pyrefly.lib.binding.scope uses a module listed above it, which is the healthy direction.
pyrefly.lib.binding.scope uses pyrefly_python.module_name, so a change to pyrefly_python.module_name can break pyrefly.lib.binding.scope, while a change to pyrefly.lib.binding.scope can't break pyrefly_python.module_name.
Position
Below the diagonal: pyrefly.lib.binding.scope uses a module listed above it, which is the healthy direction.
pyrefly.lib.binding.scope uses pyrefly_types.class, so a change to pyrefly_types.class can break pyrefly.lib.binding.scope, while a change to pyrefly.lib.binding.scope can't break pyrefly_types.class.
Position
Below the diagonal: pyrefly.lib.binding.scope uses a module listed above it, which is the healthy direction.
20→35 pyrefly.lib.binding.scope uses pyrefly.lib.binding.bindingspart of a loop✕
Connections
8 pairs of types, where a type in pyrefly.lib.binding.scope uses a type in pyrefly.lib.binding.bindings.
pyrefly.lib.binding.scope uses pyrefly.lib.binding.bindings, so a change to pyrefly.lib.binding.bindings can break pyrefly.lib.binding.scope, while a change to pyrefly.lib.binding.scope can't break pyrefly.lib.binding.bindings.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
20→36 pyrefly.lib.binding.scope uses pyrefly.lib.binding.bindingpart of a loop✕
Connections
11 pairs of types, where a type in pyrefly.lib.binding.scope uses a type in pyrefly.lib.binding.binding.
pyrefly.lib.binding.scope uses pyrefly.lib.binding.binding, so a change to pyrefly.lib.binding.binding can break pyrefly.lib.binding.scope, while a change to pyrefly.lib.binding.scope can't break pyrefly.lib.binding.binding.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
pyrefly_types.quantified uses pyrefly_util.visit, so a change to pyrefly_util.visit can break pyrefly_types.quantified, while a change to pyrefly_types.quantified can't break pyrefly_util.visit.
Position
Below the diagonal: pyrefly_types.quantified uses a module listed above it, which is the healthy direction.
pyrefly_types.quantified uses pyrefly_python.module_name, so a change to pyrefly_python.module_name can break pyrefly_types.quantified, while a change to pyrefly_types.quantified can't break pyrefly_python.module_name.
Position
Below the diagonal: pyrefly_types.quantified uses a module listed above it, which is the healthy direction.
pyrefly_types.quantified uses pyrefly_python.qname, so a change to pyrefly_python.qname can break pyrefly_types.quantified, while a change to pyrefly_types.quantified can't break pyrefly_python.qname.
Position
Below the diagonal: pyrefly_types.quantified uses a module listed above it, which is the healthy direction.
pyrefly_types.quantified uses pyrefly_types.stdlib, so a change to pyrefly_types.stdlib can break pyrefly_types.quantified, while a change to pyrefly_types.quantified can't break pyrefly_types.stdlib.
Position
Below the diagonal: pyrefly_types.quantified uses a module listed above it, which is the healthy direction.
pyrefly_types.quantified uses pyrefly_types.type_var, so a change to pyrefly_types.type_var can break pyrefly_types.quantified, while a change to pyrefly_types.quantified can't break pyrefly_types.type_var.
Position
Below the diagonal: pyrefly_types.quantified uses a module listed above it, which is the healthy direction.
pyrefly_types.quantified uses pyrefly_types.heap, so a change to pyrefly_types.heap can break pyrefly_types.quantified, while a change to pyrefly_types.quantified can't break pyrefly_types.heap.
Position
Below the diagonal: pyrefly_types.quantified uses a module listed above it, which is the healthy direction.
pyrefly_types.quantified uses pyrefly_types.types, so a change to pyrefly_types.types can break pyrefly_types.quantified, while a change to pyrefly_types.quantified can't break pyrefly_types.types.
Position
Below the diagonal: pyrefly_types.quantified uses a module listed above it, which is the healthy direction.
pyrefly_types.quantified uses pyrefly_types.class, so a change to pyrefly_types.class can break pyrefly_types.quantified, while a change to pyrefly_types.quantified can't break pyrefly_types.class.
Position
Below the diagonal: pyrefly_types.quantified uses a module listed above it, which is the healthy direction.
pyrefly_types.callable uses pyrefly_util.visit, so a change to pyrefly_util.visit can break pyrefly_types.callable, while a change to pyrefly_types.callable can't break pyrefly_util.visit.
Position
Below the diagonal: pyrefly_types.callable uses a module listed above it, which is the healthy direction.
pyrefly_types.callable uses pyrefly_types.types, so a change to pyrefly_types.types can break pyrefly_types.callable, while a change to pyrefly_types.callable can't break pyrefly_types.types.
Position
Below the diagonal: pyrefly_types.callable uses a module listed above it, which is the healthy direction.
pyrefly_types.callable uses pyrefly_types.quantified, so a change to pyrefly_types.quantified can break pyrefly_types.callable, while a change to pyrefly_types.callable can't break pyrefly_types.quantified.
Position
Below the diagonal: pyrefly_types.callable uses a module listed above it, which is the healthy direction.
pyrefly.lib.alt.class.class_field uses pyrefly_config.error_kind, so a change to pyrefly_config.error_kind can break pyrefly.lib.alt.class.class_field, while a change to pyrefly.lib.alt.class.class_field can't break pyrefly_config.error_kind.
Position
Below the diagonal: pyrefly.lib.alt.class.class_field uses a module listed above it, which is the healthy direction.
pyrefly.lib.alt.class.class_field uses pyrefly_types.heap, so a change to pyrefly_types.heap can break pyrefly.lib.alt.class.class_field, while a change to pyrefly.lib.alt.class.class_field can't break pyrefly_types.heap.
Position
Below the diagonal: pyrefly.lib.alt.class.class_field uses a module listed above it, which is the healthy direction.
pyrefly.lib.alt.class.class_field uses pyrefly_types.types, so a change to pyrefly_types.types can break pyrefly.lib.alt.class.class_field, while a change to pyrefly.lib.alt.class.class_field can't break pyrefly_types.types.
Position
Below the diagonal: pyrefly.lib.alt.class.class_field uses a module listed above it, which is the healthy direction.
pyrefly.lib.alt.class.class_field uses pyrefly_types.class, so a change to pyrefly_types.class can break pyrefly.lib.alt.class.class_field, while a change to pyrefly.lib.alt.class.class_field can't break pyrefly_types.class.
Position
Below the diagonal: pyrefly.lib.alt.class.class_field uses a module listed above it, which is the healthy direction.
pyrefly.lib.alt.class.class_field uses pyrefly_types.callable, so a change to pyrefly_types.callable can break pyrefly.lib.alt.class.class_field, while a change to pyrefly.lib.alt.class.class_field can't break pyrefly_types.callable.
Position
Below the diagonal: pyrefly.lib.alt.class.class_field uses a module listed above it, which is the healthy direction.
23→37 pyrefly.lib.alt.class.class_field uses pyrefly.lib.alt.answers_solverpart of a loop✕
Connections
2 pairs of types, where a type in pyrefly.lib.alt.class.class_field uses a type in pyrefly.lib.alt.answers_solver.
pyrefly.lib.alt.class.class_field uses pyrefly.lib.alt.answers_solver, so a change to pyrefly.lib.alt.answers_solver can break pyrefly.lib.alt.class.class_field, while a change to pyrefly.lib.alt.class.class_field can't break pyrefly.lib.alt.answers_solver.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
pyrefly.lib.report.pysa.call_graph uses pyrefly_python.module_name, so a change to pyrefly_python.module_name can break pyrefly.lib.report.pysa.call_graph, while a change to pyrefly.lib.report.pysa.call_graph can't break pyrefly_python.module_name.
Position
Below the diagonal: pyrefly.lib.report.pysa.call_graph uses a module listed above it, which is the healthy direction.
pyrefly.lib.report.pysa.call_graph uses pyrefly_types.types, so a change to pyrefly_types.types can break pyrefly.lib.report.pysa.call_graph, while a change to pyrefly.lib.report.pysa.call_graph can't break pyrefly_types.types.
Position
Below the diagonal: pyrefly.lib.report.pysa.call_graph uses a module listed above it, which is the healthy direction.
pyrefly.lib.report.pysa.call_graph uses pyrefly.lib.state.lsp, so a change to pyrefly.lib.state.lsp can break pyrefly.lib.report.pysa.call_graph, while a change to pyrefly.lib.report.pysa.call_graph can't break pyrefly.lib.state.lsp.
Position
Below the diagonal: pyrefly.lib.report.pysa.call_graph uses a module listed above it, which is the healthy direction.
pyrefly.lib.report.pysa.call_graph uses pyrefly.lib.report.pysa.context, so a change to pyrefly.lib.report.pysa.context can break pyrefly.lib.report.pysa.call_graph, while a change to pyrefly.lib.report.pysa.call_graph can't break pyrefly.lib.report.pysa.context.
Position
Below the diagonal: pyrefly.lib.report.pysa.call_graph uses a module listed above it, which is the healthy direction.
pyrefly.lib.report.pysa.call_graph uses pyrefly_types.class, so a change to pyrefly_types.class can break pyrefly.lib.report.pysa.call_graph, while a change to pyrefly.lib.report.pysa.call_graph can't break pyrefly_types.class.
Position
Below the diagonal: pyrefly.lib.report.pysa.call_graph uses a module listed above it, which is the healthy direction.
pyrefly.lib.report.pysa.call_graph uses pyrefly.lib.binding.scope, so a change to pyrefly.lib.binding.scope can break pyrefly.lib.report.pysa.call_graph, while a change to pyrefly.lib.report.pysa.call_graph can't break pyrefly.lib.binding.scope.
Position
Below the diagonal: pyrefly.lib.report.pysa.call_graph uses a module listed above it, which is the healthy direction.
pyrefly.lib.report.pysa.call_graph uses pyrefly_types.callable, so a change to pyrefly_types.callable can break pyrefly.lib.report.pysa.call_graph, while a change to pyrefly.lib.report.pysa.call_graph can't break pyrefly_types.callable.
Position
Below the diagonal: pyrefly.lib.report.pysa.call_graph uses a module listed above it, which is the healthy direction.
24→25 pyrefly.lib.report.pysa.call_graph uses pyrefly.lib.report.pysa.functionpart of a loop✕
Connections
3 pairs of types, where a type in pyrefly.lib.report.pysa.call_graph uses a type in pyrefly.lib.report.pysa.function.
pyrefly.lib.report.pysa.call_graph uses pyrefly.lib.report.pysa.function, so a change to pyrefly.lib.report.pysa.function can break pyrefly.lib.report.pysa.call_graph, while a change to pyrefly.lib.report.pysa.call_graph can't break pyrefly.lib.report.pysa.function.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
24→29 pyrefly.lib.report.pysa.call_graph uses pyrefly.lib.report.debug_infopart of a loop✕
Connections
1 pair of types, where a type in pyrefly.lib.report.pysa.call_graph uses a type in pyrefly.lib.report.debug_info.
pyrefly.lib.report.pysa.call_graph uses pyrefly.lib.report.debug_info, so a change to pyrefly.lib.report.debug_info can break pyrefly.lib.report.pysa.call_graph, while a change to pyrefly.lib.report.pysa.call_graph can't break pyrefly.lib.report.debug_info.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
24→32 pyrefly.lib.report.pysa.call_graph uses pyrefly.lib.error.collectorpart of a loop✕
Connections
1 pair of types, where a type in pyrefly.lib.report.pysa.call_graph uses a type in pyrefly.lib.error.collector.
pyrefly.lib.report.pysa.call_graph uses pyrefly.lib.error.collector, so a change to pyrefly.lib.error.collector can break pyrefly.lib.report.pysa.call_graph, while a change to pyrefly.lib.report.pysa.call_graph can't break pyrefly.lib.error.collector.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
pyrefly.lib.report.pysa.function uses pyrefly_python.module_name, so a change to pyrefly_python.module_name can break pyrefly.lib.report.pysa.function, while a change to pyrefly.lib.report.pysa.function can't break pyrefly_python.module_name.
Position
Below the diagonal: pyrefly.lib.report.pysa.function uses a module listed above it, which is the healthy direction.
pyrefly.lib.report.pysa.function uses pyrefly_types.types, so a change to pyrefly_types.types can break pyrefly.lib.report.pysa.function, while a change to pyrefly.lib.report.pysa.function can't break pyrefly_types.types.
Position
Below the diagonal: pyrefly.lib.report.pysa.function uses a module listed above it, which is the healthy direction.
pyrefly.lib.report.pysa.function uses pyrefly_types.function, so a change to pyrefly_types.function can break pyrefly.lib.report.pysa.function, while a change to pyrefly.lib.report.pysa.function can't break pyrefly_types.function.
Position
Below the diagonal: pyrefly.lib.report.pysa.function uses a module listed above it, which is the healthy direction.
pyrefly.lib.report.pysa.function uses pyrefly.lib.report.pysa.context, so a change to pyrefly.lib.report.pysa.context can break pyrefly.lib.report.pysa.function, while a change to pyrefly.lib.report.pysa.function can't break pyrefly.lib.report.pysa.context.
Position
Below the diagonal: pyrefly.lib.report.pysa.function uses a module listed above it, which is the healthy direction.
pyrefly.lib.report.pysa.function uses pyrefly_types.class, so a change to pyrefly_types.class can break pyrefly.lib.report.pysa.function, while a change to pyrefly.lib.report.pysa.function can't break pyrefly_types.class.
Position
Below the diagonal: pyrefly.lib.report.pysa.function uses a module listed above it, which is the healthy direction.
pyrefly.lib.report.pysa.function uses pyrefly_types.callable, so a change to pyrefly_types.callable can break pyrefly.lib.report.pysa.function, while a change to pyrefly.lib.report.pysa.function can't break pyrefly_types.callable.
Position
Below the diagonal: pyrefly.lib.report.pysa.function uses a module listed above it, which is the healthy direction.
pyrefly.lib.report.pysa.function uses pyrefly.lib.alt.class.class_field, so a change to pyrefly.lib.alt.class.class_field can break pyrefly.lib.report.pysa.function, while a change to pyrefly.lib.report.pysa.function can't break pyrefly.lib.alt.class.class_field.
Position
Below the diagonal: pyrefly.lib.report.pysa.function uses a module listed above it, which is the healthy direction.
pyrefly.lib.report.pysa.function uses pyrefly.lib.report.pysa.call_graph, so a change to pyrefly.lib.report.pysa.call_graph can break pyrefly.lib.report.pysa.function, while a change to pyrefly.lib.report.pysa.function can't break pyrefly.lib.report.pysa.call_graph.
Position
Below the diagonal: pyrefly.lib.report.pysa.function uses a module listed above it, which is the healthy direction.
25→36 pyrefly.lib.report.pysa.function uses pyrefly.lib.binding.bindingpart of a loop✕
Connections
1 pair of types, where a type in pyrefly.lib.report.pysa.function uses a type in pyrefly.lib.binding.binding.
pyrefly.lib.report.pysa.function uses pyrefly.lib.binding.binding, so a change to pyrefly.lib.binding.binding can break pyrefly.lib.report.pysa.function, while a change to pyrefly.lib.report.pysa.function can't break pyrefly.lib.binding.binding.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
pyrefly.lib.state.steps uses pyrefly_python.sys_info, so a change to pyrefly_python.sys_info can break pyrefly.lib.state.steps, while a change to pyrefly.lib.state.steps can't break pyrefly_python.sys_info.
Position
Below the diagonal: pyrefly.lib.state.steps uses a module listed above it, which is the healthy direction.
pyrefly.lib.state.steps uses pyrefly_python.module_name, so a change to pyrefly_python.module_name can break pyrefly.lib.state.steps, while a change to pyrefly.lib.state.steps can't break pyrefly_python.module_name.
Position
Below the diagonal: pyrefly.lib.state.steps uses a module listed above it, which is the healthy direction.
pyrefly.lib.state.steps uses pyrefly_python.module_path, so a change to pyrefly_python.module_path can break pyrefly.lib.state.steps, while a change to pyrefly.lib.state.steps can't break pyrefly_python.module_path.
Position
Below the diagonal: pyrefly.lib.state.steps uses a module listed above it, which is the healthy direction.
pyrefly.lib.state.steps uses pyrefly_build.handle, so a change to pyrefly_build.handle can break pyrefly.lib.state.steps, while a change to pyrefly.lib.state.steps can't break pyrefly_build.handle.
Position
Below the diagonal: pyrefly.lib.state.steps uses a module listed above it, which is the healthy direction.
pyrefly.lib.state.steps uses pyrefly_types.stdlib, so a change to pyrefly_types.stdlib can break pyrefly.lib.state.steps, while a change to pyrefly.lib.state.steps can't break pyrefly_types.stdlib.
Position
Below the diagonal: pyrefly.lib.state.steps uses a module listed above it, which is the healthy direction.
pyrefly.lib.state.steps uses pyrefly.lib.report.pysa.call_graph, so a change to pyrefly.lib.report.pysa.call_graph can break pyrefly.lib.state.steps, while a change to pyrefly.lib.state.steps can't break pyrefly.lib.report.pysa.call_graph.
Position
Below the diagonal: pyrefly.lib.state.steps uses a module listed above it, which is the healthy direction.
26→28 pyrefly.lib.state.steps uses pyrefly.lib.state.statepart of a loop✕
Connections
2 pairs of types, where a type in pyrefly.lib.state.steps uses a type in pyrefly.lib.state.state.
pyrefly.lib.state.steps uses pyrefly.lib.state.state, so a change to pyrefly.lib.state.state can break pyrefly.lib.state.steps, while a change to pyrefly.lib.state.steps can't break pyrefly.lib.state.state.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
26→32 pyrefly.lib.state.steps uses pyrefly.lib.error.collectorpart of a loop✕
Connections
1 pair of types, where a type in pyrefly.lib.state.steps uses a type in pyrefly.lib.error.collector.
pyrefly.lib.state.steps uses pyrefly.lib.error.collector, so a change to pyrefly.lib.error.collector can break pyrefly.lib.state.steps, while a change to pyrefly.lib.state.steps can't break pyrefly.lib.error.collector.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
26→38 pyrefly.lib.state.steps uses pyrefly.lib.alt.answerspart of a loop✕
Connections
6 pairs of types, where a type in pyrefly.lib.state.steps uses a type in pyrefly.lib.alt.answers.
pyrefly.lib.state.steps uses pyrefly.lib.alt.answers, so a change to pyrefly.lib.alt.answers can break pyrefly.lib.state.steps, while a change to pyrefly.lib.state.steps can't break pyrefly.lib.alt.answers.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
pyrefly.lib.report.pysa uses pyrefly_config.error_kind, so a change to pyrefly_config.error_kind can break pyrefly.lib.report.pysa, while a change to pyrefly.lib.report.pysa can't break pyrefly_config.error_kind.
Position
Below the diagonal: pyrefly.lib.report.pysa uses a module listed above it, which is the healthy direction.
pyrefly.lib.report.pysa uses pyrefly_python.sys_info, so a change to pyrefly_python.sys_info can break pyrefly.lib.report.pysa, while a change to pyrefly.lib.report.pysa can't break pyrefly_python.sys_info.
Position
Below the diagonal: pyrefly.lib.report.pysa uses a module listed above it, which is the healthy direction.
pyrefly.lib.report.pysa uses pyrefly_python.module_name, so a change to pyrefly_python.module_name can break pyrefly.lib.report.pysa, while a change to pyrefly.lib.report.pysa can't break pyrefly_python.module_name.
Position
Below the diagonal: pyrefly.lib.report.pysa uses a module listed above it, which is the healthy direction.
pyrefly.lib.report.pysa uses pyrefly_python.module_path, so a change to pyrefly_python.module_path can break pyrefly.lib.report.pysa, while a change to pyrefly.lib.report.pysa can't break pyrefly_python.module_path.
Position
Below the diagonal: pyrefly.lib.report.pysa uses a module listed above it, which is the healthy direction.
pyrefly.lib.report.pysa uses pyrefly_build.handle, so a change to pyrefly_build.handle can break pyrefly.lib.report.pysa, while a change to pyrefly.lib.report.pysa can't break pyrefly_build.handle.
Position
Below the diagonal: pyrefly.lib.report.pysa uses a module listed above it, which is the healthy direction.
pyrefly.lib.report.pysa uses pyrefly.lib.report.pysa.context, so a change to pyrefly.lib.report.pysa.context can break pyrefly.lib.report.pysa, while a change to pyrefly.lib.report.pysa can't break pyrefly.lib.report.pysa.context.
Position
Below the diagonal: pyrefly.lib.report.pysa uses a module listed above it, which is the healthy direction.
pyrefly.lib.report.pysa uses pyrefly.lib.report.pysa.function, so a change to pyrefly.lib.report.pysa.function can break pyrefly.lib.report.pysa, while a change to pyrefly.lib.report.pysa can't break pyrefly.lib.report.pysa.function.
Position
Below the diagonal: pyrefly.lib.report.pysa uses a module listed above it, which is the healthy direction.
27→28 pyrefly.lib.report.pysa uses pyrefly.lib.state.statepart of a loop✕
Connections
2 pairs of types, where a type in pyrefly.lib.report.pysa uses a type in pyrefly.lib.state.state.
pyrefly.lib.report.pysa uses pyrefly.lib.state.state, so a change to pyrefly.lib.state.state can break pyrefly.lib.report.pysa, while a change to pyrefly.lib.report.pysa can't break pyrefly.lib.state.state.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
pyrefly.lib.state.state uses pyrefly_python.sys_info, so a change to pyrefly_python.sys_info can break pyrefly.lib.state.state, while a change to pyrefly.lib.state.state can't break pyrefly_python.sys_info.
Position
Below the diagonal: pyrefly.lib.state.state uses a module listed above it, which is the healthy direction.
pyrefly.lib.state.state uses pyrefly_util.arc_id, so a change to pyrefly_util.arc_id can break pyrefly.lib.state.state, while a change to pyrefly.lib.state.state can't break pyrefly_util.arc_id.
Position
Below the diagonal: pyrefly.lib.state.state uses a module listed above it, which is the healthy direction.
pyrefly.lib.state.state uses pyrefly_python.module_name, so a change to pyrefly_python.module_name can break pyrefly.lib.state.state, while a change to pyrefly.lib.state.state can't break pyrefly_python.module_name.
Position
Below the diagonal: pyrefly.lib.state.state uses a module listed above it, which is the healthy direction.
pyrefly.lib.state.state uses pyrefly_python.module_path, so a change to pyrefly_python.module_path can break pyrefly.lib.state.state, while a change to pyrefly.lib.state.state can't break pyrefly_python.module_path.
Position
Below the diagonal: pyrefly.lib.state.state uses a module listed above it, which is the healthy direction.
pyrefly.lib.state.state uses pyrefly_build.handle, so a change to pyrefly_build.handle can break pyrefly.lib.state.state, while a change to pyrefly.lib.state.state can't break pyrefly_build.handle.
Position
Below the diagonal: pyrefly.lib.state.state uses a module listed above it, which is the healthy direction.
pyrefly.lib.state.state uses pyrefly_python.module, so a change to pyrefly_python.module can break pyrefly.lib.state.state, while a change to pyrefly.lib.state.state can't break pyrefly_python.module.
Position
Below the diagonal: pyrefly.lib.state.state uses a module listed above it, which is the healthy direction.
pyrefly.lib.state.state uses pyrefly_types.stdlib, so a change to pyrefly_types.stdlib can break pyrefly.lib.state.state, while a change to pyrefly.lib.state.state can't break pyrefly_types.stdlib.
Position
Below the diagonal: pyrefly.lib.state.state uses a module listed above it, which is the healthy direction.
pyrefly.lib.state.state uses pyrefly_types.types, so a change to pyrefly_types.types can break pyrefly.lib.state.state, while a change to pyrefly.lib.state.state can't break pyrefly_types.types.
Position
Below the diagonal: pyrefly.lib.state.state uses a module listed above it, which is the healthy direction.
pyrefly.lib.state.state uses pyrefly.lib.state.lsp, so a change to pyrefly.lib.state.lsp can break pyrefly.lib.state.state, while a change to pyrefly.lib.state.state can't break pyrefly.lib.state.lsp.
Position
Below the diagonal: pyrefly.lib.state.state uses a module listed above it, which is the healthy direction.
pyrefly.lib.state.state uses pyrefly_types.function, so a change to pyrefly_types.function can break pyrefly.lib.state.state, while a change to pyrefly.lib.state.state can't break pyrefly_types.function.
Position
Below the diagonal: pyrefly.lib.state.state uses a module listed above it, which is the healthy direction.
pyrefly.lib.state.state uses pyrefly_types.class, so a change to pyrefly_types.class can break pyrefly.lib.state.state, while a change to pyrefly.lib.state.state can't break pyrefly_types.class.
Position
Below the diagonal: pyrefly.lib.state.state uses a module listed above it, which is the healthy direction.
pyrefly.lib.state.state uses pyrefly_types.callable, so a change to pyrefly_types.callable can break pyrefly.lib.state.state, while a change to pyrefly.lib.state.state can't break pyrefly_types.callable.
Position
Below the diagonal: pyrefly.lib.state.state uses a module listed above it, which is the healthy direction.
pyrefly.lib.state.state uses pyrefly.lib.state.steps, so a change to pyrefly.lib.state.steps can break pyrefly.lib.state.state, while a change to pyrefly.lib.state.state can't break pyrefly.lib.state.steps.
Position
Below the diagonal: pyrefly.lib.state.state uses a module listed above it, which is the healthy direction.
pyrefly.lib.state.state uses pyrefly.lib.report.pysa, so a change to pyrefly.lib.report.pysa can break pyrefly.lib.state.state, while a change to pyrefly.lib.state.state can't break pyrefly.lib.report.pysa.
Position
Below the diagonal: pyrefly.lib.state.state uses a module listed above it, which is the healthy direction.
28→29 pyrefly.lib.state.state uses pyrefly.lib.report.debug_infopart of a loop✕
Connections
2 pairs of types, where a type in pyrefly.lib.state.state uses a type in pyrefly.lib.report.debug_info.
pyrefly.lib.state.state uses pyrefly.lib.report.debug_info, so a change to pyrefly.lib.report.debug_info can break pyrefly.lib.state.state, while a change to pyrefly.lib.state.state can't break pyrefly.lib.report.debug_info.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
28→35 pyrefly.lib.state.state uses pyrefly.lib.binding.bindingspart of a loop✕
Connections
1 pair of types, where a type in pyrefly.lib.state.state uses a type in pyrefly.lib.binding.bindings.
pyrefly.lib.state.state uses pyrefly.lib.binding.bindings, so a change to pyrefly.lib.binding.bindings can break pyrefly.lib.state.state, while a change to pyrefly.lib.state.state can't break pyrefly.lib.binding.bindings.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
28→36 pyrefly.lib.state.state uses pyrefly.lib.binding.bindingpart of a loop✕
Connections
4 pairs of types, where a type in pyrefly.lib.state.state uses a type in pyrefly.lib.binding.binding.
pyrefly.lib.state.state uses pyrefly.lib.binding.binding, so a change to pyrefly.lib.binding.binding can break pyrefly.lib.state.state, while a change to pyrefly.lib.state.state can't break pyrefly.lib.binding.binding.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
28→37 pyrefly.lib.state.state uses pyrefly.lib.alt.answers_solverpart of a loop✕
Connections
9 pairs of types, where a type in pyrefly.lib.state.state uses a type in pyrefly.lib.alt.answers_solver.
pyrefly.lib.state.state uses pyrefly.lib.alt.answers_solver, so a change to pyrefly.lib.alt.answers_solver can break pyrefly.lib.state.state, while a change to pyrefly.lib.state.state can't break pyrefly.lib.alt.answers_solver.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
28→38 pyrefly.lib.state.state uses pyrefly.lib.alt.answerspart of a loop✕
Connections
10 pairs of types, where a type in pyrefly.lib.state.state uses a type in pyrefly.lib.alt.answers.
pyrefly.lib.state.state uses pyrefly.lib.alt.answers, so a change to pyrefly.lib.alt.answers can break pyrefly.lib.state.state, while a change to pyrefly.lib.state.state can't break pyrefly.lib.alt.answers.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
pyrefly.lib.report.debug_info uses pyrefly.lib.state.state, so a change to pyrefly.lib.state.state can break pyrefly.lib.report.debug_info, while a change to pyrefly.lib.report.debug_info can't break pyrefly.lib.state.state.
Position
Below the diagonal: pyrefly.lib.report.debug_info uses a module listed above it, which is the healthy direction.
29→30 pyrefly.lib.report.debug_info uses pyrefly.lib.error.errorpart of a loop✕
Connections
1 pair of types, where a type in pyrefly.lib.report.debug_info uses a type in pyrefly.lib.error.error.
pyrefly.lib.report.debug_info uses pyrefly.lib.error.error, so a change to pyrefly.lib.error.error can break pyrefly.lib.report.debug_info, while a change to pyrefly.lib.report.debug_info can't break pyrefly.lib.error.error.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
29→32 pyrefly.lib.report.debug_info uses pyrefly.lib.error.collectorpart of a loop✕
Connections
1 pair of types, where a type in pyrefly.lib.report.debug_info uses a type in pyrefly.lib.error.collector.
pyrefly.lib.report.debug_info uses pyrefly.lib.error.collector, so a change to pyrefly.lib.error.collector can break pyrefly.lib.report.debug_info, while a change to pyrefly.lib.report.debug_info can't break pyrefly.lib.error.collector.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
29→36 pyrefly.lib.report.debug_info uses pyrefly.lib.binding.bindingpart of a loop✕
Connections
1 pair of types, where a type in pyrefly.lib.report.debug_info uses a type in pyrefly.lib.binding.binding.
pyrefly.lib.report.debug_info uses pyrefly.lib.binding.binding, so a change to pyrefly.lib.binding.binding can break pyrefly.lib.report.debug_info, while a change to pyrefly.lib.report.debug_info can't break pyrefly.lib.binding.binding.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
pyrefly.lib.error.error uses pyrefly_config.error_kind, so a change to pyrefly_config.error_kind can break pyrefly.lib.error.error, while a change to pyrefly.lib.error.error can't break pyrefly_config.error_kind.
Position
Below the diagonal: pyrefly.lib.error.error uses a module listed above it, which is the healthy direction.
pyrefly.lib.error.error uses pyrefly_python.module_path, so a change to pyrefly_python.module_path can break pyrefly.lib.error.error, while a change to pyrefly.lib.error.error can't break pyrefly_python.module_path.
Position
Below the diagonal: pyrefly.lib.error.error uses a module listed above it, which is the healthy direction.
pyrefly.lib.error.error uses pyrefly.lib.state.lsp, so a change to pyrefly.lib.state.lsp can break pyrefly.lib.error.error, while a change to pyrefly.lib.error.error can't break pyrefly.lib.state.lsp.
Position
Below the diagonal: pyrefly.lib.error.error uses a module listed above it, which is the healthy direction.
pyrefly.lib.error.error uses pyrefly.lib.report.debug_info, so a change to pyrefly.lib.report.debug_info can break pyrefly.lib.error.error, while a change to pyrefly.lib.error.error can't break pyrefly.lib.report.debug_info.
Position
Below the diagonal: pyrefly.lib.error.error uses a module listed above it, which is the healthy direction.
pyrefly.lib.commands.check uses pyrefly_config.error_kind, so a change to pyrefly_config.error_kind can break pyrefly.lib.commands.check, while a change to pyrefly.lib.commands.check can't break pyrefly_config.error_kind.
Position
Below the diagonal: pyrefly.lib.commands.check uses a module listed above it, which is the healthy direction.
pyrefly.lib.commands.check uses pyrefly_build.handle, so a change to pyrefly_build.handle can break pyrefly.lib.commands.check, while a change to pyrefly.lib.commands.check can't break pyrefly_build.handle.
Position
Below the diagonal: pyrefly.lib.commands.check uses a module listed above it, which is the healthy direction.
pyrefly.lib.commands.check uses pyrefly_config.config, so a change to pyrefly_config.config can break pyrefly.lib.commands.check, while a change to pyrefly.lib.commands.check can't break pyrefly_config.config.
Position
Below the diagonal: pyrefly.lib.commands.check uses a module listed above it, which is the healthy direction.
pyrefly.lib.commands.check uses pyrefly.lib.report.pysa, so a change to pyrefly.lib.report.pysa can break pyrefly.lib.commands.check, while a change to pyrefly.lib.commands.check can't break pyrefly.lib.report.pysa.
Position
Below the diagonal: pyrefly.lib.commands.check uses a module listed above it, which is the healthy direction.
pyrefly.lib.commands.check uses pyrefly.lib.state.state, so a change to pyrefly.lib.state.state can break pyrefly.lib.commands.check, while a change to pyrefly.lib.commands.check can't break pyrefly.lib.state.state.
Position
Below the diagonal: pyrefly.lib.commands.check uses a module listed above it, which is the healthy direction.
pyrefly.lib.commands.check uses pyrefly.lib.error.error, so a change to pyrefly.lib.error.error can break pyrefly.lib.commands.check, while a change to pyrefly.lib.commands.check can't break pyrefly.lib.error.error.
Position
Below the diagonal: pyrefly.lib.commands.check uses a module listed above it, which is the healthy direction.
pyrefly.lib.error.collector uses pyrefly_config.error_kind, so a change to pyrefly_config.error_kind can break pyrefly.lib.error.collector, while a change to pyrefly.lib.error.collector can't break pyrefly_config.error_kind.
Position
Below the diagonal: pyrefly.lib.error.collector uses a module listed above it, which is the healthy direction.
pyrefly.lib.error.collector uses pyrefly.lib.error.error, so a change to pyrefly.lib.error.error can break pyrefly.lib.error.collector, while a change to pyrefly.lib.error.collector can't break pyrefly.lib.error.error.
Position
Below the diagonal: pyrefly.lib.error.collector uses a module listed above it, which is the healthy direction.
pyrefly.lib.lsp.non_wasm.server uses pyrefly_config.error_kind, so a change to pyrefly_config.error_kind can break pyrefly.lib.lsp.non_wasm.server, while a change to pyrefly.lib.lsp.non_wasm.server can't break pyrefly_config.error_kind.
Position
Below the diagonal: pyrefly.lib.lsp.non_wasm.server uses a module listed above it, which is the healthy direction.
pyrefly.lib.lsp.non_wasm.server uses pyrefly_python.sys_info, so a change to pyrefly_python.sys_info can break pyrefly.lib.lsp.non_wasm.server, while a change to pyrefly.lib.lsp.non_wasm.server can't break pyrefly_python.sys_info.
Position
Below the diagonal: pyrefly.lib.lsp.non_wasm.server uses a module listed above it, which is the healthy direction.
pyrefly.lib.lsp.non_wasm.server uses pyrefly_util.arc_id, so a change to pyrefly_util.arc_id can break pyrefly.lib.lsp.non_wasm.server, while a change to pyrefly.lib.lsp.non_wasm.server can't break pyrefly_util.arc_id.
Position
Below the diagonal: pyrefly.lib.lsp.non_wasm.server uses a module listed above it, which is the healthy direction.
pyrefly.lib.lsp.non_wasm.server uses pyrefly_python.module_name, so a change to pyrefly_python.module_name can break pyrefly.lib.lsp.non_wasm.server, while a change to pyrefly.lib.lsp.non_wasm.server can't break pyrefly_python.module_name.
Position
Below the diagonal: pyrefly.lib.lsp.non_wasm.server uses a module listed above it, which is the healthy direction.
pyrefly.lib.lsp.non_wasm.server uses pyrefly_python.module_path, so a change to pyrefly_python.module_path can break pyrefly.lib.lsp.non_wasm.server, while a change to pyrefly.lib.lsp.non_wasm.server can't break pyrefly_python.module_path.
Position
Below the diagonal: pyrefly.lib.lsp.non_wasm.server uses a module listed above it, which is the healthy direction.
pyrefly.lib.lsp.non_wasm.server uses pyrefly_build.handle, so a change to pyrefly_build.handle can break pyrefly.lib.lsp.non_wasm.server, while a change to pyrefly.lib.lsp.non_wasm.server can't break pyrefly_build.handle.
Position
Below the diagonal: pyrefly.lib.lsp.non_wasm.server uses a module listed above it, which is the healthy direction.
pyrefly.lib.lsp.non_wasm.server uses pyrefly_python.module, so a change to pyrefly_python.module can break pyrefly.lib.lsp.non_wasm.server, while a change to pyrefly.lib.lsp.non_wasm.server can't break pyrefly_python.module.
Position
Below the diagonal: pyrefly.lib.lsp.non_wasm.server uses a module listed above it, which is the healthy direction.
pyrefly.lib.lsp.non_wasm.server uses pyrefly_types.types, so a change to pyrefly_types.types can break pyrefly.lib.lsp.non_wasm.server, while a change to pyrefly.lib.lsp.non_wasm.server can't break pyrefly_types.types.
Position
Below the diagonal: pyrefly.lib.lsp.non_wasm.server uses a module listed above it, which is the healthy direction.
pyrefly.lib.lsp.non_wasm.server uses pyrefly.lib.state.lsp, so a change to pyrefly.lib.state.lsp can break pyrefly.lib.lsp.non_wasm.server, while a change to pyrefly.lib.lsp.non_wasm.server can't break pyrefly.lib.state.lsp.
Position
Below the diagonal: pyrefly.lib.lsp.non_wasm.server uses a module listed above it, which is the healthy direction.
pyrefly.lib.lsp.non_wasm.server uses pyrefly_types.class, so a change to pyrefly_types.class can break pyrefly.lib.lsp.non_wasm.server, while a change to pyrefly.lib.lsp.non_wasm.server can't break pyrefly_types.class.
Position
Below the diagonal: pyrefly.lib.lsp.non_wasm.server uses a module listed above it, which is the healthy direction.
pyrefly.lib.lsp.non_wasm.server uses pyrefly_types.callable, so a change to pyrefly_types.callable can break pyrefly.lib.lsp.non_wasm.server, while a change to pyrefly.lib.lsp.non_wasm.server can't break pyrefly_types.callable.
Position
Below the diagonal: pyrefly.lib.lsp.non_wasm.server uses a module listed above it, which is the healthy direction.
pyrefly.lib.lsp.non_wasm.server uses pyrefly.lib.state.state, so a change to pyrefly.lib.state.state can break pyrefly.lib.lsp.non_wasm.server, while a change to pyrefly.lib.lsp.non_wasm.server can't break pyrefly.lib.state.state.
Position
Below the diagonal: pyrefly.lib.lsp.non_wasm.server uses a module listed above it, which is the healthy direction.
pyrefly.lib.lsp.non_wasm.server uses pyrefly.lib.error.error, so a change to pyrefly.lib.error.error can break pyrefly.lib.lsp.non_wasm.server, while a change to pyrefly.lib.lsp.non_wasm.server can't break pyrefly.lib.error.error.
Position
Below the diagonal: pyrefly.lib.lsp.non_wasm.server uses a module listed above it, which is the healthy direction.
pyrefly.lib.lsp.non_wasm.server uses pyrefly.lib.error.collector, so a change to pyrefly.lib.error.collector can break pyrefly.lib.lsp.non_wasm.server, while a change to pyrefly.lib.lsp.non_wasm.server can't break pyrefly.lib.error.collector.
Position
Below the diagonal: pyrefly.lib.lsp.non_wasm.server uses a module listed above it, which is the healthy direction.
pyrefly.lib.solver.solver uses pyrefly_config.error_kind, so a change to pyrefly_config.error_kind can break pyrefly.lib.solver.solver, while a change to pyrefly.lib.solver.solver can't break pyrefly_config.error_kind.
Position
Below the diagonal: pyrefly.lib.solver.solver uses a module listed above it, which is the healthy direction.
pyrefly.lib.solver.solver uses pyrefly_types.type_var, so a change to pyrefly_types.type_var can break pyrefly.lib.solver.solver, while a change to pyrefly.lib.solver.solver can't break pyrefly_types.type_var.
Position
Below the diagonal: pyrefly.lib.solver.solver uses a module listed above it, which is the healthy direction.
pyrefly.lib.solver.solver uses pyrefly_types.heap, so a change to pyrefly_types.heap can break pyrefly.lib.solver.solver, while a change to pyrefly.lib.solver.solver can't break pyrefly_types.heap.
Position
Below the diagonal: pyrefly.lib.solver.solver uses a module listed above it, which is the healthy direction.
pyrefly.lib.solver.solver uses pyrefly_types.types, so a change to pyrefly_types.types can break pyrefly.lib.solver.solver, while a change to pyrefly.lib.solver.solver can't break pyrefly_types.types.
Position
Below the diagonal: pyrefly.lib.solver.solver uses a module listed above it, which is the healthy direction.
pyrefly.lib.solver.solver uses pyrefly_types.class, so a change to pyrefly_types.class can break pyrefly.lib.solver.solver, while a change to pyrefly.lib.solver.solver can't break pyrefly_types.class.
Position
Below the diagonal: pyrefly.lib.solver.solver uses a module listed above it, which is the healthy direction.
pyrefly.lib.solver.solver uses pyrefly_types.quantified, so a change to pyrefly_types.quantified can break pyrefly.lib.solver.solver, while a change to pyrefly.lib.solver.solver can't break pyrefly_types.quantified.
Position
Below the diagonal: pyrefly.lib.solver.solver uses a module listed above it, which is the healthy direction.
pyrefly.lib.solver.solver uses pyrefly_types.callable, so a change to pyrefly_types.callable can break pyrefly.lib.solver.solver, while a change to pyrefly.lib.solver.solver can't break pyrefly_types.callable.
Position
Below the diagonal: pyrefly.lib.solver.solver uses a module listed above it, which is the healthy direction.
pyrefly.lib.solver.solver uses pyrefly.lib.error.collector, so a change to pyrefly.lib.error.collector can break pyrefly.lib.solver.solver, while a change to pyrefly.lib.solver.solver can't break pyrefly.lib.error.collector.
Position
Below the diagonal: pyrefly.lib.solver.solver uses a module listed above it, which is the healthy direction.
34→37 pyrefly.lib.solver.solver uses pyrefly.lib.alt.answers_solverpart of a loop✕
Connections
1 pair of types, where a type in pyrefly.lib.solver.solver uses a type in pyrefly.lib.alt.answers_solver.
pyrefly.lib.solver.solver uses pyrefly.lib.alt.answers_solver, so a change to pyrefly.lib.alt.answers_solver can break pyrefly.lib.solver.solver, while a change to pyrefly.lib.solver.solver can't break pyrefly.lib.alt.answers_solver.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
pyrefly.lib.binding.bindings uses pyrefly_config.error_kind, so a change to pyrefly_config.error_kind can break pyrefly.lib.binding.bindings, while a change to pyrefly.lib.binding.bindings can't break pyrefly_config.error_kind.
Position
Below the diagonal: pyrefly.lib.binding.bindings uses a module listed above it, which is the healthy direction.
pyrefly.lib.binding.bindings uses pyrefly_python.sys_info, so a change to pyrefly_python.sys_info can break pyrefly.lib.binding.bindings, while a change to pyrefly.lib.binding.bindings can't break pyrefly_python.sys_info.
Position
Below the diagonal: pyrefly.lib.binding.bindings uses a module listed above it, which is the healthy direction.
pyrefly.lib.binding.bindings uses pyrefly_python.module_name, so a change to pyrefly_python.module_name can break pyrefly.lib.binding.bindings, while a change to pyrefly.lib.binding.bindings can't break pyrefly_python.module_name.
Position
Below the diagonal: pyrefly.lib.binding.bindings uses a module listed above it, which is the healthy direction.
pyrefly.lib.binding.bindings uses pyrefly_types.function, so a change to pyrefly_types.function can break pyrefly.lib.binding.bindings, while a change to pyrefly.lib.binding.bindings can't break pyrefly_types.function.
Position
Below the diagonal: pyrefly.lib.binding.bindings uses a module listed above it, which is the healthy direction.
pyrefly.lib.binding.bindings uses pyrefly_types.class, so a change to pyrefly_types.class can break pyrefly.lib.binding.bindings, while a change to pyrefly.lib.binding.bindings can't break pyrefly_types.class.
Position
Below the diagonal: pyrefly.lib.binding.bindings uses a module listed above it, which is the healthy direction.
pyrefly.lib.binding.bindings uses pyrefly.lib.binding.scope, so a change to pyrefly.lib.binding.scope can break pyrefly.lib.binding.bindings, while a change to pyrefly.lib.binding.bindings can't break pyrefly.lib.binding.scope.
Position
Below the diagonal: pyrefly.lib.binding.bindings uses a module listed above it, which is the healthy direction.
pyrefly.lib.binding.bindings uses pyrefly_types.quantified, so a change to pyrefly_types.quantified can break pyrefly.lib.binding.bindings, while a change to pyrefly.lib.binding.bindings can't break pyrefly_types.quantified.
Position
Below the diagonal: pyrefly.lib.binding.bindings uses a module listed above it, which is the healthy direction.
pyrefly.lib.binding.bindings uses pyrefly.lib.error.collector, so a change to pyrefly.lib.error.collector can break pyrefly.lib.binding.bindings, while a change to pyrefly.lib.binding.bindings can't break pyrefly.lib.error.collector.
Position
Below the diagonal: pyrefly.lib.binding.bindings uses a module listed above it, which is the healthy direction.
pyrefly.lib.binding.bindings uses pyrefly.lib.solver.solver, so a change to pyrefly.lib.solver.solver can break pyrefly.lib.binding.bindings, while a change to pyrefly.lib.binding.bindings can't break pyrefly.lib.solver.solver.
Position
Below the diagonal: pyrefly.lib.binding.bindings uses a module listed above it, which is the healthy direction.
35→36 pyrefly.lib.binding.bindings uses pyrefly.lib.binding.bindingpart of a loop✕
Connections
24 pairs of types, where a type in pyrefly.lib.binding.bindings uses a type in pyrefly.lib.binding.binding.
pyrefly.lib.binding.bindings uses pyrefly.lib.binding.binding, so a change to pyrefly.lib.binding.binding can break pyrefly.lib.binding.bindings, while a change to pyrefly.lib.binding.bindings can't break pyrefly.lib.binding.binding.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
pyrefly.lib.binding.binding uses pyrefly_python.sys_info, so a change to pyrefly_python.sys_info can break pyrefly.lib.binding.binding, while a change to pyrefly.lib.binding.binding can't break pyrefly_python.sys_info.
Position
Below the diagonal: pyrefly.lib.binding.binding uses a module listed above it, which is the healthy direction.
pyrefly.lib.binding.binding uses pyrefly_python.module_name, so a change to pyrefly_python.module_name can break pyrefly.lib.binding.binding, while a change to pyrefly.lib.binding.binding can't break pyrefly_python.module_name.
Position
Below the diagonal: pyrefly.lib.binding.binding uses a module listed above it, which is the healthy direction.
pyrefly.lib.binding.binding uses pyrefly_types.stdlib, so a change to pyrefly_types.stdlib can break pyrefly.lib.binding.binding, while a change to pyrefly.lib.binding.binding can't break pyrefly_types.stdlib.
Position
Below the diagonal: pyrefly.lib.binding.binding uses a module listed above it, which is the healthy direction.
26 pairs of types, where a type in pyrefly.lib.binding.binding uses a type in pyrefly_types.heap. Showing 25 of them; the rest are in namespace-graph.json in this report's bundle.
pyrefly.lib.binding.binding uses pyrefly_types.heap, so a change to pyrefly_types.heap can break pyrefly.lib.binding.binding, while a change to pyrefly.lib.binding.binding can't break pyrefly_types.heap.
Position
Below the diagonal: pyrefly.lib.binding.binding uses a module listed above it, which is the healthy direction.
26 pairs of types, where a type in pyrefly.lib.binding.binding uses a type in pyrefly_types.types. Showing 25 of them; the rest are in namespace-graph.json in this report's bundle.
pyrefly.lib.binding.binding uses pyrefly_types.types, so a change to pyrefly_types.types can break pyrefly.lib.binding.binding, while a change to pyrefly.lib.binding.binding can't break pyrefly_types.types.
Position
Below the diagonal: pyrefly.lib.binding.binding uses a module listed above it, which is the healthy direction.
pyrefly.lib.binding.binding uses pyrefly_types.function, so a change to pyrefly_types.function can break pyrefly.lib.binding.binding, while a change to pyrefly.lib.binding.binding can't break pyrefly_types.function.
Position
Below the diagonal: pyrefly.lib.binding.binding uses a module listed above it, which is the healthy direction.
pyrefly.lib.binding.binding uses pyrefly_types.class, so a change to pyrefly_types.class can break pyrefly.lib.binding.binding, while a change to pyrefly.lib.binding.binding can't break pyrefly_types.class.
Position
Below the diagonal: pyrefly.lib.binding.binding uses a module listed above it, which is the healthy direction.
pyrefly.lib.binding.binding uses pyrefly_types.quantified, so a change to pyrefly_types.quantified can break pyrefly.lib.binding.binding, while a change to pyrefly.lib.binding.binding can't break pyrefly_types.quantified.
Position
Below the diagonal: pyrefly.lib.binding.binding uses a module listed above it, which is the healthy direction.
pyrefly.lib.binding.binding uses pyrefly.lib.error.collector, so a change to pyrefly.lib.error.collector can break pyrefly.lib.binding.binding, while a change to pyrefly.lib.binding.binding can't break pyrefly.lib.error.collector.
Position
Below the diagonal: pyrefly.lib.binding.binding uses a module listed above it, which is the healthy direction.
54 pairs of types, where a type in pyrefly.lib.binding.binding uses a type in pyrefly.lib.binding.bindings. Showing 25 of them; the rest are in namespace-graph.json in this report's bundle.
pyrefly.lib.binding.binding uses pyrefly.lib.binding.bindings, so a change to pyrefly.lib.binding.bindings can break pyrefly.lib.binding.binding, while a change to pyrefly.lib.binding.binding can't break pyrefly.lib.binding.bindings.
Position
Below the diagonal: pyrefly.lib.binding.binding uses a module listed above it, which is the healthy direction.
36→37 pyrefly.lib.binding.binding uses pyrefly.lib.alt.answers_solverpart of a loop✕
Connections
25 pairs of types, where a type in pyrefly.lib.binding.binding uses a type in pyrefly.lib.alt.answers_solver.
pyrefly.lib.binding.binding uses pyrefly.lib.alt.answers_solver, so a change to pyrefly.lib.alt.answers_solver can break pyrefly.lib.binding.binding, while a change to pyrefly.lib.binding.binding can't break pyrefly.lib.alt.answers_solver.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
pyrefly.lib.alt.answers_solver uses pyrefly_config.error_kind, so a change to pyrefly_config.error_kind can break pyrefly.lib.alt.answers_solver, while a change to pyrefly.lib.alt.answers_solver can't break pyrefly_config.error_kind.
Position
Below the diagonal: pyrefly.lib.alt.answers_solver uses a module listed above it, which is the healthy direction.
pyrefly.lib.alt.answers_solver uses pyrefly_python.sys_info, so a change to pyrefly_python.sys_info can break pyrefly.lib.alt.answers_solver, while a change to pyrefly.lib.alt.answers_solver can't break pyrefly_python.sys_info.
Position
Below the diagonal: pyrefly.lib.alt.answers_solver uses a module listed above it, which is the healthy direction.
pyrefly.lib.alt.answers_solver uses pyrefly_util.arc_id, so a change to pyrefly_util.arc_id can break pyrefly.lib.alt.answers_solver, while a change to pyrefly.lib.alt.answers_solver can't break pyrefly_util.arc_id.
Position
Below the diagonal: pyrefly.lib.alt.answers_solver uses a module listed above it, which is the healthy direction.
pyrefly.lib.alt.answers_solver uses pyrefly_python.module_name, so a change to pyrefly_python.module_name can break pyrefly.lib.alt.answers_solver, while a change to pyrefly.lib.alt.answers_solver can't break pyrefly_python.module_name.
Position
Below the diagonal: pyrefly.lib.alt.answers_solver uses a module listed above it, which is the healthy direction.
pyrefly.lib.alt.answers_solver uses pyrefly_python.module_path, so a change to pyrefly_python.module_path can break pyrefly.lib.alt.answers_solver, while a change to pyrefly.lib.alt.answers_solver can't break pyrefly_python.module_path.
Position
Below the diagonal: pyrefly.lib.alt.answers_solver uses a module listed above it, which is the healthy direction.
pyrefly.lib.alt.answers_solver uses pyrefly_types.stdlib, so a change to pyrefly_types.stdlib can break pyrefly.lib.alt.answers_solver, while a change to pyrefly.lib.alt.answers_solver can't break pyrefly_types.stdlib.
Position
Below the diagonal: pyrefly.lib.alt.answers_solver uses a module listed above it, which is the healthy direction.
pyrefly.lib.alt.answers_solver uses pyrefly_types.type_var, so a change to pyrefly_types.type_var can break pyrefly.lib.alt.answers_solver, while a change to pyrefly.lib.alt.answers_solver can't break pyrefly_types.type_var.
Position
Below the diagonal: pyrefly.lib.alt.answers_solver uses a module listed above it, which is the healthy direction.
pyrefly.lib.alt.answers_solver uses pyrefly_types.heap, so a change to pyrefly_types.heap can break pyrefly.lib.alt.answers_solver, while a change to pyrefly.lib.alt.answers_solver can't break pyrefly_types.heap.
Position
Below the diagonal: pyrefly.lib.alt.answers_solver uses a module listed above it, which is the healthy direction.
pyrefly.lib.alt.answers_solver uses pyrefly_types.types, so a change to pyrefly_types.types can break pyrefly.lib.alt.answers_solver, while a change to pyrefly.lib.alt.answers_solver can't break pyrefly_types.types.
Position
Below the diagonal: pyrefly.lib.alt.answers_solver uses a module listed above it, which is the healthy direction.
pyrefly.lib.alt.answers_solver uses pyrefly_types.function, so a change to pyrefly_types.function can break pyrefly.lib.alt.answers_solver, while a change to pyrefly.lib.alt.answers_solver can't break pyrefly_types.function.
Position
Below the diagonal: pyrefly.lib.alt.answers_solver uses a module listed above it, which is the healthy direction.
pyrefly.lib.alt.answers_solver uses pyrefly_types.class, so a change to pyrefly_types.class can break pyrefly.lib.alt.answers_solver, while a change to pyrefly.lib.alt.answers_solver can't break pyrefly_types.class.
Position
Below the diagonal: pyrefly.lib.alt.answers_solver uses a module listed above it, which is the healthy direction.
pyrefly.lib.alt.answers_solver uses pyrefly_types.quantified, so a change to pyrefly_types.quantified can break pyrefly.lib.alt.answers_solver, while a change to pyrefly.lib.alt.answers_solver can't break pyrefly_types.quantified.
Position
Below the diagonal: pyrefly.lib.alt.answers_solver uses a module listed above it, which is the healthy direction.
pyrefly.lib.alt.answers_solver uses pyrefly_types.callable, so a change to pyrefly_types.callable can break pyrefly.lib.alt.answers_solver, while a change to pyrefly.lib.alt.answers_solver can't break pyrefly_types.callable.
Position
Below the diagonal: pyrefly.lib.alt.answers_solver uses a module listed above it, which is the healthy direction.
pyrefly.lib.alt.answers_solver uses pyrefly.lib.alt.class.class_field, so a change to pyrefly.lib.alt.class.class_field can break pyrefly.lib.alt.answers_solver, while a change to pyrefly.lib.alt.answers_solver can't break pyrefly.lib.alt.class.class_field.
Position
Below the diagonal: pyrefly.lib.alt.answers_solver uses a module listed above it, which is the healthy direction.
pyrefly.lib.alt.answers_solver uses pyrefly.lib.error.collector, so a change to pyrefly.lib.error.collector can break pyrefly.lib.alt.answers_solver, while a change to pyrefly.lib.alt.answers_solver can't break pyrefly.lib.error.collector.
Position
Below the diagonal: pyrefly.lib.alt.answers_solver uses a module listed above it, which is the healthy direction.
pyrefly.lib.alt.answers_solver uses pyrefly.lib.solver.solver, so a change to pyrefly.lib.solver.solver can break pyrefly.lib.alt.answers_solver, while a change to pyrefly.lib.alt.answers_solver can't break pyrefly.lib.solver.solver.
Position
Below the diagonal: pyrefly.lib.alt.answers_solver uses a module listed above it, which is the healthy direction.
pyrefly.lib.alt.answers_solver uses pyrefly.lib.binding.bindings, so a change to pyrefly.lib.binding.bindings can break pyrefly.lib.alt.answers_solver, while a change to pyrefly.lib.alt.answers_solver can't break pyrefly.lib.binding.bindings.
Position
Below the diagonal: pyrefly.lib.alt.answers_solver uses a module listed above it, which is the healthy direction.
51 pairs of types, where a type in pyrefly.lib.alt.answers_solver uses a type in pyrefly.lib.binding.binding. Showing 25 of them; the rest are in namespace-graph.json in this report's bundle.
pyrefly.lib.alt.answers_solver uses pyrefly.lib.binding.binding, so a change to pyrefly.lib.binding.binding can break pyrefly.lib.alt.answers_solver, while a change to pyrefly.lib.alt.answers_solver can't break pyrefly.lib.binding.binding.
Position
Below the diagonal: pyrefly.lib.alt.answers_solver uses a module listed above it, which is the healthy direction.
37→38 pyrefly.lib.alt.answers_solver uses pyrefly.lib.alt.answerspart of a loop✕
Connections
19 pairs of types, where a type in pyrefly.lib.alt.answers_solver uses a type in pyrefly.lib.alt.answers.
pyrefly.lib.alt.answers_solver uses pyrefly.lib.alt.answers, so a change to pyrefly.lib.alt.answers can break pyrefly.lib.alt.answers_solver, while a change to pyrefly.lib.alt.answers_solver can't break pyrefly.lib.alt.answers.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
pyrefly.lib.alt.answers uses pyrefly_python.sys_info, so a change to pyrefly_python.sys_info can break pyrefly.lib.alt.answers, while a change to pyrefly.lib.alt.answers can't break pyrefly_python.sys_info.
Position
Below the diagonal: pyrefly.lib.alt.answers uses a module listed above it, which is the healthy direction.
pyrefly.lib.alt.answers uses pyrefly_util.visit, so a change to pyrefly_util.visit can break pyrefly.lib.alt.answers, while a change to pyrefly.lib.alt.answers can't break pyrefly_util.visit.
Position
Below the diagonal: pyrefly.lib.alt.answers uses a module listed above it, which is the healthy direction.
pyrefly.lib.alt.answers uses pyrefly_python.module_name, so a change to pyrefly_python.module_name can break pyrefly.lib.alt.answers, while a change to pyrefly.lib.alt.answers can't break pyrefly_python.module_name.
Position
Below the diagonal: pyrefly.lib.alt.answers uses a module listed above it, which is the healthy direction.
pyrefly.lib.alt.answers uses pyrefly_python.module_path, so a change to pyrefly_python.module_path can break pyrefly.lib.alt.answers, while a change to pyrefly.lib.alt.answers can't break pyrefly_python.module_path.
Position
Below the diagonal: pyrefly.lib.alt.answers uses a module listed above it, which is the healthy direction.
pyrefly.lib.alt.answers uses pyrefly_types.stdlib, so a change to pyrefly_types.stdlib can break pyrefly.lib.alt.answers, while a change to pyrefly.lib.alt.answers can't break pyrefly_types.stdlib.
Position
Below the diagonal: pyrefly.lib.alt.answers uses a module listed above it, which is the healthy direction.
pyrefly.lib.alt.answers uses pyrefly_types.heap, so a change to pyrefly_types.heap can break pyrefly.lib.alt.answers, while a change to pyrefly.lib.alt.answers can't break pyrefly_types.heap.
Position
Below the diagonal: pyrefly.lib.alt.answers uses a module listed above it, which is the healthy direction.
pyrefly.lib.alt.answers uses pyrefly_types.types, so a change to pyrefly_types.types can break pyrefly.lib.alt.answers, while a change to pyrefly.lib.alt.answers can't break pyrefly_types.types.
Position
Below the diagonal: pyrefly.lib.alt.answers uses a module listed above it, which is the healthy direction.
pyrefly.lib.alt.answers uses pyrefly.lib.report.pysa.context, so a change to pyrefly.lib.report.pysa.context can break pyrefly.lib.alt.answers, while a change to pyrefly.lib.alt.answers can't break pyrefly.lib.report.pysa.context.
Position
Below the diagonal: pyrefly.lib.alt.answers uses a module listed above it, which is the healthy direction.
pyrefly.lib.alt.answers uses pyrefly_types.class, so a change to pyrefly_types.class can break pyrefly.lib.alt.answers, while a change to pyrefly.lib.alt.answers can't break pyrefly_types.class.
Position
Below the diagonal: pyrefly.lib.alt.answers uses a module listed above it, which is the healthy direction.
pyrefly.lib.alt.answers uses pyrefly_types.callable, so a change to pyrefly_types.callable can break pyrefly.lib.alt.answers, while a change to pyrefly.lib.alt.answers can't break pyrefly_types.callable.
Position
Below the diagonal: pyrefly.lib.alt.answers uses a module listed above it, which is the healthy direction.
pyrefly.lib.alt.answers uses pyrefly.lib.report.pysa.call_graph, so a change to pyrefly.lib.report.pysa.call_graph can break pyrefly.lib.alt.answers, while a change to pyrefly.lib.alt.answers can't break pyrefly.lib.report.pysa.call_graph.
Position
Below the diagonal: pyrefly.lib.alt.answers uses a module listed above it, which is the healthy direction.
pyrefly.lib.alt.answers uses pyrefly.lib.report.pysa, so a change to pyrefly.lib.report.pysa can break pyrefly.lib.alt.answers, while a change to pyrefly.lib.alt.answers can't break pyrefly.lib.report.pysa.
Position
Below the diagonal: pyrefly.lib.alt.answers uses a module listed above it, which is the healthy direction.
pyrefly.lib.alt.answers uses pyrefly.lib.state.state, so a change to pyrefly.lib.state.state can break pyrefly.lib.alt.answers, while a change to pyrefly.lib.alt.answers can't break pyrefly.lib.state.state.
Position
Below the diagonal: pyrefly.lib.alt.answers uses a module listed above it, which is the healthy direction.
pyrefly.lib.alt.answers uses pyrefly.lib.error.collector, so a change to pyrefly.lib.error.collector can break pyrefly.lib.alt.answers, while a change to pyrefly.lib.alt.answers can't break pyrefly.lib.error.collector.
Position
Below the diagonal: pyrefly.lib.alt.answers uses a module listed above it, which is the healthy direction.
pyrefly.lib.alt.answers uses pyrefly.lib.solver.solver, so a change to pyrefly.lib.solver.solver can break pyrefly.lib.alt.answers, while a change to pyrefly.lib.alt.answers can't break pyrefly.lib.solver.solver.
Position
Below the diagonal: pyrefly.lib.alt.answers uses a module listed above it, which is the healthy direction.
pyrefly.lib.alt.answers uses pyrefly.lib.binding.bindings, so a change to pyrefly.lib.binding.bindings can break pyrefly.lib.alt.answers, while a change to pyrefly.lib.alt.answers can't break pyrefly.lib.binding.bindings.
Position
Below the diagonal: pyrefly.lib.alt.answers uses a module listed above it, which is the healthy direction.
pyrefly.lib.alt.answers uses pyrefly.lib.binding.binding, so a change to pyrefly.lib.binding.binding can break pyrefly.lib.alt.answers, while a change to pyrefly.lib.alt.answers can't break pyrefly.lib.binding.binding.
Position
Below the diagonal: pyrefly.lib.alt.answers uses a module listed above it, which is the healthy direction.
pyrefly.lib.alt.answers uses pyrefly.lib.alt.answers_solver, so a change to pyrefly.lib.alt.answers_solver can break pyrefly.lib.alt.answers, while a change to pyrefly.lib.alt.answers can't break pyrefly.lib.alt.answers_solver.
Position
Below the diagonal: pyrefly.lib.alt.answers uses a module listed above it, which is the healthy direction.
pyrefly.lib.commands.coverage.collect uses pyrefly_python.module_name, so a change to pyrefly_python.module_name can break pyrefly.lib.commands.coverage.collect, while a change to pyrefly.lib.commands.coverage.collect can't break pyrefly_python.module_name.
Position
Below the diagonal: pyrefly.lib.commands.coverage.collect uses a module listed above it, which is the healthy direction.
pyrefly.lib.commands.coverage.collect uses pyrefly_build.handle, so a change to pyrefly_build.handle can break pyrefly.lib.commands.coverage.collect, while a change to pyrefly.lib.commands.coverage.collect can't break pyrefly_build.handle.
Position
Below the diagonal: pyrefly.lib.commands.coverage.collect uses a module listed above it, which is the healthy direction.
pyrefly.lib.commands.coverage.collect uses pyrefly_types.types, so a change to pyrefly_types.types can break pyrefly.lib.commands.coverage.collect, while a change to pyrefly.lib.commands.coverage.collect can't break pyrefly_types.types.
Position
Below the diagonal: pyrefly.lib.commands.coverage.collect uses a module listed above it, which is the healthy direction.
pyrefly.lib.commands.coverage.collect uses pyrefly_types.class, so a change to pyrefly_types.class can break pyrefly.lib.commands.coverage.collect, while a change to pyrefly.lib.commands.coverage.collect can't break pyrefly_types.class.
Position
Below the diagonal: pyrefly.lib.commands.coverage.collect uses a module listed above it, which is the healthy direction.
pyrefly.lib.commands.coverage.collect uses pyrefly.lib.state.state, so a change to pyrefly.lib.state.state can break pyrefly.lib.commands.coverage.collect, while a change to pyrefly.lib.commands.coverage.collect can't break pyrefly.lib.state.state.
Position
Below the diagonal: pyrefly.lib.commands.coverage.collect uses a module listed above it, which is the healthy direction.
pyrefly.lib.commands.coverage.collect uses pyrefly.lib.report.debug_info, so a change to pyrefly.lib.report.debug_info can break pyrefly.lib.commands.coverage.collect, while a change to pyrefly.lib.commands.coverage.collect can't break pyrefly.lib.report.debug_info.
Position
Below the diagonal: pyrefly.lib.commands.coverage.collect uses a module listed above it, which is the healthy direction.
pyrefly.lib.commands.coverage.collect uses pyrefly.lib.error.error, so a change to pyrefly.lib.error.error can break pyrefly.lib.commands.coverage.collect, while a change to pyrefly.lib.commands.coverage.collect can't break pyrefly.lib.error.error.
Position
Below the diagonal: pyrefly.lib.commands.coverage.collect uses a module listed above it, which is the healthy direction.
pyrefly.lib.commands.coverage.collect uses pyrefly.lib.binding.bindings, so a change to pyrefly.lib.binding.bindings can break pyrefly.lib.commands.coverage.collect, while a change to pyrefly.lib.commands.coverage.collect can't break pyrefly.lib.binding.bindings.
Position
Below the diagonal: pyrefly.lib.commands.coverage.collect uses a module listed above it, which is the healthy direction.
pyrefly.lib.commands.coverage.collect uses pyrefly.lib.binding.binding, so a change to pyrefly.lib.binding.binding can break pyrefly.lib.commands.coverage.collect, while a change to pyrefly.lib.commands.coverage.collect can't break pyrefly.lib.binding.binding.
Position
Below the diagonal: pyrefly.lib.commands.coverage.collect uses a module listed above it, which is the healthy direction.
pyrefly.lib.commands.coverage.collect uses pyrefly.lib.alt.answers_solver, so a change to pyrefly.lib.alt.answers_solver can break pyrefly.lib.commands.coverage.collect, while a change to pyrefly.lib.commands.coverage.collect can't break pyrefly.lib.alt.answers_solver.
Position
Below the diagonal: pyrefly.lib.commands.coverage.collect uses a module listed above it, which is the healthy direction.
pyrefly.lib.commands.coverage.collect uses pyrefly.lib.alt.answers, so a change to pyrefly.lib.alt.answers can break pyrefly.lib.commands.coverage.collect, while a change to pyrefly.lib.commands.coverage.collect can't break pyrefly.lib.alt.answers.
Position
Below the diagonal: pyrefly.lib.commands.coverage.collect uses a module listed above it, which is the healthy direction.
pyrefly.lib.query uses pyrefly_python.sys_info, so a change to pyrefly_python.sys_info can break pyrefly.lib.query, while a change to pyrefly.lib.query can't break pyrefly_python.sys_info.
Position
Below the diagonal: pyrefly.lib.query uses a module listed above it, which is the healthy direction.
pyrefly.lib.query uses pyrefly_python.module_name, so a change to pyrefly_python.module_name can break pyrefly.lib.query, while a change to pyrefly.lib.query can't break pyrefly_python.module_name.
Position
Below the diagonal: pyrefly.lib.query uses a module listed above it, which is the healthy direction.
pyrefly.lib.query uses pyrefly_python.module_path, so a change to pyrefly_python.module_path can break pyrefly.lib.query, while a change to pyrefly.lib.query can't break pyrefly_python.module_path.
Position
Below the diagonal: pyrefly.lib.query uses a module listed above it, which is the healthy direction.
pyrefly.lib.query uses pyrefly_build.handle, so a change to pyrefly_build.handle can break pyrefly.lib.query, while a change to pyrefly.lib.query can't break pyrefly_build.handle.
Position
Below the diagonal: pyrefly.lib.query uses a module listed above it, which is the healthy direction.
pyrefly.lib.query uses pyrefly_python.qname, so a change to pyrefly_python.qname can break pyrefly.lib.query, while a change to pyrefly.lib.query can't break pyrefly_python.qname.
Position
Below the diagonal: pyrefly.lib.query uses a module listed above it, which is the healthy direction.
pyrefly.lib.query uses pyrefly_types.types, so a change to pyrefly_types.types can break pyrefly.lib.query, while a change to pyrefly.lib.query can't break pyrefly_types.types.
Position
Below the diagonal: pyrefly.lib.query uses a module listed above it, which is the healthy direction.
pyrefly.lib.query uses pyrefly_types.function, so a change to pyrefly_types.function can break pyrefly.lib.query, while a change to pyrefly.lib.query can't break pyrefly_types.function.
Position
Below the diagonal: pyrefly.lib.query uses a module listed above it, which is the healthy direction.
pyrefly.lib.query uses pyrefly_types.class, so a change to pyrefly_types.class can break pyrefly.lib.query, while a change to pyrefly.lib.query can't break pyrefly_types.class.
Position
Below the diagonal: pyrefly.lib.query uses a module listed above it, which is the healthy direction.
pyrefly.lib.query uses pyrefly.lib.state.state, so a change to pyrefly.lib.state.state can break pyrefly.lib.query, while a change to pyrefly.lib.query can't break pyrefly.lib.state.state.
Position
Below the diagonal: pyrefly.lib.query uses a module listed above it, which is the healthy direction.
pyrefly.lib.query uses pyrefly.lib.report.debug_info, so a change to pyrefly.lib.report.debug_info can break pyrefly.lib.query, while a change to pyrefly.lib.query can't break pyrefly.lib.report.debug_info.
Position
Below the diagonal: pyrefly.lib.query uses a module listed above it, which is the healthy direction.
pyrefly.lib.query uses pyrefly.lib.alt.answers, so a change to pyrefly.lib.alt.answers can break pyrefly.lib.query, while a change to pyrefly.lib.query can't break pyrefly.lib.alt.answers.
Position
Below the diagonal: pyrefly.lib.query uses a module listed above it, which is the healthy direction.
At a glance — Code Health · 55% · Adequate · gated by D2, X4 ·
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
134
High / Critical
A03:2025 — Software Supply Chain Failures
26
High / Critical
Roadmap
Top priorities: Interpolated log message defeats structured logging; Thread an AbortSignal through async functions that make requests, so the work stops when its caller gives up; Resolve the 1 No ADRs found finding(s) in ADR Quality — start with Cargo.toml.
Ranked by impact ÷ effort. "Helps" is the estimated gain on the 0–100 health score.
Bring the 16 bodies over 120 down to 120 or less in Cognitive Complexity — start with BindingsBuilder::stmt_impl (cognitive 393), AnswersSolver::callable_infer_params (cognitive 368), StructurallyValidatedTypeShapeDslFunction::evaluate_expression (cognitive 282).
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.
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 — 140
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 — 1955
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 — 97
Recorded, with no effect on how the codebase functions.
Present so the survey is complete, not because it needs doing.
Could not be resolved — 15
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 63 evaluated dimensions are computed by tools and static analysis; no language model sets or judges any of them. Overall confidence is 0.9, the weighted average across measured dimensions.
Every figure here is one of two kinds, and we label which: ✓ Measured — a deterministic fact (LoC, complexity, coverage); ~ Modeled — an estimate from a stated model (cost, effort, value-at-risk), always a range with its assumptions, never a precise fact. We never present a modelled estimate as if it were measured. Perfect or absent scores carry their provenance too (ADR-0011): ✓ Tool-verified means the property itself was measured across the surface; ○ Nothing flagged means the probes came back clean — a claim bounded by what a repository can show; ⊘ Not evidenced means a working control (a tested restore, an automated rollback) showed no positive evidence — absence of evidence is not evidence of a control, so it's excluded from the score rather than awarded a spurious 10.
What we checked — 63 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, 2173 of 2192 do; the remainder are repo-wide signals — a dimension-level measurement, not a single line. (Every path in this report is repo-relative by construction: paths are normalized at the producer and the report is rejected if any rooted path leaks through.)
Is there a tool behind the number? Every score below names the method that produced it: Roslyn, git or a scanner, not a narrative.
Does re-running give the same result? Run it again on the same commit and the score — and this report, byte for byte — is identical. A report whose numbers move between runs is describing the run, not the code.
This report answers yes to all three. That's the bar to hold any assessment to.
Tools & methods
The actual versions used this run (captured at analysis time) — re-run on the same commit for the identical score.
Method
Backs
Version
Evaluator
Roslyn static analysis
Complexity, cohesion, coupling, dead code, API surface, layering
What ran differently this time — a tool absent, degraded, or that fell back to an estimate. Named openly, not folded silently into the scores. A degraded run also records its exact cause in diagnostics.md.
D8 Code Coverage — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. Coverage NOT MEASURED: the JavaScript/TypeScript half could not be measured — the dependency install for website/ could not reach the package registry on this run (info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.), so the suite never ran. Coverage is excluded from the score rather than counted as a near-zero. This is OUR limitation, not a defect in the repo.
D10 Test Quality — measured, with a gap in what it reached — We measured this, but not all of it. What we did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. The 117 test(s) behind this row are the ones the JavaScript/TypeScript census could read, and this repository also carries at least 864 test source file(s) (.py, .rs) that it cannot: it reads JavaScript/TypeScript test declarations off disk, so a JUnit/pytest-style suite is invisible to it. Skipped tests, zero-assertion tests and the other quality signals on this row are UNMEASURED in that suite — their absence from the counts above is a gap in this analyzer's language coverage, not a finding that those tests are sound.
D11 Test Reliability — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. Test reliability NOT MEASURED: the JavaScript/TypeScript suite could not be re-run in the analyzer sandbox — the dependency install for website/ could not reach the package registry on this run (info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.), so the suite never ran. This is OUR limitation, not a defect in the repo — it is excluded from the score.
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 reliability for the jest suite in website/ was NOT MEASURED: the dependency install for website/ could not reach the package registry on this run (info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.), so the suite never ran. This is OUR limitation, not a defect in the repository, and the suite is excluded from the measurement rather than counted against it.
D14 License Compliance — measured, with a gap in what it reached — We measured this, but not all of it. What we did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. This repository declares a Python pyproject.toml/requirements.txt (pip/uv/Poetry), but the licence verdict published here was taken over its crate dependencies. Nothing was read about its Python dependencies' licensing in either direction, and a clean score on this card must not be read as covering them.
D14 License Compliance — measured, with a gap in what it reached — We measured this, but not all of it. What we did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. This repository declares package.json, but the licence verdict published here was taken over its crate dependencies. Nothing was read about its npm dependencies' licensing in either direction, and a clean score on this card must not be read as covering them.
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.
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. D21's naming rules read C# through Roslyn and every other language through its sidecar model; these languages are left out (PHP's reading is its own change, a Roslyn-loaded VB or F# project has no population builder yet). Their declarations carry no naming verdict this run — this says nothing about whether their names are consistent.
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 — 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 source language's comment syntax, and the code a comment annotates in it, needs its own proof before D24 judges it. Until then those comments are left unread, not counted as clean.
D27 Navigability — 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. Navigability is taken over call sites whose callee resolved. For C# that population includes calls into referenced assemblies; for this language only calls declared inside the repository count, so the abstention threshold reads the repository's use of its standard library as a resolution failure. That is a limit of this analyzer, not a build problem in this repository.
D32 Data Compliance (PII/GDPR) — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. `conformance/third_party/aliases_type_statement.py`, `conformance/third_party/aliases_typealiastype.py`, `conformance/third_party/annotations_forward_refs.py`, `conformance/third_party/callables_annotation.py`, `conformance/third_party/callables_protocol.py`, … (+51 more) produced a parse error, so every rule in this engine's `gdpr.yml` was absent there. That absence is NOT a clean result: these rules detect personal data crossing a boundary into a log sink, a URL or browser storage, and a file that was never parsed cannot report any of the three. The rest of the tree analysed normally and its rows above stand; only these files are unaccounted for. You can widen what we reach: fix the syntax error (or exclude the file deliberately) and re-scan to cover it.
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's reader does not cover most of the languages this repository's product is written in. What it read is kept, but it is too small a share to grade the product by. That is a gap in this analyzer's language reach — not a finding about this repository.
AXB2 Runtime readiness — 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. `npm run` found no package.json in the folder where our sandbox ran it. This is a limit of our sandbox, not of your repository. (rule: no-root-manifest). The renderer reported: the dev server (`npm run start`) exited before it served a page. Likely cause (our sandbox): `npm run` found no package.json in the folder where our sandbox ran it. This is a limit of our sandbox, not of your repository. Last output: "npm error code ENOENT / npm error syscall open / npm error path <repo>/package.json / npm error errno -2 / npm error enoent Could not read package.json: Error: ENOENT: no such file or directory, open '<repo>/package.json' / npm error enoent This is related to npm not being able to find a file. / npm error enoent / npm error A complete log of this run can be found in: <path>" No runtime evidence was gathered.
AXR1 Runtime accessibility — 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. Render strategy: boot via DevServer (start). the dev server (`npm run start`) exited before it served a page. Likely cause (our sandbox): `npm run` found no package.json in the folder where our sandbox ran it. This is a limit of our sandbox, not of your repository. Last output: "npm error code ENOENT / npm error syscall open / npm error path <repo>/package.json / npm error errno -2 / npm error enoent Could not read package.json: Error: ENOENT: no such file or directory, open '<repo>/package.json' / npm error enoent This is related to npm not being able to find a file. / npm error enoent / npm error A complete log of this run can be found in: <path>" No runtime evidence was gathered.
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, Rust 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 reads C# syntax, JavaScript/TypeScript, Java, Dart, Ruby and Scala source only, and this repository's Python, Rust 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.
M4 Documentation accuracy — measured, with a gap in what it reached — We measured this, but not all of it. What we did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. A badge or prose version claim scored 9/17 in its adjudication (docs/plans/deterministic-engine/adjudication/M4-v3.md: badges 9/9, prose 0/8, where prose versions are minimums or history), short of the 95 % precision gate, 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. The .NET and Node.js version checks are a different kind and still publish.
M4 Documentation accuracy — measured, with a gap in what it reached — We measured this, but not all of it. What we did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. M4 checks only the claim kinds adjudicated at or above 95 % precision: links and versions (PREREGISTRATION version 9), and artefact counts an order of magnitude off. Paths, command arguments, installs, environment variables, settings, projects, packages, routes, cd targets, infrastructure products and removed modules are read but not checked, and none of them is reported or counted.
P5 DR & Backup — not measured this run — This is a true statement about the repository that carries nothing for its owner to act on, so it is reported here rather than as a defect in their code. No backup/snapshot/replication config, RTO/RPO or restore-procedure documentation was found — and no production persistence was detected either (no data-access packages, no data-store services, no database resources), so there is nothing in this repository whose loss a DR control would recover. If this system's data lives in a platform or ops repo we can't see, that's where the DR evidence belongs.
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's reader does not cover most of the languages this repository's product is written in. What it read is kept, but it is too small a share to grade the product by. That is a gap in this analyzer's language reach — not a finding about this repository.
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's reader does not cover most of the languages this repository's product is written in. What it read is kept, but it is too small a share to grade the product by. That is a gap in this analyzer's language reach — not a finding about this repository.
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's reader does not cover most of the languages this repository's product is written in. What it read is kept, but it is too small a share to grade the product by. That is a gap in this analyzer's language reach — not a finding about this repository.
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's reader does not cover most of the languages this repository's product is written in. What it read is kept, but it is too small a share to grade the product by. That is a gap in this analyzer's language reach — not a finding about this repository.
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's reader does not cover most of the languages this repository's product is written in. What it read is kept, but it is too small a share to grade the product by. That is a gap in this analyzer's language reach — not a finding about this repository.
X4 Structured logging — 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. 109 further occurrence(s) are not listed individually; the score already reflects all 149.
Repo exclusion declarations (.gitattributes linguist-generated/vendored, .editorconfig generated_code): none declared — every source file was scored.
Limitations & what we did not check
We assess the repository exactly as committed, and only the repository. By design we do not reach outside the source tree: the live cloud account, the running CI/CD pipeline, the host's branch-protection and approval rules, the production configuration, or a restore actually exercised against a backup are all out of scope. That boundary is a feature, not a gap — a repo-relative, deterministic scan re-runs identically on any commit and every finding opens at a real file and line, where a live audit can neither be reproduced nor traced. The visible consequence is that controls which leave no in-repo evidence are reported as "not evidenced" and excluded from the score rather than awarded a number a static scan cannot justify.
Per-dimension blind spots
For each dimension that was measured, what a static, repo-only scan structurally cannot see — the honest edge of the measurement, not a failure of it.
D1 Cyclomatic Complexity: Cyclomatic complexity counts branches statically — it cannot tell an essential decision tree from accidental tangle, nor see complexity that lives in data or configuration (large switch-case token tables, DSL lexers/parsers, data-as-code rule tables) rather than control flow: a tokenizer's many single-character cases read as high complexity though each branch is trivial.
D2 Cognitive Complexity: Cognitive-complexity heuristics approximate how hard code is to follow; genuine domain difficulty and well-named intent that eases reading are not captured.
D3 God Classes: "God class" is sized by members and responsibilities visible in the type — a deliberately broad facade over a coherent subsystem can read the same as an accidental grab-bag. For front-end JS the file-length check is cohesion-aware (a single-responsibility module — one class/IIFE — earns a 3× threshold), but cohesion is approximated from top-level declarations, not true dependency structure.
D4 Code Duplication: Duplication is token-similarity — an in-process token-stream comparison over sliding windows, with type-aware normalization — so it finds copy-paste, not semantic duplication expressed differently. Committed machine-written code (scaffolded migrations, designer/codegen output, protobuf/OpenAPI stubs, model snapshots) is EXCLUDED — its repetition is the tool's, not the team's — so the score reflects hand-written duplication only.
D5 Coupling: Coupling is measured between projects/assemblies — runtime coupling through DI, reflection, messaging or shared databases is invisible to a static reference graph.
D6 Cohesion (LCOM4): LCOM4 cohesion is syntactic — it infers connectivity from which methods touch which fields/methods by name, not from real runtime behaviour or intent.
D10 Test Quality: Assertion density is structural — it cannot tell a meaningful behavioural assertion from a trivial one, only that an assertion is present.
D12 Dependency Hygiene: Dependency health reads manifests and lockfiles — a vulnerability in a vendored/copied dependency, or risk from how a dependency is actually used, is outside this view.
D13 Secret Scanning: Secret detection is signature- and entropy-based on the current tree — a secret that does not match a known pattern, or one already rotated, will not be flagged (a clean scan is "nothing matched", not "no secrets exist").
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.
D20 ADR Quality: ADR quality checks the structure of the decision records present: it cannot know about decisions made and never recorded, and it does not judge how well a record argues its case. Records in a language the section lexicon does not cover are not evaluated.
D24 Comment Value: Comment value is measured as redundancy only: a comment that repeats its code's words is found, but a paraphrase in other words, a vague comment, or one the code contradicts is not, and whether a comment is valuable is not claimed. Comments in other scripts or languages, and outside C#, are not judged.
D26 Project Cohesion: Project focus is sized from members/namespaces per project — a project that is broad by deliberate design reads the same as one that has sprawled.
D28 Secrets (history): Secret-history scanning sweeps the git log for known patterns — a secret that predates the available history, or never matched a signature, is not found (clean means "nothing matched in the history we can see").
D29 Static Analysis (SAST): SAST findings are pattern-based (semgrep) — it finds classes of bug it has rules for; logic flaws, auth/authorization gaps and issues needing runtime context are out of reach (and clean means "no rule matched").
D30 Dependency Vulnerabilities: CVE matching depends on accurate package/version metadata and on the advisory databases — a vulnerability with no published advisory, or in code not declared as a dependency, is not seen. Coverage needs a RESOLVED graph: an unpinned requirements.txt, or a pom without a resolved build, yields partial coverage rather than a clean verdict. An ecosystem the analyzer cannot scan is reported as unmeasured, never as clean.
D34 Knowledge Freshness: Freshness is decayed commit RECENCY, not comprehension — code read often but rarely committed reads as orphaned, and stable code that genuinely needs no changes is penalised the same as forgotten code; bot/squash commits distort it like the bus factor.
D35 Change Coupling: Change coupling is co-change in COMMITS — files split across separate commits, or coupled only through a shared config/build step, read as uncoupled, and a sweeping commit (rename/format) is excluded so it doesn't couple everything. It shows that files change together, not WHY: a high coupling can be a healthy cohesive pair as readily as a hidden leak.
D43 Malicious Dependencies: Only packages some vulnerability database has already NAMED as malicious are seen — a compromise published in the last hours, or never reported at all, is invisible here, and this dimension reading 10 is not evidence that a dependency is trustworthy. There is no typosquat or dependency-confusion analysis: a package nobody has reported is simply absent from the feeds. Coverage is the dependency scan's: an ecosystem that could not be scanned is disclosed as unmeasured, never as clean.
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.
AX9 CQS / query purity: Handlers are found by interface/name convention — a query handler using neither is not seen. Mutation is a resolved write/publish invocation (SaveChanges/repository/bus), so a write hidden behind a hand-rolled wrapper, reflection, or a string-keyed service locator resolves to a non-persistence type and isn't flagged; it detects that a query writes state, not whether the write is a legitimate read-side cache update. Clean means "no resolved write/publish in a query body", not a proof of CQS purity.
M4 Documentation accuracy: Documentation accuracy checks links, versions and artefact counts against the tree: other claims (paths, commands, settings, routes) are read but not checked, and it cannot run the onboarding or measure how long a real new joiner takes.
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.
276 method(s) exceeded the cyclomatic complexity threshold of 15; the worst was StructurallyValidatedTypeShapeDslFunction::evaluate_expression at 278. A further 43 method(s) were over the threshold but excluded as flat dispatchers (a long switch/match over independent cases: many branches, almost no nesting), the largest being KnownClass::lookup at 182 — they are counted neither in the figure above nor in this dimension's score. 12 files carry no cyclomatic complexity row at all for this reason — every one of their over-threshold functions was excluded, so the exclusion is disclosed nowhere in the file itself: crates/pyrefly_types/src/known_class.rs (KnownClass::lookup at 182), crates/pyrefly_config/src/error_kind.rs (ErrorKind::default_severity at 91), pyrefly/lib/export/special.rs (SpecialExport::new at 88), pyrefly/lib/query/type_table.rs (pyrefly::lib::query::type_table::type_to_indexed_shape at 54), crates/pyrefly_types/src/types.rs (Type::recurse at 53), and 7 more not listed here. They are named here because the per-file figures other dimensions report are taken BEFORE this exclusion, so such a file can show a high maximum complexity elsewhere in this report and nothing here, with nothing to reconcile the two.
+ 57 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Bring the 8 bodies over 120 down to 120 or less in Cyclomatic Complexity — start with StructurallyValidatedTypeShapeDslFunction::evaluate_expression (cyclomatic 278), Subset::is_subset_eq_no_recursive_check (cyclomatic 251), BindingsBuilder::stmt_impl (cyclomatic 188). — 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 8 together lifts Cyclomatic Complexity from 4.3 to about 5.3/10, projected with the scoring formula itself and assuming each lands exactly at 120; 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.
+ 95 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Bring the 16 bodies over 120 down to 120 or less in Cognitive Complexity — start with BindingsBuilder::stmt_impl (cognitive 393), AnswersSolver::callable_infer_params (cognitive 368), StructurallyValidatedTypeShapeDslFunction::evaluate_expression (cognitive 282). — 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 16 together lifts Cognitive Complexity from 2.0 to about 3.7/10, projected with the scoring formula itself and assuming each lands exactly at 120; 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.4 / 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.
+ 2 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Resolve the 123 MethodTooLong finding(s) in God Classes — start with type_level_dsl.rs (12), expr.rs (8), class_field.rs (7). — One of this dimension's main actionable groups (123 warning-level).
Resolve the 81 FileTooLong finding(s) in God Classes — start with function.rs (3), type_level_dsl.rs (2), expr.rs (2). — One of this dimension's main actionable groups (81 warning-level).
Resolve the 25 TooManyMethods finding(s) in God Classes — start with answers_solver.rs (2), bindings.rs (2), solver.rs (2). — One of this dimension's main actionable groups (25 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.
333 duplicated block group(s) detected. 4.0 % of the production lines (13,995 of 349,391) are in a reported copy. A further 206 rows report members as variants of one another; the share counts each copied line once, however many rows cite it. 140 of the 539 are in trees this repository does not ship — vendored, example/demo, project-template, fixture and benchmark code — and are ranked below the shipped groups rather than excluded from them: the duplication there is real and is still counted in this dimension's score. The dimensions that publish a production-file census leave those trees out of theirs, so this count is deliberately drawn over the wider population.
+ 158 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Resolve the 30 Duplicated block (7 lines × 2) finding(s) in Code Duplication — start with type_level_dsl.rs (4), class_field.rs (2), narrow.rs (2). — One of this dimension's main actionable groups (30 warning-level).
Resolve the 29 Duplicated block (5 lines × 2) finding(s) in Code Duplication — start with nanogpt_future_annotations_runnable.py (3), expr.rs (2), soft_actor_critic.py (2). — One of this dimension's main actionable groups (29 warning-level).
Resolve the 19 Duplicated block (9 lines × 2) finding(s) in Code Duplication — start with type_level_dsl.rs (3), class_field.rs (2), lsp.rs (2). — One of this dimension's main actionable groups (19 warning-level).
Detailed fixes: d4_recommendation.md · top locations in Appendix A, every location in findings.md.
Do you agree with this assessment?
D5 · Coupling10.0 / 10Exemplary✓ Tool-verified
What it measures: Whether volatile projects sit underneath others that depend on them (so their churn ripples upward), and whether project dependencies form cycles. A widely-depended-on but stable shared/kernel project is healthy, not penalised.
Method: Dependency cycles via elementary-DFS over real .csproj references, plus Martin instability (afferent/efferent) per project. Exhaustive over the reference graph, deterministic.
Coverage: Exhaustive · type-level: afferent/efferent coupling + cycles computed over every production type — the population is all types, not a name convention.
8 production modules (Cargo+npm+Python), 0 dependency cycle(s), 0 unstable depended-on module(s). Read from the build's own module declarations; 0 module(s) off the main sequence, with abstractness counted on 7 of the 8 (the rest declare no modelled class or interface, export only macros, declare types in source no model reads, or have no source directory of their own).
What it measures: Whether a class's methods are focused on a single responsibility.
Method: LCOM4 cohesion per production class with at least two methods: connected components of methods sharing state or calls, computed syntactically. Deterministic, not a proxy.
Coverage: Exhaustive · type-level: LCOM4 cohesion computed over every production class — the population is all types, not a name convention.
Resolve the 2 Low cohesion finding(s) in Cohesion (LCOM4) — start with nesting_context.rs, solver.rs. — One of this dimension's main actionable groups (2 warning-level).
Detailed fixes: d6_recommendation.md · top locations in Appendix A, every location in findings.md.
Do you agree with this assessment?
D10 · Test Quality9.9 / 10Stronggated by 1 serious finding✓ Tool-verified
What it measures: Whether the tests truly assert behaviour rather than just running the code.
Method: Per-test assertions, skips, and mock references analyzed via Roslyn; structured skip-reason tags (BUG:/ENV:) separate documented deferrals from debt. Deterministic.
0 skipped, 1 zero-assertion, no mocking-framework packages referenced (hand-written doubles or no mocking) across 117 tests. Measured on the JavaScript/TypeScript suite only — at least 864 test source file(s) (.py, .rs) went unread, so its test quality is unmeasured and is not in these counts.
No assertions: startup requests and diagnostics use the interpreter from the Python extensionlsp/src/test/startup-settings/instant/instant.test.ts:23
What to do
Resolve the 1 No assertions finding(s) in Test Quality — start with instant.test.ts. — One of this dimension's main actionable groups (1 warning-level).
Detailed fixes: d10_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether dependencies are current, not deprecated, and not bloated. Known vulnerabilities are D30's.
Method: Manifest scan via dotnet list package across all projects; worst-signal-per-package deduction (capped-linear for deprecation, prerelease and outdated) per KLoC. Known-vulnerable packages are D30's and are not charged here (rubric-2026.11.2). Exhaustive.
3 outdated, 0 yanked direct Cargo dependencies. 89 of 90 direct crates were graded against crates.io (0 not published there, 1 not resolved by a committed REDACTED). Only DIRECT edges are graded: a transitive crate cannot be moved past what its parent's requirement admits, so reporting one would be advice its owner cannot take. A newer release is reported only where this repository's OWN requirement already admits it, so the remedy is `cargo update` and never a manifest edit — which means a release outside the declared range is deliberately NOT charged, because a written-down constraint is a decision rather than a defect. Note that a bare requirement is a CARET, and for a 0.x crate its ceiling is the minor. Whether any crate is UNMAINTAINED is not graded — crates.io publishes no maintenance status, and release age does not stand in for one. Known CVEs in this dependency graph are D30's question, read from REDACTED there.
Outdated: arc-swap · ×3
✓ On the Gold path — maintain.
Detailed fixes: d12_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether any secrets (keys, tokens, passwords) have leaked into the code.
Method: In-process native secret scanner (entropy plus signature patterns) across all tracked files; no external tool. A clean result is a measured 10, not no-data zero. Deterministic.
What it measures: 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 412 shipped crate(s) use a banned license. Licences were resolved from crates.io over the crates a consumer compiles — this repository's REDACTED closed over its manifests' `[dependencies]` and `[build-dependencies]`. Crates it asks for ONLY under `[dev-dependencies]` are excluded: they are not compiled by anything that depends on this repository. A further 1 crate(s) in the closure resolve from git, a path or a private registry and publish no licence this pass can read; they are outside this verdict. This repository publishes itself under MIT, which is its own choice and is not judged here. ★ COVERAGE OF THIS VERDICT: it grades this repository's crate dependencies and nothing else. The repository also declares a Python pyproject.toml/requirements.txt (pip/uv/Poetry) and package.json, and the licences of those dependency graphs were NOT read by this pass — a gap in this engine's coverage, not a statement about them. So this result says the graded closure carries no banned licence; it does NOT say this repository's licensing is clear.
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 80 Hotspot finding(s) in Churn × Complexity Hotspots — start with type_level_dsl.rs (2), expr.rs (2), display.rs (2). — One of this dimension's main actionable groups (80 warning-level).
Resolve the 1 Repeated repair finding(s) in Churn × Complexity Hotspots — start with signature_help.rs. — One of this dimension's main actionable groups (1 warning-level).
Detailed fixes: d15_recommendation.md · top locations in Appendix A, every location in findings.md.
Do you agree with this assessment?
D16 · Bus Factor9.0 / 10Strong✓ 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.
42 source file(s) have their living knowledge concentrated in one author (≥90% of recent, decayed contribution). The largest is crates/pyrefly_types/src/type_level_dsl.rs. Counted over 418 of the 577 production source files in this repository: the rest are under the ~2,400-byte size floor this dimension measures over.
Off-boarding risk: anonymized user #1 · ×3
Further sole-owners (lower concentration)
What to do
Resolve the 3 Off-boarding risk finding(s) in Bus Factor. — One of this dimension's main actionable groups (3 recommendation-level).
Resolve the 1 Further sole-owners (lower concentration) 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.
280 deducted task-comment markers across 349391 LoC (0.1/KLoC) → score 9.8. Task comments only: this repository's language is read without a compiler, so D17's suppression, dead-code and commented-out-code arms did not run and this score counts fewer marker kinds than a .NET repository's would.
Resolve the 274 TodoComment finding(s) in Explicit Debt — start with call_graph.rs (21), solve.rs (16), class_field.rs (13). — One of this dimension's main actionable groups (274 warning-level).
Resolve the 4 HackComment finding(s) in Explicit Debt — start with callable.rs (2), call.rs, class_bases.rs. — One of this dimension's main actionable groups (4 warning-level).
Resolve the 1 XxxComment finding(s) in Explicit Debt — start with lsp.rs. — One of this dimension's main actionable groups (1 warning-level).
Detailed fixes: d17_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether 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.
1 of 2 documentation facets pass in full; short on: F2 example. 77 document(s) read across 4 unit(s).
Documentation: no build, run or usage examplelsp/README.md:1
What to do
Resolve the 1 Documentation finding(s) in Documentation Quality — start with README.md. — One of this dimension's main actionable groups (1 recommendation-level).
Detailed fixes: d19_recommendation.md · top locations in Appendix A, every location in findings.md.
Do you agree with this assessment?
D20 · ADR Quality0.0 / 10Critical✓ Tool-verified
What it measures: Whether architecture decisions are recorded well (context, decision, consequences).
Method: Every ADR read by its section structure: nine located rules (a missing Decision, Context or Consequences section, a stale status, two records deciding the same question, a dangling supersede link, a number-only title, a single option, no named cost, no status where the log uses one, no enforcement field where the log adopted one), each a fixed deduction from 10; the score is the mean over evaluated records. Deterministic, no model. Advisory.
Resolve the 1 No ADRs found finding(s) in ADR Quality — start with Cargo.toml. — One of this dimension's main actionable groups (1 recommendation-level).
Detailed fixes: d20_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether comments are worth it — explaining WHY (valuable) rather than WHAT (redundant).
Method: Every inline C# comment compared word by word with the identifiers, literals and constructs of the code it annotates (taken from the syntax); a comment whose words that code already contains is redundant, as are closing-brace labels and generator template text. Comments giving a reason or a reference are kept; other scripts and languages are not judged. Deterministic, exhaustive, advisory.
4 of 220 judged comments only repeat the code they sit on (1.8 %). 3 comment(s) in another language or script were not judged.
redundant comment · ×4REDACTED:54
doc comments repeat the nameswebsite/src/__tests__/__mocks__/configuredMonacoMock.ts:74
What to do
Resolve the 4 redundant comment finding(s) in Comment Value — start with REDACTED (3), dark-mode-favicon.js. — One of this dimension's main actionable groups (4 recommendation-level).
Detailed fixes: d24_recommendation.md · top locations in Appendix A, every location in findings.md.
Do you agree with this assessment?
D26 · Project Cohesion4.5 / 10Weak✓ Tool-verified
What it measures: Whether each project is a focused, coherent unit rather than an oversized grab-bag.
3 of 11 build units (Cargo, Python, npm) flagged as possibly oversized/incoherent.
Projects may be oversized for their cohesion
What to do
Resolve the 1 Projects may be oversized for their cohesion finding(s) in Project Cohesion. — One of this dimension's main actionable groups (1 recommendation-level).
Detailed fixes: d26_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether any secrets were ever committed — scanned across the full git history, not just now.
Method: Secret scan via TWO gitleaks detect passes in an isolated checkout — the full git history, then a second --no-git pass over the working tree as it stands — merged and de-duplicated by (rule, file, line); each match flagged High. Both invocations are recorded in the audit trail. Exhaustive; when the tool is absent, or when its output cannot be parsed into the expected shape, the dimension is WITHHELD as an explicit measurement gap on our side — unscored and excluded from the lens, never a hedged middling score.
What it measures: Real static-analysis (SAST) findings — likely security bugs in the code, any language.
Method: Polyglot static analysis via semgrep across the repo using the pinned, image-baked p/security-audit + p/owasp-top-ten rulesets (no scan-time registry fetch); severity rules (ERROR/WARNING/INFO) map to a full-band severity-weighted score. Exhaustive, deterministic; degrades on parse failure.
Coverage: semgrep pattern rules over all files — exhaustive for the rule set, blind to classes of bug without a rule (clean = no rule matched).
134 finding(s): 0 critical, 132 high, 1 medium, 1 low. 115 unpinned-GitHub-Actions row(s) are reported here but scored by D36 (supply-chain provenance), which measures that posture as `pinned_actions` — one pinning decision is charged once, not once per lens. semgrep hit a parse error in 99 file(s) — `conformance/third_party/aliases_type_statement.py` (line 8, line 9, line 10, …), `conformance/third_party/aliases_typealiastype.py` (line 22, line 39), `conformance/third_party/annotations_forward_refs.py` (lines 121–122, lines 123–125, lines 126–129), `conformance/third_party/callables_annotation.py` (line 114), `conformance/third_party/callables_protocol.py` (line 176), … (+94 more) — so no absence of findings in the named regions is evidence of anything; rows reported elsewhere in those files are real. Fix the syntax error (or exclude the file deliberately) and re-scan to cover them. Separately, one or more rules could not re-parse an embedded snippet in 7 file(s) (e.g. a workflow `run:` block read as shell). Those files WERE scanned and their other rows are unaffected; only those rules' view of those snippets is missing.
REDACTED
REDACTED
REDACTED
REDACTED
REDACTED
+ 3 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Resolve the 9 REDACTED finding(s) in Static Analysis (SAST) — start with REDACTED (5), REDACTED (4). — One of this dimension's main actionable groups (9 issue-level).
Resolve the 4 REDACTED finding(s) in Static Analysis (SAST) — start with REDACTED, REDACTED, REDACTED. — One of this dimension's main actionable groups (4 issue-level).
Resolve the 1 REDACTED finding(s) charged to Static Analysis (SAST) — the other 115 are reported here at file:line but scored by D36 (supply-chain provenance), which charges them once. — One of this dimension's main actionable groups (116 issue-level, 1 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.
+ 1 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Resolve the 4 High CVE finding(s) in Dependency Vulnerabilities — start with REDACTED (4). — One of this dimension's main actionable groups (4 issue-level).
Resolve the 1 Critical CVE finding(s) in Dependency Vulnerabilities — start with REDACTED. — One of this dimension's main actionable groups (1 issue-level).
Resolve the 1 High vulnerability finding(s) in Dependency Vulnerabilities — start with REDACTED. — One of this dimension's main actionable groups (1 issue-level).
Detailed fixes: d30_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether anyone still has living knowledge of each file, or it has been orphaned — last understood long ago by someone now gone quiet. The sibling of the bus factor: D16 asks who owns it, D34 asks whether anyone still knows it.
Method: File orphaning as total living-knowledge decay below one focused-commit's worth within a year, computed per-file from the D16 decay model. Exhaustive, deterministic over fixed history.
2 of 418 significant source file(s) are orphaned — their living knowledge has decayed to nothing, so no one currently understands them. The largest is crates/pyrefly_config/src/migration/mypy/regex_converter.rs. Counted over 418 of the 577 production source files in this repository: the rest are under the ~2,400-byte size floor this dimension measures over.
What it measures: Whether files that change together actually belong together — pairs that repeatedly co-change in git history despite having no explicit code dependency, surfacing the hidden/logical coupling (and boundaries in the wrong place) a static scan can't see.
Method: Pairwise co-occurrence over the per-commit file sets in git history (production source only — tests and generated dropped): Degree-of-Coupling = shared ÷ min individual revisions, reported above noise floors (each file ≥10 revisions, ≥5 shared commits, ≥50% strength); sweeping commits excluded. Deterministic over fixed history.
Coverage: Population: PRODUCTION source files only — test and generated files are dropped before pairing, so a class co-changing with its own test (trivially ~100%) can't drown the real production↔production coupling. Pairs ranked by Degree-of-Coupling. A non-source file is never a coupling PARTICIPANT either: documentation, schemas, config and data files are dropped with the rest, so a code↔docs pair — a command and the reference page that restates it — is not reported however strongly the two co-change; nor is coupling that runs THROUGH a build step or config file.
Resolve the 7 Change coupling finding(s) in Change Coupling — start with type_table.rs (2), map_db.rs, buck_check.rs. — One of this dimension's main actionable groups (7 warning-level).
Resolve the 1 Change-coupling hub finding(s) in Change Coupling — start with binding_memory.rs. — One of this dimension's main actionable groups (1 warning-level).
Detailed fixes: d35_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether the build pipeline provides supply-chain integrity — generated provenance/attestation, signed artifacts (cosign/sigstore), an SBOM, and pinned build actions. Presence of the configuration, not a runtime guarantee.
Method: Supply-chain provenance/signing read deterministically from CI/build config (.github/workflows, .gitlab-ci.yml, azure-pipelines, Jenkinsfile, .circleci) + the release surface: four signals — generated provenance/attestation (SLSA/in-toto/actions-attest), artifact signing (cosign/sigstore/gitsign), an SBOM (syft/sbom-action/*.spdx.json/*.cdx.json), and SHA-pinned build actions — scored 10·present/denom. NotApplicable without a build pipeline. Detects configuration presence, not runtime enforcement.
+ 2 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Resolve the 4 REDACTED finding(s) in Supply-chain Provenance & Signing — start with REDACTED, REDACTED, REDACTED. — One of this dimension's main actionable groups (4 warning-level).
Resolve the 3 REDACTED finding(s) in Supply-chain Provenance & Signing — start with REDACTED, REDACTED, REDACTED. — One of this dimension's main actionable groups (3 warning-level).
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).
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 5 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.
Do you agree with this assessment?
AX8 · Test isolation10.0 / 10Exemplary✓ Tool-verified
Other · Architecture — Whether production projects stay free of references to test projects — tests may depend on production, never the reverse.
Method: Csproj graph: each production project checked for references to test projects (identified by test-framework presence, not name). Zero violations is clean. Deterministic.
Other · Architecture — Whether read (query) handlers stay side-effect-free — a query that writes persistent state or raises events breaks CQS and makes reads unsafe to retry, cache, or route to a read replica.
Method: Roslyn scan: CQRS handlers classified query-vs-command by interface (IQueryHandler/ICommandHandler/IRequestHandler<TQuery,TResult>) and name convention (*Query/Get*/Find* vs *Command); each query handler's body checked for persistent-state writes (SaveChanges/repository Add-Update) or event publishes by resolved invocation. Deterministic, type-level, exhaustive over the detected handlers.
Coverage: Population: CQRS handlers identified by IQueryHandler/ICommandHandler/IRequestHandler interface + *Query/Get*/Find*/*Command NAME convention; query purity then checked exhaustively within that set — a query handler using neither convention is invisible, and mutation is a resolved persistence/publish CALL, not full dataflow.
`ConfigFile.get_paths_to_watch` is a read-named query yet it performs a durable write on the read path (a persist to a store/repository). A query must stay side-effect-free so reads are safe to retry, cache, and route to a read replica; move the write into a command. — crates/pyrefly_config/src/config.rs:1636
`ConfigFile.query_source_db` is a read-named query yet it performs a durable write on the read path (a persist to a store/repository). A query must stay side-effect-free so reads are safe to retry, cache, and route to a read replica; move the write into a command. — crates/pyrefly_config/src/config.rs:1699
What to do
Keep query handlers read-only — move the writes/event-publishes into a command handler so reads stay safe to retry, cache, and route to a read replica.
Other · Event Sourcing — Whether the recovery-replay fold is deterministic — state derived purely from each event's own fields, no clock/random/IO on the replay path.
Method: Roslyn syntax scan (event-sourcing gated): Apply/When folds checked for forbidden tokens (DateTime.Now, Guid.NewGuid, Random, IO), stripped of comments/strings. Deterministic, hard fact per fold.
Other · Event Sourcing — Whether domain events stay immutable (private fields, set once) rather than carrying mutable state.
Method: Roslyn scan (event-sourcing gated): persisted events checked for public setters; immutability verified per property/field. Deterministic, hard fact.
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.
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.
Maturity · Maturity — Whether the repository is organised deliberately: production code and tests are set apart in a way its ecosystem or the repository itself declares.
Method: Filesystem scan: src/test folder separation and namespace-prefix consistency (majority RootNamespace agreement). Exhaustive across projects, deterministic.
Maturity · Maturity — Whether the project's current-state documentation describes the code that exists.
Method: Every current-state document's checkable claims looked up in the tree (links, versions, and artefact counts an order of magnitude off), plus two README checks: an advertised infrastructure product with no footprint, and a module the CHANGELOG records as removed. Deterministic, no model. Advisory.
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 · Observability5.4 / 10Adequate✓ Tool-verified
Readiness · Readiness — Whether the code is diagnosable in production — structured logging, tracing/metrics, health checks.
Only 5/11 runnable modules use logging (modules with no entry point or server are excluded — they are libraries a runnable module hosts). Silent: `pyrefly`, `tensor-shapes/jax-pyrefly-stubs`, `tensor-shapes/pyrefly-einops-stubs`, `tensor-shapes/pyrefly-numpy-stubs`, `tensor-shapes/pyrefly-shape-extensions` and 1 more.
What to do
Extend structured logging to the remaining runnable modules so everything you run is diagnosable in production.
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.
`lsp/package.json` declares packages, and nothing in the repository keeps them current: no Dependabot or Renovate configuration that schedules updates, and no dependency-review gate on pull requests. A pinned dependency stays at the version it was added at until someone notices — including after an advisory is published against it. Add a `.github/dependabot.yml` with one `package-ecosystem` entry per ecosystem the tree uses (or an enabled `renovate.json`), and gate pull requests with `actions/dependency-review-action`. — lsp/package.json:440
What to do
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.
Readiness · Performance — Whether the code protects its performance with benchmarks — a benchmark suite, allocation/memory measurement, and (ideally) a CI gate. Presence is credited as a bonus, never a deduction.
Method: Repo + source scan: BenchmarkDotNet referenced (csproj/source), [Benchmark]/[MemoryDiagnoser] attribute counts, and a benchmark step in CI; off .NET, the same ladder over Go testing.B, Rust criterion/#[bench]/divan, JMH/kotlinx-benchmark, pytest-benchmark/asv/pyperf, tinybench/mitata/vitest bench/benchmark.js and Swift package-benchmark — scored as a bonus ladder (absence is neutral, never a deduction). Deterministic, presence detection.
Readiness · Performance — Whether asynchronous code stays responsive — it avoids sync-over-async blocking (a .NET .Wait()/.GetAwaiter().GetResult(), a time.sleep or blocking HTTP call inside a Python coroutine, a *Sync call inside an async JavaScript function, block_on inside a Rust async fn, runBlocking inside a Kotlin suspend function, block() inside a Reactor publisher) that stalls a thread or event loop and risks deadlock, and, where the code is a reusable library on .NET, awaits with ConfigureAwait(false) so it never captures and stalls its caller's context.
Method: Production-source scan: sync-over-async blocking counted everywhere — .Wait()/.GetAwaiter().GetResult() in .NET; off .NET, read from each language's code model, a blocking call inside an async function (Python, TS/JS, Rust, Kotlin, Swift, Dart) or inside a Java method returning a Reactor Mono/Flux or a Scala method returning a Future or effect — and, for a .NET library with ≥5 awaits, the share of awaits using ConfigureAwait(false). Deterministic, syntax/text detection.
`fs.statSync` in `size` blocks the event loop until it finishes — a blocking call inside async code stalls the event loop — every other request waits for as long as it runs. — pyrefly/benches/tsp/record/runner/index.js:56
`fs.readFileSync` in `run` blocks the event loop until it finishes — a blocking call inside async code stalls the event loop — every other request waits for as long as it runs. (×2) — pyrefly/benches/tsp/record/runner/index.js:79, pyrefly/benches/tsp/record/runner/index.js:91
What to do
TypeScript/JavaScript: use the promise APIs (fs/promises, a promisified child_process.execFile, the async zlib/crypto functions) and await them instead of the *Sync variants.
Do you agree with this assessment?
R1 · Type Safety7.9 / 10Strong✓ Tool-verified
React / JS · Code Health — How much of the frontend is typed TypeScript vs untyped JavaScript.
Method: Frontend file inventory: the share of typed TypeScript vs untyped JavaScript across the source tree. Deterministic, exhaustive over frontend files.
React / JS · Code Health — The share of the scored frontend lines inside a near-exact copy-pasted block of substantial extent (the D4 clone algorithm over JS/TS tokens, D-386; each line once, 10 at none and 0 at a quarter of the lines, as D4): a block is reported only where its copies still agree on most of their own identifiers and literals, or were renamed as they were pasted but kept most of their constants, and where the copies carry enough code to stand on their own or the copied extent reaches 30 lines — so a re-implementation sharing neither names nor values, and a small pasted declaration, are both found and deliberately not reported, and a clean R10 is not a claim that nothing was copied.
Method: Near-exact copy-pasted blocks of substantial extent across the frontend (the D4 clone algorithm run over JS/TS tokens). Masking finds the candidates; a block is reported when its copies still agree on most of their own identifiers and literals, or when a renamed copy still agrees on most of its constants, AND the copies carry enough code to stand on their own — or when the copied extent reaches 30 lines. So a re-implementation sharing neither names nor values, and a small pasted declaration, are deliberately not counted. Scored on the share of the scored frontend lines inside a reported copy, on the same curve as D4. Deterministic.
lsp/src/extension.ts:148 · lsp/src/extension.ts:443 — the two spans are one implementation copied and then locally edited — 91 tokens are still identical, in the same order in both spans, with only local edits between them. The copies have already begun to drift, which is this row's finding: an edit made to one and not the other changes behaviour silently. Diff the two spans first to learn what genuinely differs, then extract the shared core into one module both sites use, passing the differences in as parameters — or, if one copy exists only because the other could not be imported from its context, make one of them the single source the other is generated or re-exported from. If one copy is no longer reachable, delete it rather than letting it shadow the live one. — lsp/src/extension.ts:148
lsp/src/code-lens.ts:219 · lsp/src/code-lens.ts:246 — the two spans are one implementation copied and then locally edited — 62 tokens are still identical, in the same order in both spans, with only local edits between them. The copies have already begun to drift, which is this row's finding: an edit made to one and not the other changes behaviour silently. Diff the two spans first to learn what genuinely differs, then extract the shared core into one module both sites use, passing the differences in as parameters — or, if one copy exists only because the other could not be imported from its context, make one of them the single source the other is generated or re-exported from. If one copy is no longer reachable, delete it rather than letting it shadow the live one. — lsp/src/code-lens.ts:219
lsp/src/code-lens.ts:53 · lsp/src/code-lens.ts:64 — all 2 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported. — lsp/src/code-lens.ts:53
What to do
Act on each finding's own remediation rather than one rule: the move depends on what recurs. Where the copies are executable blocks, give the shared part one home and call it from each site; where they are declarations, a listing, a specialisation already delegating to its base, or one shape repeated per entity, there is no call site and the move is a shared type, a generated set or a factory — sometimes there is nothing to extract.
React / JS · Code Health — Per-function cyclomatic/cognitive complexity from the token-level function scanner (D-386) — real branching, not a regex heuristic.
Method: Per-function cyclomatic/cognitive complexity from a token-level function scanner (real branching, not a regex heuristic), computed over every frontend function. Deterministic.
provideCodeLenses has cyclomatic complexity 22 and cognitive complexity 26; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — lsp/src/overrideCodeLens.ts:144
runTestAtLocation has cyclomatic complexity 14 and cognitive complexity 17; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — lsp/src/code-lens.ts:245
updateStatusBar has cyclomatic complexity 13 and cognitive complexity 13; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — lsp/src/status-bar.ts:57
selectBinary has cyclomatic complexity 11 and cognitive complexity 11; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — lsp/src/lsp-path.ts:120
Do you agree with this assessment?
R3 · Large Files6.7 / 10Adequate✓ Tool-verified
React / JS · Code Health — How many source files exceed the large-file threshold.
Method: Components/modules exceeding the large-file threshold, counted exhaustively across the frontend source tree. Deterministic.
lsp/src/extension.ts has 631 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — lsp/src/extension.ts:1
What to do
Split each oversized file along the responsibilities already in it, into smaller focused modules in the same package.
Do you agree with this assessment?
R4 · Test Coverage7.5 / 10Strong✓ Tool-verified
React / JS · Readiness — Static test reachability (D-386): the share of production files reachable from any test via the import graph — measured without running anything.
Method: Static test reachability: the share of production files reachable from any test via the import graph — measured without running anything. Deterministic.
No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one. (×3) — pyrefly_wasm/pyrefly_wasm.js:1, lsp/esbuild.js:1, lsp/build-pyrefly.js:1
What to do
Add tests that import the unreached modules (directly or through their public entry).
React / JS · Readiness — How outdated the npm dependencies are (a maturity signal). JS/npm CVEs are scored separately in D30 (JS/npm Dependency Vulnerabilities).
Method: npm dependency staleness from manifest/registry metadata (a maturity signal; JS/npm CVEs are scored separately in D30, which answers dependency vulnerabilities for every ecosystem). Deterministic.
Do you agree with this assessment?
R6 · Tooling10.0 / 10Exemplary✓ Tool-verified
React / JS · Readiness — Whether the project wires up test, lint and typecheck — detected from each package.json script's COMMAND (eslint / tsc / vitest / jest / playwright), not just its name, and corroborated against CI-workflow invocations so a tool run only in CI still counts.
Method: package.json scanned for test/lint/typecheck script wiring. Deterministic presence check.
Do you agree with this assessment?
R7 · Dead Code9.9 / 10Exemplary✓ Tool-verified
React / JS · Code Health — Files unreachable from every application/tooling/test entry point, and exports nothing imports (module-graph reachability, D-386).
Method: Dead code: files unreachable from every application/tooling/test entry point plus exports nothing imports, via module-graph reachability. Deterministic, exhaustive over the import graph.
Nothing imports this binding — it is safe to review for removal. — lsp/src/lsp-path.ts:33
React / JS · Readiness — npm dependency truthfulness (D-386): unused dependencies, imports not declared anywhere, and type-/test-only packages shipped as production deps.
Method: npm dependency truthfulness: unused dependencies, imports declared nowhere, and type-/test-only packages shipped as production deps — from the manifest + import graph. Deterministic.
Declared in lsp/package.json but never imported anywhere in that package or its workspace members — no static import reaches it. Usually that is dead weight and attack surface, but two shapes are indistinguishable from source and are NOT dead: an optional or native peer that another dependency loads dynamically at runtime, and a package a build, docs or test step installs and invokes separately. Confirm which of the three this is before removing it. (×3)
What to do
Remove unused dependencies, declare unlisted imports explicitly, and demote type-/test-only packages to devDependencies.
React / JS · Architecture — Import cycles in the module graph (D-386) — files that can only be understood and changed together.
Method: Import cycles in the module graph, detected exhaustively over JS/TS imports (the same cycle detection as the .NET coupling dimension). Deterministic.
Other · Code Health — Whether the code avoids sync-over-async (deadlock-prone blocking on tasks) and async void.
Method: Roslyn syntax scan: async methods scanned for .Wait()/.GetAwaiter().GetResult() and async-void outside event handlers. Deterministic, hard fact per invocation.
Other · Code Health — Whether async functions that make a cancellable request accept or pass on an AbortSignal (adoption curve).
Method: Roslyn scan: every async method (excluding framework-fixed overrides/Blazor handlers) checked for CancellationToken parameter presence. Deterministic, adoption percentage. On a repository with no .NET source it reads JavaScript/TypeScript off the engine’s own token stream (test, vendored and minified paths not) with the same question: every named async function that itself makes a request an AbortSignal can cancel (global `fetch`, axios and its file-local instances, ky, ofetch) counts, and it is compliant when its parameters or body name a signal or it hands one of its own parameters to the request as options; signatures a framework fixes (JSX event handlers, route and lifecycle exports, request-first handlers, `override`, `'use server'` modules, TanStack `mutationFn`) are exempt unless they take a signal. Deterministic, adoption percentage.
Only 0/1 async functions that make a cancellable request (fetch, axios, ky, ofetch, got, undici, node:http) accept an AbortSignal or pass one on, so a request keeps running after whatever wanted it has given up — a page navigated away from, an unmounted component, a timed-out job. Take a `signal` (or an options object that carries one) and hand it to the request; where nothing could ever cancel the call, omitting it is a deliberate choice — judge against how the function is used.
`compile` awaits `fetch(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `fetch(url, { signal })`. — pyrefly_wasm/pyrefly_wasm.js:344
What to do
Thread an AbortSignal through async functions that make requests, so the work stops when its caller gives up.
Other · Code Health — Whether a `when` guard is free of side effects — a guard that increments a counter or assigns while deciding whether its arm matches applies that change during PATTERN MATCHING, on an arm that may not be selected, and skips it entirely when a short-circuit to its left answers first.
Method: Roslyn syntax: `when` guards on case labels and switch-expression arms, read for a mutation (`++`/`--`/assignment) sitting in a position the guard's own `&&`/`||`/`??`/`?:`/`?.` can skip. Deterministic, provable per finding. Advisory.
Do you agree with this assessment?
X27 · Collection changed while being enumerated10.0 / 10Exemplary○ Nothing flagged
Other · Code Health — Whether a `for` loop leaves the `RefCell` it is walking alone — safe Rust rejects a body that changes the collection its loop borrows at compile time, except through interior mutability: a `RefCell` borrowed in the loop's header stays borrowed until the loop ends, so a `borrow_mut()` of it inside the body panics with `already borrowed: BorrowMutError` and the remaining elements 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?
X28 · Index access outside its own emptiness guard10.0 / 10Exemplary○ Nothing flagged
Other · Code Health — Whether a condition that tests a value for emptiness indexes that same value only where the test holds — an `||` written one parenthesis too far to the left leaves an index access outside the guard beside it, so the empty case the guard exists to anticipate reaches the index and throws.
Method: Roslyn syntax only, no semantic model: the OUTERMOST `&&`/`||` of every boolean condition, read for a symbol the condition tests for emptiness (`string.IsNullOrEmpty`/`IsNullOrWhiteSpace`, a `Length`/`Count` comparison against a literal, `Any()`, a `Length`/`Count` pattern, or a comparison against `""`) and ALSO indexes. Each `symbol[...]` access is placed by a boolean-reachability walk from the access up to the outermost connective: an access is COVERED when some enclosing step has it in the right operand and the left operand, under the truth value that step forces, proves the symbol non-empty — a recursion over `&&`/`||` whose true- and false-directions are asymmetric. A finding needs BOTH an uncovered access and a covered one on the same symbol in the same condition, which is the agreeing twin that separates a misplaced parenthesis from an unrelated length test. Bare index accesses with no emptiness test in the condition are neither counted nor reported; a non-identifier receiver and a lambda nested inside the condition are outside the population. Deterministic, provable per finding. Advisory.
Do you agree with this assessment?
X29 · Per-element action decided by a fixed element10.0 / 10Exemplary○ Nothing flagged
Other · Code Health — Whether a decision taken once per element is taken ABOUT that element — a test inside a counted loop that reads a fixed subscript of the very collection its guarded statement indexes by the loop variable applies element zero's answer to all of them, so the elements that differ from it are all handled wrongly, and in the same direction.
Method: Roslyn syntax only, no semantic model: every `for` statement declaring exactly ONE loop variable, and every `if` inside its body that is not under a nested loop or a lambda. A site enters the population when the `if`’s condition never mentions the loop variable while the statement it guards indexes some collection by that variable ALONE (`c[i]`; `c[i + 1]` and `c[i, j]` are outside it). A finding additionally needs the AGREEING TWIN at the same-collection grain: the condition must read THAT SAME collection at a subscript that does not move — written into the condition, or reached through a local declared BEFORE the loop, so an alias bound inside the body is not followed. Both collection expressions must be simple identifiers. On a repository with no .NET source the same rule reads JavaScript/TypeScript off the engine’s own token stream (tests included, bundles and vendored paths not): a `for (let|var|const x = …; …; …)` with one declarator and a braced body, an alias followed only when it is declared before the loop in a block that encloses it and never assigned inside the loop. Deterministic, provable per finding. Advisory.
Do you agree with this assessment?
X30 · Support guard that admits what it rejects10.0 / 10Exemplary○ Nothing flagged
Other · Code Health — Whether a guard written as a NEGATED `||` says what its author meant — `!(a || b || x != k)` is `!a && !b && x == k` by De Morgan, so a bail-out that mixes capabilities the code needs with a fault it refuses turns inside out: it fires only where the capabilities are ABSENT, and lets every value the fault term names walk straight into the body that cannot handle it.
Method: Roslyn syntax only, no semantic model: every logical-not whose operand is a parenthesised `||` chain of two or more disjuncts, flattened (a left-nested `a || b || c` read once would see `(a || b)` as one disjunct). A site enters the population on that shape alone. A finding additionally needs the disjuncts to DISAGREE in polarity: at least one bare boolean read — an identifier or member access, never an invocation, which is a predicate rather than a capability flag — and at least one `x != <constant>`, the only form that negates into an exact-value pin (`== null` negates into a looser requirement and is outside the fault set). Consistently-polarised disjunctions, all-fault or all-capability, are counted and never reported; a negated `&&` is outside the population entirely. No same-receiver gate: it was measured to cost a real defect and remove no false positive. Deterministic, provable per finding. Advisory.
Other · Code Health — Whether log calls use message templates (queryable) rather than interpolated strings.
Method: Roslyn syntax scan: every log call-site counted; interpolated-string first-argument violations flagged. Population is all log calls, not estimated. On a repository with no .NET source it reads JavaScript/TypeScript off the engine’s own token stream (test, vendored and minified paths not) with the same rule: a `trace`/`debug`/`info`/`warn`/`error`/`fatal`/`verbose`/`silly`/`http`/`log` call on a receiver named for a logger, in a package whose own or an enclosing `package.json` declares a logger that carries values as fields (pino, pino-http, nestjs-pino, Fastify, winston, bunyan, tslog, LogTape, roarr), whose first deciding argument is a template literal with substitutions; an object-literal fields argument is stepped over, a plain string message clears the call. Python is read the same way: a `debug`/`info`/`warning`/`error`/`exception`/`critical`/`log` call on a logger in a file that imports the standard library’s `logging` or structlog (loguru, which formats at the call, is not judged), whose message is a whole f-string with a non-constant field; a `%`-formatted, `.format()`-ed or concatenated message is not convicted, as in C#. PHP is read the same way: a PSR-3 level call (`emergency`…`debug`, `log`) on a logger (`$logger`, `$this->logger`, Laravel’s `Log::`, `logger()`, `\Drupal::logger()`) in a package whose `composer.json` requires a PSR-3 logger or a framework that hands one out (psr/log, Monolog, Laravel, Symfony, Drupal, CakePHP), or a file that imports one, whose message is a double-quoted string interpolating a variable; a single-quoted message clears the call, and `sprintf` or `.` concatenation is not convicted, as in C#. Dart is read the same way: a `trace`/`debug`/`info`/`warn`/`error`/`fatal` call on Sentry’s structured logger (`Sentry.logger`) whose message is a whole string literal interpolating a value (`$name`, `${…}`); the `Sentry.logger.fmt` template API clears the call. Dart that logs only through loggers with one message and no fields (package:logging, package:logger, talker, dart:developer) is not applicable rather than a reach gap. Ruby is read the same way: a `trace`/`debug`/`info`/`warn`/`error`/`fatal` call on the console gem’s `Console` (declared by a Gemfile, gemspec or Gemfile.lock, or required) or, where SemanticLogger, Ougai or dry-logger is declared or required, on a receiver named for a logger (`logger`, `@logger`, `Rails.logger`, `log`), whose first deciding argument is, as the whole argument, a double-quoted string interpolating a non-constant value (`#{…}`, `#@ivar`); a plain literal clears the call, keyword arguments are the fields, and a block, `%`-format or `+` concatenation is not convicted. Ruby that logs only through the standard Logger (Rails.logger) is not applicable rather than a reach gap. Deterministic.
`info` at line 57 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog. — REDACTED:57
`info` at line 90 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog. — REDACTED:90
`error` at line 318 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.error("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.error("order moved", order_id=order_id, status=status)` with structlog. — conformance/conformance_output.py:318
`error` at line 333 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.error("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.error("order moved", order_id=order_id, status=status)` with structlog. — conformance/conformance_output.py:333
`warn!` at line 193 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — pyrefly/lib/tsp/server.rs:193
`warn!` at line 226 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — pyrefly/lib/tsp/server.rs:226
`info!` at line 734 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `info!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — pyrefly/lib/tsp/server.rs:734
`debug!` at line 1729 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — pyrefly/lib/state/state.rs:1729
`debug!` at line 2326 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — pyrefly/lib/state/state.rs:2326
`info!` at line 2769 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `info!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — pyrefly/lib/state/state.rs:2769
`debug!` at line 3440 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — pyrefly/lib/state/state.rs:3440
`debug!` at line 232 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — pyrefly/lib/report/pysa.rs:232
`error!` at line 191 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `error!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — pyrefly/lib/report/scip.rs:191
`debug!` at line 17 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — pyrefly/lib/report/pysa/step_logger.rs:17
`debug!` at line 25 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — pyrefly/lib/report/pysa/step_logger.rs:25
`debug!` at line 271 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — pyrefly/lib/module/typeshed.rs:271
`debug!` at line 274 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — pyrefly/lib/module/typeshed.rs:274
`warn!` at line 294 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — pyrefly/lib/module/typeshed.rs:294
`warn!` at line 44 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — pyrefly/lib/lsp/module_helpers.rs:44
`warn!` at line 56 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — pyrefly/lib/lsp/module_helpers.rs:56
`warn!` at line 68 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — pyrefly/lib/lsp/module_helpers.rs:68
`debug!` at line 260 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — pyrefly/lib/lsp/non_wasm/call_hierarchy.rs:260
`debug!` at line 264 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — pyrefly/lib/lsp/non_wasm/call_hierarchy.rs:264
`warn!` at line 109 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — pyrefly/lib/lsp/non_wasm/initial_configuration.rs:109
`info!` at line 145 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `info!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — pyrefly/lib/lsp/non_wasm/initial_configuration.rs:145
`debug!` at line 401 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — pyrefly/lib/lsp/non_wasm/queue.rs:401
`debug!` at line 423 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — pyrefly/lib/lsp/non_wasm/queue.rs:423
`info!` at line 434 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `info!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — pyrefly/lib/lsp/non_wasm/queue.rs:434
`info!` at line 628 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `info!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — pyrefly/lib/lsp/non_wasm/server.rs:628
`info!` at line 630 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `info!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — pyrefly/lib/lsp/non_wasm/server.rs:630
`error!` at line 1296 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `error!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — pyrefly/lib/lsp/non_wasm/server.rs:1296
`error!` at line 1308 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `error!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — pyrefly/lib/lsp/non_wasm/server.rs:1308
`error!` at line 1315 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `error!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — pyrefly/lib/lsp/non_wasm/server.rs:1315
`error!` at line 1343 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `error!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — pyrefly/lib/lsp/non_wasm/server.rs:1343
`error!` at line 1361 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `error!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — pyrefly/lib/lsp/non_wasm/server.rs:1361
`error!` at line 1364 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `error!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — pyrefly/lib/lsp/non_wasm/server.rs:1364
`error!` at line 1445 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `error!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — pyrefly/lib/lsp/non_wasm/server.rs:1445
`error!` at line 1465 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `error!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — pyrefly/lib/lsp/non_wasm/server.rs:1465
`error!` at line 1473 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `error!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — pyrefly/lib/lsp/non_wasm/server.rs:1473
`info!` at line 1599 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `info!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — pyrefly/lib/lsp/non_wasm/server.rs:1599
Other · Code Health — Whether strict null checking is enabled and not undermined by heavy `!` assertion — TypeScript's `strictNullChecks` (which `strict` turns on) is what makes `string` exclude `null` and `undefined`, and the postfix `!` is the operator that silences it.
Method: Roslyn compiler-options scan: NullableContextOptions per project; null-forgiving (!) suppression density per 1k syntax nodes. Deterministic, adoption plus suppression penalty.
Do you agree with this assessment?
Reference — by lens
The score is the rank-weighted fold of these lenses (worst-heaviest), each including its meta-dimensions; a lens with a Critical contributor is capped at Fair (its band reads "gated by …") and is never the strongest area however high its average.
Unscored — 2 check(s) recorded observations but carry no score
These checks ran and found something, but they do not carry a score — either by design (an advisory check reports evidence rather than grading it) or because they could not be scored here. They are excluded from the score for that reason, not because there was nothing to see.
X10 Duplicated predicate — 25 observation(s) recorded · Advisory — this card reports evidence and never carries a score.
X7 Silent fallback defaults — 5 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 — 64 check(s) not relevant to this codebase
These checks had nothing to measure here (no tests, no git history, the codebase is small, or the architecture style doesn't apply), so they're omitted above rather than scored low.
AC1 Text alternatives — Frontend below the scale floor (13 DOM element(s) < 25) — too little surface to assess accessibility.
AC2 Forms & labels — Frontend below the scale floor (13 DOM element(s) < 25) — too little surface to assess accessibility.
AC3 Page structure — Frontend below the scale floor (13 DOM element(s) < 25) — too little surface to assess accessibility.
AC4 Keyboard semantics — Frontend below the scale floor (13 DOM element(s) < 25) — too little surface to assess accessibility.
AC5 ARIA correctness — Frontend below the scale floor (13 DOM element(s) < 25) — too little surface to assess accessibility.
AC6 Visual & motion safety — Frontend below the scale floor (13 DOM element(s) < 25) — too little surface to assess accessibility.
AX1 Captive dependencies — Not applicable: this repository's JavaScript 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; Rust with no dependency-injection crate has no container to hand one lifetime's instance to another — every value is owned by the code that builds it, and the borrow checker rejects a longer-lived value keeping a borrow of a shorter-lived one; this repository's TypeScript imports no dependency-injection container and defines no container of its own — nothing that both registers and resolves bindings, and nothing that names two lifetimes — so nothing holds one lifetime's instance while handing out another's.
AX2 Stateful singletons — No container singleton was found, so there is no shared instance for concurrent requests to race on. No function in this Python code is served by a threaded web framework (a Flask, Bottle or FastAPI route, a Django or Pyramid view), so no module is shared between request threads. Rust's compiler refuses unsynchronised shared mutation — a value shared across threads must be Sync — so the race this check looks for cannot be written. TypeScript/JavaScript runs each process's requests on one event loop, so no two requests write a shared object at the same instant (interleaving across an await is a different defect).
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 — AX6 reached only 3% of this repository's production lines — rust (307,829 lines), python (31,108 lines) was left unread. Not scored: a score over a minority of the product would be published as the whole of it.
AX7 Slice cohesion — not applicable — not a vertical-slice architecture
AXB2 Runtime readiness — Advisory — this card reports evidence and never carries a score, so there is nothing missing here.
AXR1 Runtime accessibility — the dev server (`npm run start`) exited before it served a page. Likely cause (our sandbox): `npm run` found no package.json in the folder where our sandbox ran it. This is a limit of our sandbox, not of your repository. Last output: "npm error code ENOENT / npm error syscall open / npm error path <repo>/package.json / npm error errno -2 / npm error enoent Could not read package.json: Error: ENOENT: no such file or directory, open '<repo>/package.json' / npm error enoent This is related to npm not being able to find a file. / npm error enoent / npm error A complete log of this run can be found in: <path>" No runtime evidence was gathered. This is a statement about this run, not a statement about your application: nothing here says the surface is inaccessible, only that it was never rendered.
C1 Data Protection — 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 Diesel schema, a SeaORM entity, a Diesel or sqlx row struct, or a SQL CREATE TABLE or ALTER TABLE — and no database or data-store crate (sqlx, Diesel, SeaORM, rusqlite, tokio-postgres, MongoDB, …) in the source either, so this repository keeps no data at rest for these controls to protect.
C2 Access Controls — No access-control surface detected in the analyzed source — this repository starts no server another machine can reach (no actix-web HttpServer, axum::serve, Rocket launch, warp::serve, poem or salvo Server, tonic Server::builder, hyper or tiny_http server outside examples and tests, none bound beyond loopback). Access control is therefore N/A here — a crate 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 Diesel schema, a SeaORM entity, a Diesel or sqlx row struct, or a SQL CREATE TABLE or ALTER TABLE — and no database or data-store crate (sqlx, Diesel, SeaORM, rusqlite, tokio-postgres, MongoDB, …) 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 in a Diesel schema, a SeaORM entity, a Diesel or sqlx row struct, or a SQL CREATE TABLE or ALTER TABLE — and no database or data-store crate (sqlx, Diesel, SeaORM, rusqlite, tokio-postgres, MongoDB, …) in the source 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 in a Diesel schema, a SeaORM entity, a Diesel or sqlx row struct, or a SQL CREATE TABLE or ALTER TABLE — and no database or data-store crate (sqlx, Diesel, SeaORM, rusqlite, tokio-postgres, MongoDB, …) in the source either, so this repository keeps no personal data for a data subject to erase, export or consent over.
D11 Test Reliability — Test reliability not measured — JavaScript/TypeScript suite did not run
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.
D21 Naming Consistency — Naming consistency does not read html yet; not measured.
D22 Internal API Consistency — API consistency is measured on C# only; the exposed Python, Rust 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"]`.
D25 ADR Conformance — no ADRs to check
D27 Navigability — D27 counts a call into the standard library or a dependency as unresolved for this repository's language (.rs), so too few call sites counted as resolved to assess navigability. 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) — 56 file(s) were not parsed by semgrep — the PII/GDPR ruleset never ran over them
D37 Vulnerability-disclosure Policy — No vulnerability-disclosure policy file found (SECURITY.md/.markdown/.rst/.txt at root or under .github/.forgejo/.gitea/docs, .well-known/security.txt). A coordinated-disclosure policy may live off-repo, so this is not evidenced rather than failed.
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.
D7 Architectural Integrity — no checkable ADRs, and no project-reference graph for the cycle pass to read — so this dimension makes no claim about dependency cycles in either direction (where this repository's language has an import-cycle lens, cycles are reported there). Architectural integrity not assessed
D8 Code Coverage — Coverage not measured — JavaScript/TypeScript suite
DM1 Domain Modelling — applicable but not scored (2 of 3 signals for this style — below the bar we score at): 379 value object(s); 1 domain event(s); its domain events are published by services or handlers — no domain entity raises one
ED2 Event/command shape — not scored — deciding whether a command has more than one competing handler requires resolving the call graph, and a call made through an inferred or generic receiver has no resolvable owner in the source. Reported as guidance rather than measured
ED5 Idempotency — no mutating command handlers or message consumers detected — idempotency check not applicable
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
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 applicable — no HTTP server, API framework or worker entry point was found in the JavaScript/TypeScript, Python, Rust source, so there is no service whose uptime a failing dependency could take down
P8 Schema migrations — no ORM, schema-migration tool or schema auto-create was found in this repository's dependency manifests or source, so there is no database schema for this check to judge
P9 Domain vs controller coverage — coverage not measured: this check compares the coverage of the analyzer's own test run across the domain and web layers, and that run measured none here — Test coverage (D8) says why
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.
R11 Import Boundaries — No recognizable feature-sliced/layered src layout — boundary rules not applicable.
S1 Web-Security Posture — No web surface: 469 Rust file(s) were read for weak hashes and ciphers, key material fixed in the source, disabled TLS certificate validation and obsolete TLS versions, and none was found. This repository serves no HTTP of its own — no HTTP-server crate (actix-web, axum, Rocket, warp, poem, tide, salvo, tonic, a hyper server, …) among its Cargo manifests' run-time dependencies, and no server started in its production source — so HTTPS enforcement, HSTS, cookie flags and input validation are N/A here, as they are for a C# library or worker. If this codebase starts serving HTTP, the dimension reactivates automatically.
SC1 Supply-chain hygiene — Advisory — this card reports evidence and never carries a score, so there is nothing missing here.
X12 Unreachable branch — X12 reached only 12% of this repository's production lines — rust (307,829 lines) was left unread. Not scored: a score over a minority of the product would be published as the whole of it.
X13 Undrained process stream — not applicable — the code was read and holds no site of this kind, so there is nothing for this check to judge
X14 Bypassable address classification — not applicable — the code was read and holds no site of this kind, so there is nothing for this check to judge
X15 Unvalidated length from an untrusted reader — not applicable — the code was read and holds no site of this kind, so there is nothing for this check to judge
X16 Unfloored truncation loop — X16 reached only 3% of this repository's production lines — rust (307,829 lines), python (31,108 lines) was left unread. Not scored: a score over a minority of the product would be published as the whole of it.
X17 Uncapped recursion over a caller-supplied document — X17 reached only 12% of this repository's production lines — rust (307,829 lines) was left unread. Not scored: a score over a minority of the product would be published as the whole of it.
X18 Disposal-pattern correctness — X18 reached only 3% of this repository's production lines — rust (307,829 lines), python (31,108 lines) was left unread. Not scored: a score over a minority of the product would be published as the whole of it.
X19 Unrestored process-global state — not applicable — the code was read and holds no site of this kind, so there is nothing for this check to judge
X20 Mistyped argument guard — This check asks whether an argument guard reports an EMPTY value as a NULL one, which needs a language that throws a null-specific argument exception — .NET's ArgumentNullException, the JVM's NullPointerException, Dart's ArgumentError.notNull. This repository contains none of those languages: the ones it is written in have a single exception for a bad argument, so there is no pair of exceptions to confuse and nothing here for it to assess. Not a gap in the analyzer and not a finding about your code.
X22 Contradicted release guard — not applicable — the code was read and holds no site of this kind, so there is nothing for this check to judge
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 — not applicable — the code was read and holds no site of this kind, so there is nothing for this check to judge
X25 Inert configuration knob — not applicable — the code was read and holds no site of this kind, so there is nothing for this check to judge
X26 Unsynchronised callback handoff — not applicable — the code was read and holds no site of this kind, so there is nothing for this check to judge
X3 Exception handling — X3 reached only 12% of this repository's production lines — rust (307,829 lines) was left unread. Not scored: a score over a minority of the product would be published as the whole of it.
X32 Type resolved by simple name across every loaded assembly — This check is about how a .NET program searches the assemblies loaded into its process for a type, and this repository contains no .NET source, so there is nothing here for it to assess. Not a gap in the analyzer and not a finding about your code.
X6 Hand-rolled structured-format parsing — Advisory — this card reports evidence and never carries a score, so there is nothing missing here.
X9 Subsumed condition operand — Advisory — this card reports evidence and never carries a score, so there is nothing missing here.
Appendix A — Findings (grouped)
The findings behind the scores, grouped by severity, then by dimension and kind. The high-severity issues are enumerated in full below; items per group are capped at 25 with any overflow stated explicitly per group, never silently truncated. The complete machine-readable list of every finding (all severities) is the companion findings.md in this report's bundle.
AX9 · CQS / query purity· Query writes persistent state on the read path · ×2
Query writes persistent state on the read path: ConfigFile.get_paths_to_watch crates/pyrefly_config/src/config.rs:1636— `ConfigFile.get_paths_to_watch` is a read-named query yet it performs a durable write on the read path (a persist to a store/repository). A query must stay side-effect-free so reads are safe to retry, cache, and route to a read replica; move the write into a command.
Query writes persistent state on the read path: ConfigFile.query_source_db crates/pyrefly_config/src/config.rs:1699— `ConfigFile.query_source_db` is a read-named query yet it performs a durable write on the read path (a persist to a store/repository). A query must stay side-effect-free so reads are safe to retry, cache, and route to a read replica; move the write into a command.
TodoComment website/src/sandbox/SandboxResults.tsx:60— // TODO (T217247871): expose full error message from Pyrefly binary and use it directly here instead of duplicating the logic — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment website/src/pages/sandbox.tsx:31— // TODO (T222948083) Re-enable internal sandbox after we fix issues with sandbox on static docs — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment website/src/components/landing-page/PerformanceComparisonChart.tsx:140— // TODO (T222936871): Add data for pandas and pytorch after we publish Pyrefly and get it to a stable state — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment tensor-shapes/pyrefly-torch-stubs/run_pyrefly.py:79— # TODO(stroxler): Check the Torch stubs too. The package predates stub — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment tensor-shapes/pyrefly-torch-stubs/test/test_advanced_indexing.py:31— # TODO: BUG: Preserve the broadcast shape of tensor indices. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment tensor-shapes/pyrefly-torch-stubs/test/test_classification_losses.py:70— # TODO: BUG: A known reduction should produce a scalar for unknown rank. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment tensor-shapes/pyrefly-torch-stubs/test/test_convolution.py:61— # TODO: BUG: Track per-axis convolution kernel sizes. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment tensor-shapes/pyrefly-torch-stubs/test/test_convolution.py:68— # TODO: BUG: Track per-axis convolution controls instead of using scalar defaults. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment tensor-shapes/pyrefly-torch-stubs/test/test_convolution.py:75— # TODO: BUG: Model string padding instead of using the scalar default. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment tensor-shapes/pyrefly-torch-stubs/test/test_convolution.py:110— # TODO: BUG: Accept singleton convolution control tuples. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment tensor-shapes/pyrefly-torch-stubs/test/test_creation.py:77— # TODO: BUG: Reject negative literal dimensions statically. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment tensor-shapes/pyrefly-torch-stubs/test/test_cumulative.py:46— # TODO: BUG: Reject out-of-range cumulative dimensions statically. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment tensor-shapes/pyrefly-torch-stubs/test/test_cumulative.py:50— # TODO: BUG: Reject out-of-range cumulative dimensions statically. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment tensor-shapes/pyrefly-torch-stubs/test/test_fft.py:33— # TODO: BUG: Reject nonpositive complex FFT lengths statically. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment tensor-shapes/pyrefly-torch-stubs/test/test_fft.py:86— # TODO: BUG: Reject nonpositive real FFT lengths statically. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment tensor-shapes/pyrefly-torch-stubs/test/test_fft.py:116— # TODO: BUG: Preserve known axes for optional transform lengths. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment tensor-shapes/pyrefly-torch-stubs/test/test_fft.py:127— # TODO: BUG: Preserve literal transform sizes rather than returning gradual. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment tensor-shapes/pyrefly-torch-stubs/test/test_fft.py:138— # TODO: BUG: Preserve literal transform sizes rather than returning gradual. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment tensor-shapes/pyrefly-torch-stubs/test/test_fft.py:155— # TODO: BUG: Validate multidimensional FFT axes and lengths statically. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment tensor-shapes/pyrefly-torch-stubs/test/test_fft.py:192— # TODO: BUG: Preserve literal real multidimensional FFT sizes statically. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment tensor-shapes/pyrefly-torch-stubs/test/test_fft.py:302— # TODO: BUG: Validate FFT shift dimensions statically. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment tensor-shapes/pyrefly-torch-stubs/test/test_index_put.py:38— # TODO: BUG: Reject more index tensors than input dimensions statically. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment tensor-shapes/pyrefly-torch-stubs/test/test_index_put.py:45— # TODO: BUG: Index tensor shapes must broadcast together. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment tensor-shapes/pyrefly-torch-stubs/test/test_index_put.py:53— # TODO: BUG: Values must broadcast to the indexed result shape. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment tensor-shapes/pyrefly-torch-stubs/test/test_indexing.py:53— # TODO: BUG: Reject out-of-bounds literal indices statically. — 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.
AnswersSolver::callable_infer_params (cognitive 368) pyrefly/lib/alt/callable.rs:1143— AnswersSolver::callable_infer_params has cognitive complexity 368 (threshold 15). Drivers by points: if/else 87 (233 pts), match/switch 26 (81 pts), loops 16 (36 pts), boolean chains 18 (nesting depth added 221). Of this number, 367 points are the body's own statements and 1 belongs to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AnswersSolver::calculate_class_field (cognitive 212) pyrefly/lib/alt/class/class_field.rs:1689— AnswersSolver::calculate_class_field has cognitive complexity 212 (threshold 15). Drivers by points: if/else 78 (143 pts), boolean chains 40, match/switch 9 (20 pts), loops 3 (9 pts) (nesting depth added 82). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AnswersSolver::atomic_narrow (cognitive 173) pyrefly/lib/alt/narrow.rs:1621— AnswersSolver::atomic_narrow has cognitive complexity 173 (threshold 15). Drivers by points: if/else 62 (131 pts), match/switch 8 (22 pts), loops 4 (12 pts), boolean chains 8 (nesting depth added 91). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
AnswersSolver::subscript_infer_for_type_with_key_present_inner (cognitive 142) pyrefly/lib/alt/expr.rs:3515— AnswersSolver::subscript_infer_for_type_with_key_present_inner has cognitive complexity 142 (threshold 15). Drivers by points: if/else 43 (94 pts), match/switch 13 (28 pts), boolean chains 13, loops 2 (7 pts) (nesting depth added 71). 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.
AnswersSolver::as_call_target_impl (cognitive 135) pyrefly/lib/alt/call.rs:412— AnswersSolver::as_call_target_impl has cognitive complexity 135 (threshold 15). Drivers by points: if/else 34 (79 pts), match/switch 18 (40 pts), loops 5 (14 pts), boolean chains 2 (nesting depth added 76). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
AnswersSolver::check_consistent_override_for_field (cognitive 131) pyrefly/lib/alt/class/class_field.rs:4468— AnswersSolver::check_consistent_override_for_field has cognitive complexity 131 (threshold 15). Drivers by points: if/else 45 (86 pts), boolean chains 28, match/switch 6 (13 pts), loops 2 (4 pts) (nesting depth added 50). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AnswersSolver::validate_type_shape_dsl_declaration (cognitive 109) pyrefly/lib/alt/type_level_dsl.rs:291— AnswersSolver::validate_type_shape_dsl_declaration has cognitive complexity 109 (threshold 15). Drivers by points: match/switch 15 (49 pts), if/else 22 (42 pts), boolean chains 11, loops 4 (7 pts) (nesting depth added 57). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AnswersSolver::subscript_str_literal (cognitive 103) pyrefly/lib/alt/subscript.rs:427— AnswersSolver::subscript_str_literal has cognitive complexity 103 (threshold 15). Drivers by points: if/else 37 (77 pts), match/switch 9 (21 pts), boolean chains 3, loops 1 (2 pts) (nesting depth added 53). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AnswersSolver::call_functools_partial (cognitive 95) pyrefly/lib/alt/functools.rs:45— AnswersSolver::call_functools_partial has cognitive complexity 95 (threshold 15). Drivers by points: if/else 30 (51 pts), match/switch 14 (27 pts), loops 5 (13 pts), boolean chains 4 (nesting depth added 42). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AnswersSolver::lookup_attr_static1 (cognitive 93) pyrefly/lib/alt/attr.rs:1848— AnswersSolver::lookup_attr_static1 has cognitive complexity 93 (threshold 15). Drivers by points: if/else 23 (42 pts), match/switch 16 (38 pts), boolean chains 8, loops 2 (5 pts) (nesting depth added 44). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
AnswersSolver::solve_expectation (cognitive 87) pyrefly/lib/alt/solve.rs:3009— AnswersSolver::solve_expectation has cognitive complexity 87 (threshold 15). Drivers by points: if/else 19 (43 pts), match/switch 8 (22 pts), boolean chains 18, loops 2 (4 pts) (nesting depth added 40). Of this number, 81 points are the body's own statements and 6 belong to one function item inside it that branches. The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
AnswersSolver::check_type_is_class_object (cognitive 83) pyrefly/lib/alt/special_calls.rs:613— AnswersSolver::check_type_is_class_object has cognitive complexity 83 (threshold 15). Drivers by points: if/else 18 (62 pts), loops 3 (14 pts), boolean chains 7 (nesting depth added 55). 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.
AnswersSolver::dict_items_infer_inner (cognitive 80) pyrefly/lib/alt/expr.rs:2313— AnswersSolver::dict_items_infer_inner has cognitive complexity 80 (threshold 15). Drivers by points: if/else 23 (61 pts), boolean chains 13, loops 1 (4 pts), match/switch 1 (2 pts) (nesting depth added 42). 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.
AnswersSolver::expr_infer_impl_helper (cognitive 75) pyrefly/lib/alt/expr.rs:1048— AnswersSolver::expr_infer_impl_helper has cognitive complexity 75 (threshold 15). Drivers by points: if/else 24 (41 pts), match/switch 15 (31 pts), loops 1 (2 pts), boolean chains 1 (nesting depth added 34). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
AnswersSolver::tuple_infer (cognitive 71) pyrefly/lib/alt/expr.rs:2021— AnswersSolver::tuple_infer has cognitive complexity 71 (threshold 15). Drivers by points: if/else 20 (46 pts), loops 6 (17 pts), match/switch 3 (7 pts), boolean chains 1 (nesting depth added 41). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AnswersSolver::check_shape_flag_constructor_sources (cognitive 71) pyrefly/lib/alt/shape_flag.rs:94— AnswersSolver::check_shape_flag_constructor_sources has cognitive complexity 71 (threshold 15). Drivers by points: if/else 12 (36 pts), loops 6 (17 pts), match/switch 5 (17 pts), boolean chains 1 (nesting depth added 47). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AnswersSolver::find_closest_overload (cognitive 70) pyrefly/lib/alt/overload.rs:867— AnswersSolver::find_closest_overload has cognitive complexity 70 (threshold 15). Drivers by points: if/else 24 (55 pts), loops 4 (8 pts), match/switch 2 (6 pts), boolean chains 1 (nesting depth added 39). 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.
AnswersSolver::as_attribute_base1 (cognitive 69) pyrefly/lib/alt/attr.rs:2640— AnswersSolver::as_attribute_base1 has cognitive complexity 69 (threshold 15). Drivers by points: if/else 16 (39 pts), loops 8 (25 pts), match/switch 2 (3 pts), boolean chains 2 (nesting depth added 41). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
AnswersSolver::narrow (cognitive 65) pyrefly/lib/alt/narrow.rs:2373— AnswersSolver::narrow has cognitive complexity 65 (threshold 15). Drivers by points: if/else 19 (36 pts), match/switch 10 (21 pts), boolean chains 5, loops 1 (3 pts) (nesting depth added 30). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AnswersSolver::is_class_attribute_subset (cognitive 62) pyrefly/lib/alt/class/class_field.rs:6209— AnswersSolver::is_class_attribute_subset has cognitive complexity 62 (threshold 15). Drivers by points: if/else 27 (54 pts), match/switch 3 (5 pts), boolean chains 3 (nesting depth added 29). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
AnswersSolver::decorated_function_type (cognitive 61) pyrefly/lib/alt/function.rs:861— AnswersSolver::decorated_function_type has cognitive complexity 61 (threshold 15). Drivers by points: if/else 24 (36 pts), boolean chains 21, loops 2, match/switch 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.
AnswersSolver::call_infer_with_callee_range (cognitive 59) pyrefly/lib/alt/call.rs:1881— AnswersSolver::call_infer_with_callee_range has cognitive complexity 59 (threshold 15). Drivers by points: if/else 19 (30 pts), match/switch 5 (14 pts), boolean chains 9, loops 3 (6 pts) (nesting depth added 23). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AnswersSolver::binding_to_type_unpacked_value (cognitive 58) pyrefly/lib/alt/solve.rs:5629— AnswersSolver::binding_to_type_unpacked_value has cognitive complexity 58 (threshold 15). Drivers by points: if/else 15 (32 pts), match/switch 9 (22 pts), boolean chains 3, loops 1 (nesting depth added 30). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AnswersSolver::check_consistent_multiple_inheritance (cognitive 57) pyrefly/lib/alt/class/class_field.rs:5004— AnswersSolver::check_consistent_multiple_inheritance has cognitive complexity 57 (threshold 15). Drivers by points: if/else 12 (38 pts), loops 6 (16 pts), boolean chains 3 (nesting depth added 36). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AnswersSolver::class_metadata_of (cognitive 57) pyrefly/lib/alt/class/class_metadata.rs:186— AnswersSolver::class_metadata_of has cognitive complexity 57 (threshold 15). Drivers by points: if/else 22 (33 pts), boolean chains 16, loops 4 (5 pts), match/switch 2 (3 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.
MethodTooLong: BindingsBuilder.stmt_impl pyrefly/lib/binding/stmt.rs:929— MethodTooLong — stmt_impl runs 1013 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 913 over it, 10.13× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: AnswersSolver.callable_infer_params pyrefly/lib/alt/callable.rs:1143— MethodTooLong — callable_infer_params runs 792 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 692 over it, 7.92× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: AnswersSolver.calculate_class_field pyrefly/lib/alt/class/class_field.rs:1689— MethodTooLong — calculate_class_field runs 755 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 655 over it, 7.55× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: Subset.is_subset_eq_no_recursive_check pyrefly/lib/solver/subset.rs:1922— MethodTooLong — is_subset_eq_no_recursive_check runs 712 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 612 over it, 7.12× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: StructurallyValidatedTypeShapeDslFunction.evaluate_expression crates/pyrefly_types/src/type_level_dsl.rs:6986— MethodTooLong — evaluate_expression runs 708 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 608 over it, 7.08× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: Server.process_event pyrefly/lib/lsp/non_wasm/server.rs:2099— MethodTooLong — process_event runs 644 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 544 over it, 6.44× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: TypeDisplayContext.fmt_helper_generic crates/pyrefly_types/src/display.rs:954— MethodTooLong — fmt_helper_generic runs 610 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 510 over it, 6.10× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: AnswersSolver.subscript_infer_for_type_with_key_present_inner pyrefly/lib/alt/expr.rs:3515— MethodTooLong — subscript_infer_for_type_with_key_present_inner runs 537 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 437 over it, 5.37× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: AnswersSolver.validate_type_shape_dsl_declaration pyrefly/lib/alt/type_level_dsl.rs:291— MethodTooLong — validate_type_shape_dsl_declaration runs 532 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 432 over it, 5.32× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: BindingsBuilder.bind_pattern pyrefly/lib/binding/pattern.rs:314— MethodTooLong — bind_pattern runs 450 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 350 over it, 4.50× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: AnswersSolver.expr_infer_impl_helper pyrefly/lib/alt/expr.rs:1048— MethodTooLong — expr_infer_impl_helper runs 389 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 289 over it, 3.89× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: AnswersSolver.is_class_attribute_subset pyrefly/lib/alt/class/class_field.rs:6209— MethodTooLong — is_class_attribute_subset runs 382 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 282 over it, 3.82× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: AnswersSolver.as_call_target_impl pyrefly/lib/alt/call.rs:412— MethodTooLong — as_call_target_impl runs 369 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 269 over it, 3.69× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: AnswersSolver.atomic_narrow pyrefly/lib/alt/narrow.rs:1621— MethodTooLong — atomic_narrow runs 363 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 263 over it, 3.63× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: DslValidator.validate_condition crates/pyrefly_types/src/type_level_dsl.rs:4652— MethodTooLong — validate_condition runs 357 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 257 over it, 3.57× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: AnswersSolver.check_consistent_override_for_field pyrefly/lib/alt/class/class_field.rs:4468— MethodTooLong — check_consistent_override_for_field runs 357 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 257 over it, 3.57× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: Transaction.find_definition pyrefly/lib/state/lsp.rs:3076— MethodTooLong — find_definition runs 339 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 239 over it, 3.39× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: CheckArgs.finish_cli_run pyrefly/lib/commands/check.rs:2122— MethodTooLong — finish_cli_run runs 332 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 232 over it, 3.32× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: AnswersSolver.solve_expectation pyrefly/lib/alt/solve.rs:3009— MethodTooLong — solve_expectation runs 331 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 231 over it, 3.31× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: DefinitionsBuilder.stmt pyrefly/lib/export/definitions.rs:667— MethodTooLong — stmt runs 329 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 229 over it, 3.29× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: StructurallyValidatedTypeShapeDslFunction.evaluate_condition crates/pyrefly_types/src/type_level_dsl.rs:8129— MethodTooLong — evaluate_condition runs 327 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 227 over it, 3.27× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: Subset.is_subset_eq_var pyrefly/lib/solver/solver.rs:3909— MethodTooLong — is_subset_eq_var runs 318 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 218 over it, 3.18× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: BindingsBuilder.ensure_expr pyrefly/lib/binding/expr.rs:796— MethodTooLong — ensure_expr runs 311 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 211 over it, 3.11× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: BindingsBuilder.class_def_inner pyrefly/lib/binding/class.rs:253— MethodTooLong — class_def_inner runs 308 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 208 over it, 3.08× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: AnswersSolver.call_infer_with_callee_range pyrefly/lib/alt/call.rs:1881— MethodTooLong — call_infer_with_callee_range runs 304 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 204 over it, 3.04× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
AnswersSolver::callable_infer_params (cyclomatic 147) pyrefly/lib/alt/callable.rs:1143— AnswersSolver::callable_infer_params has cyclomatic complexity 147 (threshold 15). Of this number, 145 points are the body's own statements and 2 belong to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
AnswersSolver::calculate_class_field (cyclomatic 132) pyrefly/lib/alt/class/class_field.rs:1689— AnswersSolver::calculate_class_field has cyclomatic complexity 132 (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.
AnswersSolver::atomic_narrow (cyclomatic 127) pyrefly/lib/alt/narrow.rs:1621— AnswersSolver::atomic_narrow has cyclomatic complexity 127 (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.
AnswersSolver::as_call_target_impl (cyclomatic 96) pyrefly/lib/alt/call.rs:412— AnswersSolver::as_call_target_impl has cyclomatic complexity 96 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
AnswersSolver::subscript_infer_for_type_with_key_present_inner (cyclomatic 94) pyrefly/lib/alt/expr.rs:3515— AnswersSolver::subscript_infer_for_type_with_key_present_inner has cyclomatic complexity 94 (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.
AnswersSolver::validate_type_shape_dsl_declaration (cyclomatic 80) pyrefly/lib/alt/type_level_dsl.rs:291— AnswersSolver::validate_type_shape_dsl_declaration has cyclomatic complexity 80 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
AnswersSolver::as_attribute_base1 (cyclomatic 77) pyrefly/lib/alt/attr.rs:2640— AnswersSolver::as_attribute_base1 has cyclomatic complexity 77 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
AnswersSolver::check_consistent_override_for_field (cyclomatic 76) pyrefly/lib/alt/class/class_field.rs:4468— AnswersSolver::check_consistent_override_for_field has cyclomatic complexity 76 (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.
AnswersSolver::binding_to_type (cyclomatic 75) pyrefly/lib/alt/solve.rs:7166— AnswersSolver::binding_to_type has cyclomatic complexity 75 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
AnswersSolver::solve_expectation (cyclomatic 70) pyrefly/lib/alt/solve.rs:3009— AnswersSolver::solve_expectation has cyclomatic complexity 70 (threshold 15). Of this number, 65 points are the body's own statements and 5 belong to one function item inside it that branches. To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
AnswersSolver::lookup_attr_static1 (cyclomatic 68) pyrefly/lib/alt/attr.rs:1848— AnswersSolver::lookup_attr_static1 has cyclomatic complexity 68 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
AnswersSolver::expr_infer_impl_helper (cyclomatic 68) pyrefly/lib/alt/expr.rs:1048— AnswersSolver::expr_infer_impl_helper has cyclomatic complexity 68 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
AnswersSolver::call_functools_partial (cyclomatic 54) pyrefly/lib/alt/functools.rs:45— AnswersSolver::call_functools_partial has cyclomatic complexity 54 (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.
AnswersSolver::as_attribute_base1_of_type (cyclomatic 49) pyrefly/lib/alt/attr.rs:2927— AnswersSolver::as_attribute_base1_of_type has cyclomatic complexity 49 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
AnswersSolver::expr_call_infer (cyclomatic 48) pyrefly/lib/alt/call.rs:3183— AnswersSolver::expr_call_infer has cyclomatic complexity 48 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
AnswersSolver::decorated_function_type (cyclomatic 48) pyrefly/lib/alt/function.rs:861— AnswersSolver::decorated_function_type has cyclomatic complexity 48 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
AnswersSolver::is_class_attribute_subset (cyclomatic 47) pyrefly/lib/alt/class/class_field.rs:6209— AnswersSolver::is_class_attribute_subset has cyclomatic complexity 47 (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.
AnswersSolver::class_metadata_of (cyclomatic 44) pyrefly/lib/alt/class/class_metadata.rs:186— AnswersSolver::class_metadata_of has cyclomatic complexity 44 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
AnswersSolver::parse_dimension_expr_with_context (cyclomatic 43) pyrefly/lib/alt/expr.rs:4290— AnswersSolver::parse_dimension_expr_with_context has cyclomatic complexity 43 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
AnswersSolver::subscript_str_literal (cyclomatic 43) pyrefly/lib/alt/subscript.rs:427— AnswersSolver::subscript_str_literal 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.
AnswersSolver::narrow (cyclomatic 42) pyrefly/lib/alt/narrow.rs:2373— AnswersSolver::narrow has cyclomatic complexity 42 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
AnswersSolver::call_infer_with_callee_range (cyclomatic 41) pyrefly/lib/alt/call.rs:1881— AnswersSolver::call_infer_with_callee_range has cyclomatic complexity 41 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
AnswersSolver::declared_bool_value (cyclomatic 37) pyrefly/lib/alt/solve.rs:2777— AnswersSolver::declared_bool_value has cyclomatic complexity 37 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
AnswersSolver::check_fstring_format_spec_for_type (cyclomatic 36) pyrefly/lib/alt/expr.rs:529— AnswersSolver::check_fstring_format_spec_for_type has cyclomatic complexity 36 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
AnswersSolver::apply_special_form (cyclomatic 36) pyrefly/lib/alt/specials.rs:349— AnswersSolver::apply_special_form has cyclomatic complexity 36 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
FileTooLong: src/type_level_dsl.rs crates/pyrefly_types/src/type_level_dsl.rs— FileTooLong — 6205 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted). The bar is 500 significant lines; this is 5705 over it, 12.41× 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: alt/solve.rs pyrefly/lib/alt/solve.rs— FileTooLong — 5748 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), about 95% of them inside a single declaration: AnswersSolver (397-8514). The bar is 500 significant lines; this is 5248 over it, 11.50× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
FileTooLong: non_wasm/server.rs pyrefly/lib/lsp/non_wasm/server.rs— FileTooLong — 5214 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), about 79% of them inside a single declaration: Server (3 blocks, 1156-7771). The bar is 500 significant lines; this is 4714 over it, 10.43× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
FileTooLong: class/class_field.rs pyrefly/lib/alt/class/class_field.rs— FileTooLong — 4697 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), about 78% of them inside a single declaration: AnswersSolver (1588-6959). The bar is 500 significant lines; this is 4197 over it, 9.39× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
FileTooLong: state/lsp.rs pyrefly/lib/state/lsp.rs— FileTooLong — 4215 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), about 78% of them inside a single declaration: Transaction (3 blocks, 853-6030). The bar is 500 significant lines; this is 3715 over it, 8.43× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
FileTooLong: alt/expr.rs pyrefly/lib/alt/expr.rs— FileTooLong — 3808 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), about 92% of them inside a single declaration: AnswersSolver (449-5368). The bar is 500 significant lines; this is 3308 over it, 7.62× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
FileTooLong: binding/scope.rs pyrefly/lib/binding/scope.rs— FileTooLong — 3136 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted). The bar is 500 significant lines; this is 2636 over it, 6.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: pysa/call_graph.rs pyrefly/lib/report/pysa/call_graph.rs— FileTooLong — 3035 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), about 67% of them inside a single declaration: CallGraphVisitor (3 blocks, 1501-4480). The bar is 500 significant lines; this is 2535 over it, 6.07× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
FileTooLong: alt/call.rs pyrefly/lib/alt/call.rs— FileTooLong — 2858 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), about 92% of them inside a single declaration: AnswersSolver (315-3821). The bar is 500 significant lines; this is 2358 over it, 5.72× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
FileTooLong: solver/solver.rs pyrefly/lib/solver/solver.rs— FileTooLong — 2760 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted). The bar is 500 significant lines; this is 2260 over it, 5.52× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: alt/polars_specials.rs pyrefly/lib/alt/polars_specials.rs— FileTooLong — 2661 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), about 70% of them inside a single declaration: AnswersSolver (1157-3809), declaring 38 free functions. The bar is 500 significant lines; this is 2161 over it, 5.32× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
FileTooLong: alt/attr.rs pyrefly/lib/alt/attr.rs— FileTooLong — 2519 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), about 84% of them inside a single declaration: AnswersSolver (2 blocks, 632-3817). The bar is 500 significant lines; this is 2019 over it, 5.04× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
FileTooLong: binding/binding.rs pyrefly/lib/binding/binding.rs— FileTooLong — 2447 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted). The bar is 500 significant lines; this is 1947 over it, 4.89× 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: state/state.rs pyrefly/lib/state/state.rs— FileTooLong — 2444 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted). The bar is 500 significant lines; this is 1944 over it, 4.89× 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: binding/bindings.rs pyrefly/lib/binding/bindings.rs— FileTooLong — 2329 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted). The bar is 500 significant lines; this is 1829 over it, 4.66× 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: alt/answers_solver.rs pyrefly/lib/alt/answers_solver.rs— FileTooLong — 2310 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted). The bar is 500 significant lines; this is 1810 over it, 4.62× 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: alt/function.rs pyrefly/lib/alt/function.rs— FileTooLong — 2239 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), about 90% of them inside a single declaration: AnswersSolver (304-3223). The bar is 500 significant lines; this is 1739 over it, 4.48× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
FileTooLong: solver/subset.rs pyrefly/lib/solver/subset.rs— FileTooLong — 2229 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), about 94% of them inside a single declaration: Subset (208-3385). The bar is 500 significant lines; this is 1729 over it, 4.46× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
FileTooLong: alt/narrow.rs pyrefly/lib/alt/narrow.rs— FileTooLong — 2005 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), about 94% of them inside a single declaration: AnswersSolver (125-2998). The bar is 500 significant lines; this is 1505 over it, 4.01× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
FileTooLong: alt/callable.rs pyrefly/lib/alt/callable.rs— FileTooLong — 1942 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), about 65% of them inside a single declaration: AnswersSolver (1013-2797). The bar is 500 significant lines; this is 1442 over it, 3.88× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
FileTooLong: commands/check.rs pyrefly/lib/commands/check.rs— FileTooLong — 1830 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), declaring 42 free functions. The bar is 500 significant lines; this is 1330 over it, 3.66× 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: class/class_metadata.rs pyrefly/lib/alt/class/class_metadata.rs— FileTooLong — 1707 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), about 93% of them inside a single declaration: AnswersSolver (149-2448). The bar is 500 significant lines; this is 1207 over it, 3.41× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
FileTooLong: binding/stmt.rs pyrefly/lib/binding/stmt.rs— FileTooLong — 1695 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), about 90% of them inside a single declaration: BindingsBuilder (259-2586). The bar is 500 significant lines; this is 1195 over it, 3.39× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
FileTooLong: src/types.rs crates/pyrefly_types/src/types.rs— FileTooLong — 1554 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), about 67% of them inside a single declaration: Type (4 blocks, 862-2628). The bar is 500 significant lines; this is 1054 over it, 3.11× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
FileTooLong: src/config.rs crates/pyrefly_config/src/config.rs— FileTooLong — 1484 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), about 64% of them inside a single declaration: ConfigFile (5 blocks, 611-2505). The bar is 500 significant lines; this is 984 over it, 2.97× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
Hotspot: crates/pyrefly_types/src/type_level_dsl.rs crates/pyrefly_types/src/type_level_dsl.rs:6986— crates/pyrefly_types/src/type_level_dsl.rs changed 87 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 278 in StructurallyValidatedTypeShapeDslFunction::evaluate_expression at line 6986. 3 of those changes were fix/bug commits, and the other 84 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 12:12:22 -08:00' --until='2026-11-13 12:12:22 -08:00' --full-history --no-merges -- crates/pyrefly_types/src/type_level_dsl.rs`: 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: pyrefly/lib/solver/subset.rs pyrefly/lib/solver/subset.rs:1922— pyrefly/lib/solver/subset.rs changed 65 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 251 in Subset::is_subset_eq_no_recursive_check at line 1922. 9 of those changes were fix/bug commits, and the other 56 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 12:12:22 -08:00' --until='2026-11-13 12:12:22 -08:00' --full-history --no-merges -- pyrefly/lib/solver/subset.rs`: 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: pyrefly/lib/alt/class/class_field.rs pyrefly/lib/alt/class/class_field.rs:1689— pyrefly/lib/alt/class/class_field.rs changed 116 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 132 in AnswersSolver::calculate_class_field at line 1689. 24 of those changes were fix/bug commits, and the other 92 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 12:12:22 -08:00' --until='2026-11-13 12:12:22 -08:00' --full-history --no-merges -- pyrefly/lib/alt/class/class_field.rs`: 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: pyrefly/lib/alt/solve.rs pyrefly/lib/alt/solve.rs:7166— pyrefly/lib/alt/solve.rs changed 183 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 75 in AnswersSolver::binding_to_type at line 7166. 15 of those changes were fix/bug commits, and the other 168 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 12:12:22 -08:00' --until='2026-11-13 12:12:22 -08:00' --full-history --no-merges -- pyrefly/lib/alt/solve.rs`: 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: pyrefly/lib/binding/stmt.rs pyrefly/lib/binding/stmt.rs:929— pyrefly/lib/binding/stmt.rs changed 62 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 188 in BindingsBuilder::stmt_impl at line 929. 10 of those changes were fix/bug commits, and the other 52 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 12:12:22 -08:00' --until='2026-11-13 12:12:22 -08:00' --full-history --no-merges -- pyrefly/lib/binding/stmt.rs`: 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: pyrefly/lib/alt/expr.rs pyrefly/lib/alt/expr.rs:3515— pyrefly/lib/alt/expr.rs changed 121 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 94 in AnswersSolver::subscript_infer_for_type_with_key_present_inner at line 3515. 13 of those changes were fix/bug commits, and the other 108 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 12:12:22 -08:00' --until='2026-11-13 12:12:22 -08:00' --full-history --no-merges -- pyrefly/lib/alt/expr.rs`: 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: pyrefly/lib/lsp/non_wasm/server.rs pyrefly/lib/lsp/non_wasm/server.rs:2099— pyrefly/lib/lsp/non_wasm/server.rs changed 81 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 136 in Server::process_event at line 2099. 9 of those changes were fix/bug commits, and the other 72 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 12:12:22 -08:00' --until='2026-11-13 12:12:22 -08:00' --full-history --no-merges -- pyrefly/lib/lsp/non_wasm/server.rs`: 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: pyrefly/lib/alt/callable.rs pyrefly/lib/alt/callable.rs:1143— pyrefly/lib/alt/callable.rs changed 56 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 147 in AnswersSolver::callable_infer_params at line 1143. 8 of those changes were fix/bug commits, and the other 48 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 12:12:22 -08:00' --until='2026-11-13 12:12:22 -08:00' --full-history --no-merges -- pyrefly/lib/alt/callable.rs`: 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: crates/pyrefly_types/src/display.rs crates/pyrefly_types/src/display.rs:954— crates/pyrefly_types/src/display.rs changed 46 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 160 in TypeDisplayContext::fmt_helper_generic at line 954. 5 of those changes were fix/bug commits, and the other 41 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 12:12:22 -08:00' --until='2026-11-13 12:12:22 -08:00' --full-history --no-merges -- crates/pyrefly_types/src/display.rs`: 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: pyrefly/lib/alt/narrow.rs pyrefly/lib/alt/narrow.rs:1621— pyrefly/lib/alt/narrow.rs changed 56 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 127 in AnswersSolver::atomic_narrow at line 1621. 15 of those changes were fix/bug commits, and the other 41 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 12:12:22 -08:00' --until='2026-11-13 12:12:22 -08:00' --full-history --no-merges -- pyrefly/lib/alt/narrow.rs`: 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: pyrefly/lib/alt/call.rs pyrefly/lib/alt/call.rs:412— pyrefly/lib/alt/call.rs changed 72 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 96 in AnswersSolver::as_call_target_impl at line 412. 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 12:12:22 -08:00' --until='2026-11-13 12:12:22 -08:00' --full-history --no-merges -- pyrefly/lib/alt/call.rs`: 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: pyrefly/lib/binding/binding.rs pyrefly/lib/binding/binding.rs:2876— pyrefly/lib/binding/binding.rs changed 85 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 80 in Binding::fmt at line 2876. 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 12:12:22 -08:00' --until='2026-11-13 12:12:22 -08:00' --full-history --no-merges -- pyrefly/lib/binding/binding.rs`: 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: pyrefly/lib/alt/type_level_dsl.rs pyrefly/lib/alt/type_level_dsl.rs:291— pyrefly/lib/alt/type_level_dsl.rs changed 82 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 80 in AnswersSolver::validate_type_shape_dsl_declaration at line 291. 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 12:12:22 -08:00' --until='2026-11-13 12:12:22 -08:00' --full-history --no-merges -- pyrefly/lib/alt/type_level_dsl.rs`: 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: pyrefly/lib/alt/attr.rs pyrefly/lib/alt/attr.rs:2640— pyrefly/lib/alt/attr.rs changed 74 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 77 in AnswersSolver::as_attribute_base1 at line 2640. 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 12:12:22 -08:00' --until='2026-11-13 12:12:22 -08:00' --full-history --no-merges -- pyrefly/lib/alt/attr.rs`: 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: pyrefly/lib/state/lsp.rs pyrefly/lib/state/lsp.rs:3803— pyrefly/lib/state/lsp.rs changed 87 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 57 in Transaction::local_quickfix_code_actions_sorted at line 3803. 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 12:12:22 -08:00' --until='2026-11-13 12:12:22 -08:00' --full-history --no-merges -- pyrefly/lib/state/lsp.rs`: 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: pyrefly/lib/solver/solver.rs pyrefly/lib/solver/solver.rs:3909— pyrefly/lib/solver/solver.rs changed 83 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 55 in Subset::is_subset_eq_var at line 3909. 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 12:12:22 -08:00' --until='2026-11-13 12:12:22 -08:00' --full-history --no-merges -- pyrefly/lib/solver/solver.rs`: 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: pyrefly/lib/commands/check.rs pyrefly/lib/commands/check.rs:2122— pyrefly/lib/commands/check.rs changed 59 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 63 in CheckArgs::finish_cli_run at line 2122. 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 12:12:22 -08:00' --until='2026-11-13 12:12:22 -08:00' --full-history --no-merges -- pyrefly/lib/commands/check.rs`: 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: pyrefly/lib/binding/expr.rs pyrefly/lib/binding/expr.rs:796— pyrefly/lib/binding/expr.rs changed 46 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 80 in BindingsBuilder::ensure_expr at line 796. 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 12:12:22 -08:00' --until='2026-11-13 12:12:22 -08:00' --full-history --no-merges -- pyrefly/lib/binding/expr.rs`: 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: pyrefly/lib/state/state.rs pyrefly/lib/state/state.rs:1559— pyrefly/lib/state/state.rs changed 76 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 37 in Transaction::demand at line 1559. 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 12:12:22 -08:00' --until='2026-11-13 12:12:22 -08:00' --full-history --no-merges -- pyrefly/lib/state/state.rs`: 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: pyrefly/lib/alt/function.rs pyrefly/lib/alt/function.rs:861— pyrefly/lib/alt/function.rs changed 58 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 48 in AnswersSolver::decorated_function_type at line 861. 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 12:12:22 -08:00' --until='2026-11-13 12:12:22 -08:00' --full-history --no-merges -- pyrefly/lib/alt/function.rs`: 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: pyrefly/lib/binding/scope.rs pyrefly/lib/binding/scope.rs:4777— pyrefly/lib/binding/scope.rs changed 93 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 29 in BindingsBuilder::merged_flow_info at line 4777. 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 12:12:22 -08:00' --until='2026-11-13 12:12:22 -08:00' --full-history --no-merges -- pyrefly/lib/binding/scope.rs`: 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: pyrefly/lib/binding/bindings.rs pyrefly/lib/binding/bindings.rs:1929— pyrefly/lib/binding/bindings.rs changed 107 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 22 in BindingsBuilder::stmts at line 1929. 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 12:12:22 -08:00' --until='2026-11-13 12:12:22 -08:00' --full-history --no-merges -- pyrefly/lib/binding/bindings.rs`: 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: crates/pyrefly_config/src/config.rs crates/pyrefly_config/src/config.rs:1808— crates/pyrefly_config/src/config.rs changed 73 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 26 in ConfigFile::configure_at at line 1808. 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 12:12:22 -08:00' --until='2026-11-13 12:12:22 -08:00' --full-history --no-merges -- crates/pyrefly_config/src/config.rs`: 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: pyrefly/lib/export/definitions.rs pyrefly/lib/export/definitions.rs:667— pyrefly/lib/export/definitions.rs changed 15 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 98 in DefinitionsBuilder::stmt at line 667. 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 12:12:22 -08:00' --until='2026-11-13 12:12:22 -08:00' --full-history --no-merges -- pyrefly/lib/export/definitions.rs`: 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: pyrefly/lib/alt/class/class_metadata.rs pyrefly/lib/alt/class/class_metadata.rs:186— pyrefly/lib/alt/class/class_metadata.rs changed 30 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 44 in AnswersSolver::class_metadata_of at line 186. 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 12:12:22 -08:00' --until='2026-11-13 12:12:22 -08:00' --full-history --no-merges -- pyrefly/lib/alt/class/class_metadata.rs`: 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.
pyrefly::lib::error::suppress::update_suppressions_in_files (cognitive 145) pyrefly/lib/error/suppress.rs:402— pyrefly::lib::error::suppress::update_suppressions_in_files has cognitive complexity 145 (threshold 15). Drivers by points: if/else 33 (101 pts), loops 10 (25 pts), match/switch 3 (10 pts), boolean chains 9 (nesting depth added 90). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
pyrefly::lib::commands::coverage::collect::parse_functions (cognitive 101) pyrefly/lib/commands/coverage/collect.rs:952— pyrefly::lib::commands::coverage::collect::parse_functions has cognitive complexity 101 (threshold 15). Drivers by points: if/else 28 (76 pts), boolean chains 13, match/switch 2 (7 pts), loops 3 (5 pts) (nesting depth added 55). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
pyrefly::lib::binding::attrs::collect_attrs_decorator_methods (cognitive 75) pyrefly/lib/binding/attrs.rs:94— pyrefly::lib::binding::attrs::collect_attrs_decorator_methods has cognitive complexity 75 (threshold 15). Drivers by points: if/else 18 (54 pts), loops 5 (13 pts), match/switch 2 (6 pts), boolean chains 2 (nesting depth added 48). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
pyrefly::lib::binding::function::function_last_expressions::f (cognitive 55) pyrefly/lib/binding/function.rs:1262— pyrefly::lib::binding::function::function_last_expressions::f has cognitive complexity 55 (threshold 15). Drivers by points: if/else 17 (30 pts), match/switch 4 (12 pts), loops 4 (9 pts), boolean chains 4 (nesting depth added 26). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
pyrefly::lib::alt::regex::validate_pattern (cognitive 49) pyrefly/lib/alt/regex.rs:21— pyrefly::lib::alt::regex::validate_pattern has cognitive complexity 49 (threshold 15). Drivers by points: if/else 16 (36 pts), match/switch 3 (9 pts), boolean chains 3, loops 1 (nesting depth added 26). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
pyrefly::lib::report::cinderx::collect::collect_call_contextual_types (cognitive 49) pyrefly/lib/report/cinderx/collect.rs:267— pyrefly::lib::report::cinderx::collect::collect_call_contextual_types has cognitive complexity 49 (threshold 15). Drivers by points: if/else 16 (38 pts), loops 3 (8 pts), match/switch 1 (2 pts), boolean chains 1 (nesting depth added 28). 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.
pyrefly::lib::state::lsp::quick_fixes::move_module::build_module_member_consumer_import_updates (cognitive 41) pyrefly/lib/state/lsp/quick_fixes/move_module.rs:198— pyrefly::lib::state::lsp::quick_fixes::move_module::build_module_member_consumer_import_updates has cognitive complexity 41 (threshold 15). Drivers by points: if/else 13 (33 pts), loops 3 (6 pts), boolean chains 1, match/switch 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.
pyrefly::lib::commands::coverage::collect::parse_variables (cognitive 36) pyrefly/lib/commands/coverage/collect.rs:463— pyrefly::lib::commands::coverage::collect::parse_variables has cognitive complexity 36 (threshold 15). Drivers by points: match/switch 8 (16 pts), if/else 8 (12 pts), boolean chains 7, loops 1 (nesting depth added 12). Of this number, 24 points are the body's own statements and 12 belong to 2 function items inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
pyrefly::lib::commands::coverage::collect::parse_instance_attrs (cognitive 36) pyrefly/lib/commands/coverage/collect.rs:814— pyrefly::lib::commands::coverage::collect::parse_instance_attrs has cognitive complexity 36 (threshold 15). Drivers by points: if/else 12 (25 pts), boolean chains 4, match/switch 2 (4 pts), loops 2 (3 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.
pyrefly::lib::export::symbols::build (cognitive 36) pyrefly/lib/export/symbols.rs:187— pyrefly::lib::export::symbols::build has cognitive complexity 36 (threshold 15). Drivers by points: if/else 10 (24 pts), loops 3 (7 pts), boolean chains 3, match/switch 1 (2 pts) (nesting depth added 19). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
pyrefly::lib::lsp::non_wasm::server::dispatch_lsp_events (cognitive 35) pyrefly/lib/lsp/non_wasm/server.rs:1489— pyrefly::lib::lsp::non_wasm::server::dispatch_lsp_events has cognitive complexity 35 (threshold 15). Drivers by points: if/else 18 (28 pts), match/switch 2 (6 pts), loops 1 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
pyrefly::lib::commands::coverage::collect::collect_module_reports (cognitive 33) pyrefly/lib/commands/coverage/collect.rs:1954— pyrefly::lib::commands::coverage::collect::collect_module_reports has cognitive complexity 33 (threshold 15). Drivers by points: if/else 13 (22 pts), loops 4 (7 pts), boolean chains 4 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
pyrefly::lib::commands::infer::format_hints (cognitive 33) pyrefly/lib/commands/infer.rs:193— pyrefly::lib::commands::infer::format_hints has cognitive complexity 33 (threshold 15). Drivers by points: if/else 13 (20 pts), match/switch 3 (7 pts), boolean chains 3, loops 2 (3 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
pyrefly::lib::state::lsp::quick_fixes::deprecated_contextmanager::replace_return_code_action (cognitive 33) pyrefly/lib/state/lsp/quick_fixes/deprecated_contextmanager.rs:44— pyrefly::lib::state::lsp::quick_fixes::deprecated_contextmanager::replace_return_code_action has cognitive complexity 33 (threshold 15). Drivers by points: if/else 16 (23 pts), match/switch 5 (6 pts), boolean chains 4 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
pyrefly::lib::lsp::non_wasm::document_symbols::build_symbols_with_sections (cognitive 32) pyrefly/lib/lsp/non_wasm/document_symbols.rs:64— pyrefly::lib::lsp::non_wasm::document_symbols::build_symbols_with_sections has cognitive complexity 32 (threshold 15). Drivers by points: if/else 11 (21 pts), loops 5 (9 pts), boolean chains 2 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
pyrefly::lib::module::finder::find_import_with_mode (cognitive 32) pyrefly/lib/module/finder.rs:667— pyrefly::lib::module::finder::find_import_with_mode has cognitive complexity 32 (threshold 15). Drivers by points: if/else 18, boolean chains 14. 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.
pyrefly::lib::stubgen::extract::extract_stmts (cognitive 32) pyrefly/lib/stubgen/extract.rs:174— pyrefly::lib::stubgen::extract::extract_stmts has cognitive complexity 32 (threshold 15). Drivers by points: if/else 8 (22 pts), loops 2 (5 pts), boolean chains 3, match/switch 1 (2 pts) (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
pyrefly::lib::commands::dump_config::dump_config (cognitive 28) pyrefly/lib/commands/dump_config.rs:103— pyrefly::lib::commands::dump_config::dump_config has cognitive complexity 28 (threshold 15). Drivers by points: if/else 8 (16 pts), loops 6 (10 pts), match/switch 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.
pyrefly::lib::state::ide::find_import_merge_edit (cognitive 28) pyrefly/lib/state/ide.rs:423— pyrefly::lib::state::ide::find_import_merge_edit has cognitive complexity 28 (threshold 15). Drivers by points: if/else 6 (20 pts), loops 2 (4 pts), boolean chains 2, match/switch 1 (2 pts) (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
pyrefly::lib::state::lsp::quick_fixes::extract_function::extract_function_code_actions (cognitive 27) pyrefly/lib/state/lsp/quick_fixes/extract_function.rs:39— pyrefly::lib::state::lsp::quick_fixes::extract_function::extract_function_code_actions has cognitive complexity 27 (threshold 15). Drivers by points: if/else 12 (21 pts), boolean chains 4, loops 2 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
pyrefly::lib::report::pysa::ast_visitor::visit_statement (cognitive 26) pyrefly/lib/report/pysa/ast_visitor.rs:264— pyrefly::lib::report::pysa::ast_visitor::visit_statement has cognitive complexity 26 (threshold 15). Drivers by points: if/else 12 (21 pts), loops 2 (4 pts), match/switch 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
pyrefly::lib::state::lsp::find_global_references_from_definition_impl (cognitive 25) pyrefly/lib/state/lsp.rs:5914— pyrefly::lib::state::lsp::find_global_references_from_definition_impl has cognitive complexity 25 (threshold 15). Drivers by points: if/else 9 (17 pts), loops 4 (5 pts), boolean chains 3 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
pyrefly::lib::state::lsp::quick_fixes::inline_variable::expand_statement_removal_range (cognitive 25) pyrefly/lib/state/lsp/quick_fixes/inline_variable.rs:242— pyrefly::lib::state::lsp::quick_fixes::inline_variable::expand_statement_removal_range has cognitive complexity 25 (threshold 15). Drivers by points: if/else 9 (11 pts), boolean chains 9, loops 4 (5 pts) (nesting depth added 3). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
pyrefly::lib::module::finder::resolve_third_party_stub (cognitive 24) pyrefly/lib/module/finder.rs:88— pyrefly::lib::module::finder::resolve_third_party_stub has cognitive complexity 24 (threshold 15). Drivers by points: if/else 13 (22 pts), boolean chains 2 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
pyrefly::lib::module::finder::find_extra_extension_module (cognitive 24) pyrefly/lib/module/finder.rs:366— pyrefly::lib::module::finder::find_extra_extension_module has cognitive complexity 24 (threshold 15). Drivers by points: if/else 11 (19 pts), loops 3 (5 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
BindingsBuilder::stmt_impl (cognitive 393) pyrefly/lib/binding/stmt.rs:929— BindingsBuilder::stmt_impl has cognitive complexity 393 (threshold 15). Drivers by points: if/else 119 (293 pts), match/switch 15 (46 pts), boolean chains 29, loops 10 (25 pts) (nesting depth added 220). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
BindingsBuilder::bind_pattern (cognitive 200) pyrefly/lib/binding/pattern.rs:314— BindingsBuilder::bind_pattern has cognitive complexity 200 (threshold 15). Drivers by points: if/else 57 (132 pts), boolean chains 25, match/switch 7 (25 pts), loops 6 (18 pts) (nesting depth added 105). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
BindingsBuilder::ensure_expr (cognitive 144) pyrefly/lib/binding/expr.rs:796— BindingsBuilder::ensure_expr has cognitive complexity 144 (threshold 15). Drivers by points: if/else 33 (75 pts), loops 13 (41 pts), match/switch 8 (16 pts), boolean chains 12 (nesting depth added 78). Of this number, 142 points are the body's own statements and 2 belong to one function item inside it that branches. The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
BindingsBuilder::stmt_match (cognitive 53) pyrefly/lib/binding/pattern.rs:965— BindingsBuilder::stmt_match has cognitive complexity 53 (threshold 15). Drivers by points: if/else 17 (31 pts), match/switch 6 (14 pts), boolean chains 5, loops 2 (3 pts) (nesting depth added 23). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
BindingsBuilder::type_params_with_owner (cognitive 45) pyrefly/lib/binding/bindings.rs:3152— BindingsBuilder::type_params_with_owner has cognitive complexity 45 (threshold 15). Drivers by points: if/else 13 (37 pts), loops 2 (6 pts), match/switch 1 (2 pts) (nesting depth added 29). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
BindingsBuilder::class_def_inner (cognitive 45) pyrefly/lib/binding/class.rs:253— BindingsBuilder::class_def_inner has cognitive complexity 45 (threshold 15). Drivers by points: if/else 17 (25 pts), match/switch 5 (9 pts), boolean chains 6, loops 4 (5 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.
BindingsBuilder::merged_flow_info (cognitive 45) pyrefly/lib/binding/scope.rs:4777— BindingsBuilder::merged_flow_info has cognitive complexity 45 (threshold 15). Drivers by points: if/else 14 (28 pts), boolean chains 9, match/switch 4 (6 pts), loops 2 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
BindingsBuilder::extract_pydantic_config_dict (cognitive 35) pyrefly/lib/binding/pydantic.rs:305— BindingsBuilder::extract_pydantic_config_dict has cognitive complexity 35 (threshold 15). Drivers by points: if/else 15 (22 pts), boolean chains 9, loops 1 (2 pts), match/switch 1 (2 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
BindingsBuilder::extract_django_fields_from_class_body (cognitive 34) pyrefly/lib/binding/django.rs:62— BindingsBuilder::extract_django_fields_from_class_body has cognitive complexity 34 (threshold 15). Drivers by points: if/else 8 (24 pts), loops 2 (4 pts), boolean chains 3, match/switch 1 (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.
BindingsBuilder::bind_module_exports (cognitive 34) pyrefly/lib/binding/stmt.rs:2489— BindingsBuilder::bind_module_exports has cognitive complexity 34 (threshold 15). Drivers by points: if/else 12 (29 pts), loops 2 (4 pts), boolean chains 1 (nesting depth added 19). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
BindingsBuilder::bind_single_name_assign (cognitive 32) pyrefly/lib/binding/target.rs:676— BindingsBuilder::bind_single_name_assign has cognitive complexity 32 (threshold 15). Drivers by points: if/else 19 (23 pts), boolean chains 8, match/switch 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.
BindingsBuilder::ensure_name_impl (cognitive 31) pyrefly/lib/binding/expr.rs:423— BindingsBuilder::ensure_name_impl has cognitive complexity 31 (threshold 15). Drivers by points: if/else 15 (24 pts), boolean chains 6, match/switch 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.
BindingsBuilder::merge_flow (cognitive 31) pyrefly/lib/binding/scope.rs:5047— BindingsBuilder::merge_flow has cognitive complexity 31 (threshold 15). Drivers by points: if/else 12 (13 pts), loops 8 (10 pts), boolean chains 7, match/switch 1 (nesting depth added 3). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
BindingsBuilder::typealiastype_from_call (cognitive 31) pyrefly/lib/binding/stmt.rs:663— BindingsBuilder::typealiastype_from_call has cognitive complexity 31 (threshold 15). Drivers by points: if/else 15 (25 pts), match/switch 2 (5 pts), loops 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
BindingsBuilder::stmts (cognitive 30) pyrefly/lib/binding/bindings.rs:1929— BindingsBuilder::stmts has cognitive complexity 30 (threshold 15). Drivers by points: if/else 12 (18 pts), boolean chains 8, match/switch 1 (3 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.
BindingsBuilder::prescan_synthesized_bases (cognitive 30) pyrefly/lib/binding/class.rs:173— BindingsBuilder::prescan_synthesized_bases has cognitive complexity 30 (threshold 15). Drivers by points: if/else 7 (20 pts), match/switch 2 (8 pts), loops 1 (2 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.
BindingsBuilder::function_body (cognitive 28) pyrefly/lib/binding/function.rs:877— BindingsBuilder::function_body has cognitive complexity 28 (threshold 15). Drivers by points: boolean chains 14, if/else 9 (10 pts), match/switch 3 (4 pts) (nesting depth added 2). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
BindingsBuilder::shape_comment_target (cognitive 28) pyrefly/lib/binding/shape_type.rs:314— BindingsBuilder::shape_comment_target has cognitive complexity 28 (threshold 15). Drivers by points: if/else 8 (18 pts), match/switch 3 (6 pts), boolean chains 3, loops 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
BindingsBuilder::ensure_type_impl (cognitive 27) pyrefly/lib/binding/expr.rs:1332— BindingsBuilder::ensure_type_impl has cognitive complexity 27 (threshold 15). Drivers by points: if/else 7 (11 pts), boolean chains 10, match/switch 4 (6 pts) (nesting depth added 6). Of this number, 25 points are the body's own statements and 2 belong to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
BindingsBuilder::special_export_from_binding_idx (cognitive 25) pyrefly/lib/binding/bindings.rs:2271— BindingsBuilder::special_export_from_binding_idx has cognitive complexity 25 (threshold 15). Drivers by points: if/else 6 (15 pts), match/switch 2 (6 pts), loops 2 (4 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.
BindingsBuilder::bind_targets_with_value (cognitive 25) pyrefly/lib/binding/target.rs:450— BindingsBuilder::bind_targets_with_value has cognitive complexity 25 (threshold 15). Drivers by points: if/else 5 (13 pts), loops 3 (9 pts), boolean chains 2, match/switch 1 (nesting depth added 14). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
BindingsBuilder::decompose_key_value_pairs (cognitive 24) pyrefly/lib/binding/class.rs:956— BindingsBuilder::decompose_key_value_pairs has cognitive complexity 24 (threshold 15). Drivers by points: if/else 4 (14 pts), match/switch 3 (9 pts), loops 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.
BindingsBuilder::synthesize_collections_named_tuple_def (cognitive 24) pyrefly/lib/binding/class.rs:1389— BindingsBuilder::synthesize_collections_named_tuple_def has cognitive complexity 24 (threshold 15). Drivers by points: if/else 11 (18 pts), loops 3 (4 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.
BindingsBuilder::handle_special_import_call (cognitive 23) pyrefly/lib/binding/stmt.rs:344— BindingsBuilder::handle_special_import_call has cognitive complexity 23 (threshold 15). Drivers by points: if/else 7 (14 pts), loops 3 (6 pts), match/switch 2, 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.
BindingsBuilder::as_special_export_inner (cognitive 22) pyrefly/lib/binding/bindings.rs:2136— BindingsBuilder::as_special_export_inner has cognitive complexity 22 (threshold 15). Drivers by points: if/else 5 (14 pts), match/switch 2 (5 pts), loops 1 (3 pts) (nesting depth added 14). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
Transaction::local_quickfix_code_actions_sorted (cognitive 120) pyrefly/lib/state/lsp.rs:3803— Transaction::local_quickfix_code_actions_sorted has cognitive complexity 120 (threshold 15). Drivers by points: if/else 29 (87 pts), loops 8 (17 pts), boolean chains 14, match/switch 1 (2 pts) (nesting depth added 68). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Transaction::completion_sorted_opt_with_incomplete (cognitive 106) pyrefly/lib/lsp/wasm/completion.rs:1250— Transaction::completion_sorted_opt_with_incomplete has cognitive complexity 106 (threshold 15). Drivers by points: if/else 30 (74 pts), boolean chains 18, loops 3 (8 pts), match/switch 3 (6 pts) (nesting depth added 52). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Transaction::inlay_hints (cognitive 95) pyrefly/lib/lsp/wasm/inlay_hints.rs:116— Transaction::inlay_hints has cognitive complexity 95 (threshold 15). Drivers by points: if/else 22 (55 pts), match/switch 8 (22 pts), boolean chains 15, loops 2 (3 pts) (nesting depth added 48). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Transaction::find_definition (cognitive 80) pyrefly/lib/state/lsp.rs:3076— Transaction::find_definition has cognitive complexity 80 (threshold 15). Drivers by points: if/else 26 (53 pts), match/switch 10 (23 pts), boolean chains 4 (nesting depth added 40). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Transaction::demand (cognitive 57) pyrefly/lib/state/state.rs:1559— Transaction::demand has cognitive complexity 57 (threshold 15). Drivers by points: if/else 22 (42 pts), boolean chains 7, loops 2 (4 pts), match/switch 2 (4 pts) (nesting depth added 24). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Transaction::extend_dict_key_suggestions (cognitive 45) pyrefly/lib/state/lsp/dict_completions.rs:1017— Transaction::extend_dict_key_suggestions has cognitive complexity 45 (threshold 15). Drivers by points: if/else 15 (32 pts), loops 3 (11 pts), boolean chains 2 (nesting depth added 25). 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.
Transaction::add_match_class_keyword_completions (cognitive 42) pyrefly/lib/lsp/wasm/completion.rs:1086— Transaction::add_match_class_keyword_completions has cognitive complexity 42 (threshold 15). Drivers by points: if/else 21 (29 pts), boolean chains 7, match/switch 3 (4 pts), loops 1 (2 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Transaction::inferred_types (cognitive 42) pyrefly/lib/lsp/wasm/inlay_hints.rs:724— Transaction::inferred_types has cognitive complexity 42 (threshold 15). Drivers by points: if/else 7 (25 pts), match/switch 4 (14 pts), boolean chains 2, loops 1 (nesting depth added 28). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Transaction::pytest_fixture_definitions_for_parameter (cognitive 37) pyrefly/lib/state/lsp/pytest.rs:92— Transaction::pytest_fixture_definitions_for_parameter has cognitive complexity 37 (threshold 15). Drivers by points: if/else 8 (23 pts), boolean chains 8, loops 2 (5 pts), match/switch 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.
Transaction::clean (cognitive 36) pyrefly/lib/state/state.rs:1389— Transaction::clean has cognitive complexity 36 (threshold 15). Drivers by points: if/else 14 (27 pts), boolean chains 4, loops 2 (3 pts), match/switch 1 (2 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.
Transaction::find_operator_dunder (cognitive 32) pyrefly/lib/state/lsp.rs:2534— Transaction::find_operator_dunder has cognitive complexity 32 (threshold 15). Drivers by points: if/else 10 (25 pts), match/switch 3 (5 pts), loops 1 (2 pts) (nesting depth added 18). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
Transaction::detect_editable_packages (cognitive 32) pyrefly/lib/state/lsp.rs:4554— Transaction::detect_editable_packages has cognitive complexity 32 (threshold 15). Drivers by points: if/else 10 (29 pts), loops 2 (3 pts) (nesting depth added 20). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Transaction::add_kwargs_completions (cognitive 31) pyrefly/lib/lsp/wasm/completion.rs:379— Transaction::add_kwargs_completions has cognitive complexity 31 (threshold 15). Drivers by points: loops 4 (14 pts), if/else 4 (11 pts), match/switch 1 (5 pts), boolean chains 1 (nesting depth added 21). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
Transaction::add_autoimport_completions (cognitive 31) pyrefly/lib/lsp/wasm/completion.rs:665— Transaction::add_autoimport_completions has cognitive complexity 31 (threshold 15). Drivers by points: if/else 10 (24 pts), loops 2 (4 pts), boolean chains 3 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Transaction::add_inlay_hints_for_positional_function_args (cognitive 27) pyrefly/lib/lsp/wasm/inlay_hints.rs:421— Transaction::add_inlay_hints_for_positional_function_args has cognitive complexity 27 (threshold 15). Drivers by points: if/else 6 (19 pts), loops 2 (7 pts), boolean chains 1 (nesting depth added 18). 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.
Transaction::dict_literal_value_string_literal_at (cognitive 27) pyrefly/lib/state/lsp/dict_completions.rs:756— Transaction::dict_literal_value_string_literal_at has cognitive complexity 27 (threshold 15). Drivers by points: if/else 8 (22 pts), loops 2 (3 pts), boolean chains 2 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Transaction::find_definition_for_attribute_in_non_python_module (cognitive 27) pyrefly/lib/state/lsp/extra_extensions.rs:168— Transaction::find_definition_for_attribute_in_non_python_module has cognitive complexity 27 (threshold 15). Drivers by points: if/else 8 (19 pts), boolean chains 6, loops 1 (2 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.
Transaction::type_from_resolution (cognitive 26) pyrefly/lib/state/lsp.rs:1516— Transaction::type_from_resolution has cognitive complexity 26 (threshold 15). Drivers by points: if/else 10 (22 pts), boolean chains 3, match/switch 1 (nesting depth added 12). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
Transaction::refine_keyword_argument_definition_for_class (cognitive 24) pyrefly/lib/state/lsp.rs:1336— Transaction::refine_keyword_argument_definition_for_class has cognitive complexity 24 (threshold 15). Drivers by points: if/else 4 (13 pts), loops 4 (8 pts), match/switch 1 (2 pts), boolean chains 1 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Transaction::split_line_count (cognitive 24) pyrefly/lib/state/state.rs:1287— Transaction::split_line_count has cognitive complexity 24 (threshold 15). Drivers by points: if/else 9 (18 pts), loops 3 (6 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.
Transaction::add_local_variable_completions (cognitive 23) pyrefly/lib/lsp/wasm/completion.rs:561— Transaction::add_local_variable_completions has cognitive complexity 23 (threshold 15). Drivers by points: if/else 8 (16 pts), match/switch 1 (3 pts), boolean chains 2, loops 1 (2 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Transaction::dict_literal_string_literal_at (cognitive 23) pyrefly/lib/state/lsp/dict_completions.rs:638— Transaction::dict_literal_string_literal_at has cognitive complexity 23 (threshold 15). Drivers by points: if/else 6 (16 pts), boolean chains 4, match/switch 1 (2 pts), loops 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Transaction::infer_parameter_annotations (cognitive 22) pyrefly/lib/lsp/wasm/inlay_hints.rs:626— Transaction::infer_parameter_annotations has cognitive complexity 22 (threshold 15). Drivers by points: if/else 9 (15 pts), loops 2 (5 pts), match/switch 1 (2 pts) (nesting depth added 10). Most of this is not in the body itself: 8 of the 22 points are its own statements and the rest belongs to 2 function items inside it that branch (transpose, zip_types). Those helpers are already separate functions, so extracting the branching again is not available. To reduce it, move them out of the body to the enclosing scope, where each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
Transaction::add_dict_key_completions (cognitive 22) pyrefly/lib/state/lsp/dict_completions.rs:919— Transaction::add_dict_key_completions has cognitive complexity 22 (threshold 15). Drivers by points: if/else 8 (14 pts), loops 1 (3 pts), match/switch 2 (3 pts), boolean chains 2 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Transaction::resolve_named_import (cognitive 20) pyrefly/lib/state/lsp.rs:1771— Transaction::resolve_named_import has cognitive complexity 20 (threshold 15). Drivers by points: if/else 5 (13 pts), match/switch 2 (4 pts), boolean chains 2, loops 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Duplicated block (7 lines × 2) crates/pyrefly_config/src/migration/run.rs:471— crates/pyrefly_config/src/migration/run.rs:471-477 | pyrefly/lib/commands/init.rs:333-339 — 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) crates/pyrefly_types/src/dimension.rs:768— crates/pyrefly_types/src/dimension.rs:768-774 | crates/pyrefly_types/src/dimension.rs:961-967 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/pyrefly_types/src/dimension.rs:768` it does not close everything it opens, so those exact lines 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) crates/pyrefly_types/src/display.rs:1441— crates/pyrefly_types/src/display.rs:1441-1447 | crates/pyrefly_types/src/display.rs:1457-1463 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/pyrefly_types/src/display.rs:1441` it does not close everything it opens, so those exact lines 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) crates/pyrefly_types/src/type_level_dsl.rs:3665— crates/pyrefly_types/src/type_level_dsl.rs:3665-3671 | crates/pyrefly_types/src/type_level_dsl.rs:3791-3797 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/pyrefly_types/src/type_level_dsl.rs:3665` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (7 lines × 2) pyrefly/lib/alt/class/class_field.rs:1014— pyrefly/lib/alt/class/class_field.rs:1014-1020 | pyrefly/lib/alt/class/class_field.rs:1309-1315 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/alt/class/class_field.rs:1014` it does not close everything it opens, so those exact lines 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) pyrefly/lib/alt/class/class_field.rs:1741— pyrefly/lib/alt/class/class_field.rs:1741-1747 | pyrefly/lib/alt/class/class_field.rs:2076-2082 — both copies are in the same file, so extract the 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) pyrefly/lib/alt/narrow.rs:1425— pyrefly/lib/alt/narrow.rs:1425-1431 | pyrefly/lib/alt/narrow.rs:1448-1454 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/alt/narrow.rs:1425` it does not close everything it opens, so those exact lines 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) pyrefly/lib/alt/narrow.rs:2746— pyrefly/lib/alt/narrow.rs:2746-2753 | pyrefly/lib/alt/narrow.rs:2816-2822 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/alt/narrow.rs:2746` it does not close everything it opens, so those exact lines 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) pyrefly/lib/alt/type_var_declaration.rs:322— pyrefly/lib/alt/type_var_declaration.rs:322-328 | pyrefly/lib/alt/type_var_declaration.rs:330-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. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
Duplicated block (7 lines × 2) pyrefly/lib/lsp/non_wasm/server.rs:5088— pyrefly/lib/lsp/non_wasm/server.rs:5088-5094 | pyrefly/lib/lsp/non_wasm/server.rs:5117-5123 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/lsp/non_wasm/server.rs:5088` it does not close everything it opens, so those exact lines 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) pyrefly/lib/lsp/wasm/signature_help.rs:115— pyrefly/lib/lsp/wasm/signature_help.rs:115-123 | pyrefly/lib/lsp/wasm/signature_help.rs:178-184 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/lsp/wasm/signature_help.rs:115` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (7 lines × 2) pyrefly/lib/report/pysa/capnp_writer.rs:466— pyrefly/lib/report/pysa/capnp_writer.rs:466-472 | pyrefly/lib/report/pysa/capnp_writer.rs:510-516 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
Duplicated block (7 lines × 2) pyrefly/lib/report/pysa/capnp_writer.rs:545— pyrefly/lib/report/pysa/capnp_writer.rs:545-551 | pyrefly/lib/report/pysa/capnp_writer.rs:563-569 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
Duplicated block (7 lines × 2) pyrefly/lib/solver/subset.rs:849— pyrefly/lib/solver/subset.rs:849-855 | pyrefly/lib/solver/subset.rs:882-888 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/solver/subset.rs:849` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7 lines × 2) crates/pyrefly_types/src/type_level_dsl.rs:7794— crates/pyrefly_types/src/type_level_dsl.rs:7794-7800 | crates/pyrefly_types/src/type_level_dsl.rs:7833-7839 — both copies are in the same file, so extract the 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) pyrefly/lib/alt/class/class_metadata.rs:750— pyrefly/lib/alt/class/class_metadata.rs:750-756 | pyrefly/lib/alt/class/class_metadata.rs:1305-1311 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/alt/class/class_metadata.rs: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 (7 lines × 2) pyrefly/lib/alt/polars_specials.rs:1356— pyrefly/lib/alt/polars_specials.rs:1356-1362 | pyrefly/lib/alt/polars_specials.rs:1766-1772 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/alt/polars_specials.rs:1356` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (7 lines × 2) pyrefly/lib/state/lsp/quick_fixes/convert_star_import.rs:170— pyrefly/lib/state/lsp/quick_fixes/convert_star_import.rs:170-176 | pyrefly/lib/state/lsp/quick_fixes/extract_shared.rs:532-538 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
Duplicated block (7 lines × 2) crates/pyrefly_types/src/type_level_dsl.rs:6995— crates/pyrefly_types/src/type_level_dsl.rs:6995-7001 | crates/pyrefly_types/src/type_level_dsl.rs:7021-7027 — both copies are in the same file, so extract the 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) crates/pyrefly_types/src/type_output.rs:118— crates/pyrefly_types/src/type_output.rs:118-124 | pyrefly/lib/state/lsp/quick_fixes/implement_abstract_members.rs:212-218 — 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) pyrefly/lib/module/third_party.rs:82— pyrefly/lib/module/third_party.rs:82-88 | pyrefly/lib/module/typeshed_third_party.rs:88-94 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (7 lines × 2) pyrefly/lib/alt/polars_specials.rs:579— pyrefly/lib/alt/polars_specials.rs:579-585 | pyrefly/lib/binding/attrs.rs:359-365 — 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) pyrefly/lib/binding/bindings.rs:883— pyrefly/lib/binding/bindings.rs:883-889 | pyrefly/lib/binding/shape_type.rs:185-194 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (7 lines × 2) crates/pyrefly_types/src/type_level_dsl.rs:3523— crates/pyrefly_types/src/type_level_dsl.rs:3523-3529 | crates/pyrefly_types/src/type_level_dsl.rs:3573-3579 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/pyrefly_types/src/type_level_dsl.rs:3523` it begins part-way through the construct above it, so those exact lines 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) pyrefly/lib/alt/class/variance_inference.rs:778— pyrefly/lib/alt/class/variance_inference.rs:778-784 | pyrefly/lib/alt/class/variance_inference.rs:790-796 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/alt/class/variance_inference.rs:778` it begins part-way through the construct above it, so those exact lines 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) crates/pyrefly_python/src/ignore.rs:780— crates/pyrefly_python/src/ignore.rs:780-784 | crates/pyrefly_python/src/ignore.rs:933-937 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/pyrefly_python/src/ignore.rs:780` it does not close everything it opens, so those exact lines 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) crates/pyrefly_types/src/type_level_dsl.rs:8301— crates/pyrefly_types/src/type_level_dsl.rs:8301-8305 | crates/pyrefly_types/src/type_level_dsl.rs:8390-8394 — both copies are in the same file, so extract the 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) pyrefly/lib/alt/call.rs:2975— pyrefly/lib/alt/call.rs:2975-2979 | pyrefly/lib/alt/call.rs:3000-3004 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/alt/call.rs:2975` it does not close everything it opens, so those exact lines 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) pyrefly/lib/alt/expr.rs:3552— pyrefly/lib/alt/expr.rs:3552-3556 | pyrefly/lib/alt/types/class_bases.rs:128-134 — 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 `pyrefly/lib/alt/expr.rs:3552` it begins part-way through the construct above it, so those exact lines 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) pyrefly/lib/alt/overload.rs:934— pyrefly/lib/alt/overload.rs:934-938 | pyrefly/lib/alt/overload.rs:947-951 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/alt/overload.rs:934` it begins part-way through the construct above it, so those exact lines 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) pyrefly/lib/binding/class.rs:781— pyrefly/lib/binding/class.rs:781-785 | pyrefly/lib/binding/class.rs:1285-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 `pyrefly/lib/binding/class.rs:781` it does not close everything it opens, so those exact lines 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) pyrefly/lib/binding/stmt.rs:498— pyrefly/lib/binding/stmt.rs:498-502 | pyrefly/lib/binding/stmt.rs:617-622 — both copies are in the same file, so extract the 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) pyrefly/lib/state/lsp/dict_completions.rs:688— pyrefly/lib/state/lsp/dict_completions.rs:688-692 | pyrefly/lib/state/lsp/dict_completions.rs:789-793 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/state/lsp/dict_completions.rs:688` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (5 lines × 2) pyrefly/lib/state/lsp/quick_fixes/convert_dict.rs:302— pyrefly/lib/state/lsp/quick_fixes/convert_dict.rs:302-306 | pyrefly/lib/state/lsp/quick_fixes/convert_dict.rs:336-340 — both copies are in the same file, so extract the 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) pyrefly/lib/stubgen/extract.rs:225— pyrefly/lib/stubgen/extract.rs:225-229 | pyrefly/lib/stubgen/extract.rs:239-243 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (5 lines × 2) pyrefly/lib/alt/int_list_literal.rs:42— pyrefly/lib/alt/int_list_literal.rs:42-46 | pyrefly/lib/alt/regular_nested_list.rs:57-61 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (5 lines × 2) pyrefly/lib/state/lsp/quick_fixes/introduce_parameter.rs:715— pyrefly/lib/state/lsp/quick_fixes/introduce_parameter.rs:715-719 | pyrefly/lib/state/lsp/quick_fixes/introduce_parameter.rs:727-731 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/state/lsp/quick_fixes/introduce_parameter.rs:715` it begins part-way through the construct above it, so those exact lines 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) pyrefly/lib/alt/expr.rs:1211— pyrefly/lib/alt/expr.rs:1211-1215 | pyrefly/lib/alt/expr.rs:1221-1225 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/alt/expr.rs:1211` it does not close everything it opens, so those exact lines 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) pyrefly/lib/alt/solve.rs:7613— pyrefly/lib/alt/solve.rs:7613-7617 | pyrefly/lib/alt/solve.rs:7738-7742 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/alt/solve.rs:7613` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `x` to `&BindingYield` in one and `&BindingYieldFrom` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (5 lines × 2) pyrefly/lib/lsp/non_wasm/code_lens.rs:96— pyrefly/lib/lsp/non_wasm/code_lens.rs:96-100 | pyrefly/lib/lsp/non_wasm/code_lens.rs:104-108 — both copies are in the same file, so extract the 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) pyrefly/lib/solver/subset.rs:1156— pyrefly/lib/solver/subset.rs:1156-1160 | pyrefly/lib/solver/subset.rs:1169-1173 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/solver/subset.rs:1156` it does not close everything it opens, so those exact lines 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) tensor-shapes/pyrefly-torch-stubs/examples/soft_actor_critic.py:224— tensor-shapes/pyrefly-torch-stubs/examples/soft_actor_critic.py:224-228 | tensor-shapes/pyrefly-torch-stubs/examples/soft_actor_critic.py:287-291 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (5 lines × 2) tensor-shapes/pyrefly-torch-stubs/examples/soft_actor_critic.py:403— tensor-shapes/pyrefly-torch-stubs/examples/soft_actor_critic.py:403-407 | tensor-shapes/pyrefly-torch-stubs/examples/soft_actor_critic.py:441-445 — both copies are in the same file, so extract the 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, `tensor-shapes/pyrefly-torch-stubs/examples/soft_actor_critic.py:439` calls `assert_type`, `relu`, `conv4` and `tensor-shapes/pyrefly-torch-stubs/examples/soft_actor_critic.py:402` 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) tensor-shapes/pyrefly-torch-stubs/examples/tacotron2.py:301— tensor-shapes/pyrefly-torch-stubs/examples/tacotron2.py:301-305 | tensor-shapes/pyrefly-torch-stubs/examples/tacotron2.py:307-311 — both copies are in the same file, so extract the 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) tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations_runnable.py:530— tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations_runnable.py:530-534 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var_runnable.py:520-524 — before extracting anything, compare `tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations_runnable.py` and `tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var_runnable.py` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 202 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (5 lines × 2) tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations_runnable.py:163— tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations_runnable.py:163-167 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var_runnable.py:156-160 — before extracting anything, compare `tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations_runnable.py` and `tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var_runnable.py` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 288 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (5 lines × 2) tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations_runnable.py:174— tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations_runnable.py:174-178 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var_runnable.py:167-171 — before extracting anything, compare `tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations_runnable.py` and `tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var_runnable.py` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 288 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (5 lines × 2) tensor-shapes/pyrefly-torch-stubs/examples/background_matting.py:509— tensor-shapes/pyrefly-torch-stubs/examples/background_matting.py:509-513 | tensor-shapes/pyrefly-torch-stubs/examples/stargan.py:205-209 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (5 lines × 2) tensor-shapes/pyrefly-torch-stubs/examples/densenet.py:287— tensor-shapes/pyrefly-torch-stubs/examples/densenet.py:287-291 | tensor-shapes/pyrefly-torch-stubs/examples/densenet.py:295-299 — both copies are in the same file, so extract the 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) tensor-shapes/pyrefly-torch-stubs/examples/densenet.py:311— tensor-shapes/pyrefly-torch-stubs/examples/densenet.py:311-315 | tensor-shapes/pyrefly-torch-stubs/examples/densenet.py:319-323 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
pyrefly::lib::lsp::wasm::hover::keyword_documentation (cyclomatic 73) pyrefly/lib/lsp/wasm/hover.rs:876— pyrefly::lib::lsp::wasm::hover::keyword_documentation has cyclomatic complexity 73 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
pyrefly::lib::error::suppress::update_suppressions_in_files (cyclomatic 52) pyrefly/lib/error/suppress.rs:402— pyrefly::lib::error::suppress::update_suppressions_in_files has cyclomatic complexity 52 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
pyrefly::lib::report::cinderx::convert::type_to_structured (cyclomatic 48) pyrefly/lib/report/cinderx/convert.rs:178— pyrefly::lib::report::cinderx::convert::type_to_structured has cyclomatic complexity 48 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
pyrefly::lib::commands::coverage::collect::parse_functions (cyclomatic 41) pyrefly/lib/commands/coverage/collect.rs:952— pyrefly::lib::commands::coverage::collect::parse_functions has cyclomatic complexity 41 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
pyrefly::lib::commands::coverage::collect::parse_variables (cyclomatic 35) pyrefly/lib/commands/coverage/collect.rs:463— pyrefly::lib::commands::coverage::collect::parse_variables has cyclomatic complexity 35 (threshold 15). Of this number, 19 points are the body's own statements and 16 belong to 2 function items inside it that branch. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
pyrefly::lib::binding::attrs::collect_attrs_decorator_methods (cyclomatic 33) pyrefly/lib/binding/attrs.rs:94— pyrefly::lib::binding::attrs::collect_attrs_decorator_methods has cyclomatic complexity 33 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
pyrefly::lib::binding::function::function_last_expressions::f (cyclomatic 33) pyrefly/lib/binding/function.rs:1262— pyrefly::lib::binding::function::function_last_expressions::f has cyclomatic complexity 33 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
pyrefly::lib::alt::regex::validate_pattern (cyclomatic 32) pyrefly/lib/alt/regex.rs:21— pyrefly::lib::alt::regex::validate_pattern has cyclomatic complexity 32 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
pyrefly::lib::module::finder::find_import_with_mode (cyclomatic 31) pyrefly/lib/module/finder.rs:667— pyrefly::lib::module::finder::find_import_with_mode has cyclomatic complexity 31 (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.
pyrefly::lib::commands::infer::format_hints (cyclomatic 25) pyrefly/lib/commands/infer.rs:193— pyrefly::lib::commands::infer::format_hints has cyclomatic complexity 25 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
pyrefly::lib::state::lsp::quick_fixes::deprecated_contextmanager::replace_return_code_action (cyclomatic 24) pyrefly/lib/state/lsp/quick_fixes/deprecated_contextmanager.rs:44— pyrefly::lib::state::lsp::quick_fixes::deprecated_contextmanager::replace_return_code_action 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.
pyrefly::lib::commands::coverage::collect::parse_instance_attrs (cyclomatic 22) pyrefly/lib/commands/coverage/collect.rs:814— pyrefly::lib::commands::coverage::collect::parse_instance_attrs has cyclomatic complexity 22 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
pyrefly::lib::lsp::non_wasm::server::dispatch_lsp_events (cyclomatic 22) pyrefly/lib/lsp/non_wasm/server.rs:1489— pyrefly::lib::lsp::non_wasm::server::dispatch_lsp_events has cyclomatic complexity 22 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
pyrefly::lib::lsp::wasm::hover::get_hover_with_verbosity (cyclomatic 22) pyrefly/lib/lsp/wasm/hover.rs:1572— pyrefly::lib::lsp::wasm::hover::get_hover_with_verbosity has cyclomatic complexity 22 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
pyrefly::lib::stubgen::extract::extract_stmts (cyclomatic 22) pyrefly/lib/stubgen/extract.rs:174— pyrefly::lib::stubgen::extract::extract_stmts has cyclomatic complexity 22 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
pyrefly::lib::export::symbols::build (cyclomatic 21) pyrefly/lib/export/symbols.rs:187— pyrefly::lib::export::symbols::build 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.
pyrefly::lib::state::lsp::quick_fixes::inline_variable::expand_statement_removal_range (cyclomatic 21) pyrefly/lib/state/lsp/quick_fixes/inline_variable.rs:242— pyrefly::lib::state::lsp::quick_fixes::inline_variable::expand_statement_removal_range has cyclomatic complexity 21 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
pyrefly::lib::commands::coverage::collect::collect_module_reports (cyclomatic 20) pyrefly/lib/commands/coverage/collect.rs:1954— pyrefly::lib::commands::coverage::collect::collect_module_reports 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.
pyrefly::lib::report::cinderx::collect::collect_call_contextual_types (cyclomatic 20) pyrefly/lib/report/cinderx/collect.rs:267— pyrefly::lib::report::cinderx::collect::collect_call_contextual_types 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.
pyrefly::lib::report::pysa::types::get_classes_of_type (cyclomatic 19) pyrefly/lib/report/pysa/types.rs:263— pyrefly::lib::report::pysa::types::get_classes_of_type has cyclomatic complexity 19 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
pyrefly::lib::state::lsp::quick_fixes::extract_function::extract_function_code_actions (cyclomatic 19) pyrefly/lib/state/lsp/quick_fixes/extract_function.rs:39— pyrefly::lib::state::lsp::quick_fixes::extract_function::extract_function_code_actions 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.
pyrefly::lib::state::lsp::quick_fixes::move_module::build_module_member_consumer_import_updates (cyclomatic 17) pyrefly/lib/state/lsp/quick_fixes/move_module.rs:198— pyrefly::lib::state::lsp::quick_fixes::move_module::build_module_member_consumer_import_updates 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.
pyrefly::lib::state::semantic_tokens::collect_disabled_ranges_from_stmt (cyclomatic 17) pyrefly/lib/state/semantic_tokens.rs:934— pyrefly::lib::state::semantic_tokens::collect_disabled_ranges_from_stmt has cyclomatic complexity 17 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
pyrefly::lib::lsp::non_wasm::document_symbols::recurse_stmt_adding_symbols (cyclomatic 16) pyrefly/lib/lsp/non_wasm/document_symbols.rs:195— pyrefly::lib::lsp::non_wasm::document_symbols::recurse_stmt_adding_symbols 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.
pyrefly::lib::state::lsp::fastapi_endpoint_support::association::reference_definition (cyclomatic 16) pyrefly/lib/state/lsp/fastapi_endpoint_support/association.rs:82— pyrefly::lib::state::lsp::fastapi_endpoint_support::association::reference_definition 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.
TooManyMethods: AnswersSolver pyrefly/lib/alt/answers_solver.rs:2166— TooManyMethods — 1285 methods, declared across 53 files: alt/solve.rs (163), alt/answers_solver.rs (100), class/class_field.rs (100), alt/expr.rs (98), +49 more file(s). The bar is 30 methods; this is 1255 over it, 42.83× the bar. That list is where to read them, not a suggestion to split the file: the members belong to the type wherever they are declared, so moving them between files leaves the count unchanged. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: Transaction pyrefly/lib/state/state.rs:760— TooManyMethods — 318 methods, declared across 14 files: state/lsp.rs (130), state/state.rs (90), lsp/dict_completions.rs (32), wasm/completion.rs (23), +10 more file(s). The bar is 30 methods; this is 288 over it, 10.60× the bar. That list is where to read them, not a suggestion to split the file: the members belong to the type wherever they are declared, so moving them between files leaves the count unchanged. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: BindingsBuilder pyrefly/lib/binding/bindings.rs:526— TooManyMethods — 243 methods, declared across 14 files: binding/bindings.rs (86), binding/class.rs (24), binding/stmt.rs (24), binding/expr.rs (21), +10 more file(s). The bar is 30 methods; this is 213 over it, 8.10× the bar. That list is where to read them, not a suggestion to split the file: the members belong to the type wherever they are declared, so moving them between files leaves the count unchanged. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: Scopes pyrefly/lib/binding/scope.rs:1787— TooManyMethods — 156 methods. The bar is 30 methods; this is 126 over it, 5.20× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: Type crates/pyrefly_types/src/types.rs:862— TooManyMethods — 127 methods, declared across 3 files: src/types.rs (114), src/boundary.rs (9), src/display.rs (4). The bar is 30 methods; this is 97 over it, 4.23× the bar. That list is where to read them, not a suggestion to split the file: the members belong to the type wherever they are declared, so moving them between files leaves the count unchanged. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: Server pyrefly/lib/lsp/non_wasm/server.rs:1156— TooManyMethods — 110 methods. The bar is 30 methods; this is 80 over it, 3.67× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: Stdlib crates/pyrefly_types/src/stdlib.rs:50— TooManyMethods — 83 methods. The bar is 30 methods; this is 53 over it, 2.77× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: Solver pyrefly/lib/solver/solver.rs:580— TooManyMethods — 80 methods. The bar is 30 methods; this is 50 over it, 2.67× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: TestClient crates/pyrefly_lsp_test/src/object_model.rs:271— TooManyMethods — 64 methods. The bar is 30 methods; this is 34 over it, 2.13× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: TypeHeap crates/pyrefly_types/src/heap.rs:84— TooManyMethods — 64 methods. The bar is 30 methods; this is 34 over it, 2.13× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: ConfigFile crates/pyrefly_config/src/config.rs:611— TooManyMethods — 59 methods. The bar is 30 methods; this is 29 over it, 1.97× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: Subset pyrefly/lib/solver/solver.rs:3458— TooManyMethods — 59 methods, declared across 2 files: solver/subset.rs (42), solver/solver.rs (17). The bar is 30 methods; this is 29 over it, 1.97× the bar. That list is where to read them, not a suggestion to split the file: the members belong to the type wherever they are declared, so moving them between files leaves the count unchanged. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: ModuleName crates/pyrefly_python/src/module_name.rs:39— TooManyMethods — 55 methods. The bar is 30 methods; this is 25 over it, 1.83× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: DslValidator crates/pyrefly_types/src/type_level_dsl.rs:1961— TooManyMethods — 51 methods. The bar is 30 methods; this is 21 over it, 1.70× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: Bindings pyrefly/lib/binding/bindings.rs:421— TooManyMethods — 49 methods. The bar is 30 methods; this is 19 over it, 1.63× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: ClassField pyrefly/lib/alt/class/class_field.rs:383— TooManyMethods — 48 methods. The bar is 30 methods; this is 18 over it, 1.60× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: CallGraphVisitor pyrefly/lib/report/pysa/call_graph.rs:1501— TooManyMethods — 48 methods. The bar is 30 methods; this is 18 over it, 1.60× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: TypeDisplayContext crates/pyrefly_types/src/display.rs:166— TooManyMethods — 41 methods. The bar is 30 methods; this is 11 over it, 1.37× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: Ast crates/pyrefly_python/src/ast.rs:66— TooManyMethods — 40 methods. The bar is 30 methods; this is 10 over it, 1.33× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: CalcStack pyrefly/lib/alt/answers_solver.rs:539— TooManyMethods — 36 methods. The bar is 30 methods; this is 6 over it, 1.20× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: TypeOrder pyrefly/lib/solver/type_order.rs:53— TooManyMethods — 36 methods. The bar is 30 methods; this is 6 over it, 1.20× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: Answers pyrefly/lib/alt/answers.rs:267— TooManyMethods — 35 methods. The bar is 30 methods; this is 5 over it, 1.17× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: Error pyrefly/lib/error/error.rs:152— TooManyMethods — 32 methods. The bar is 30 methods; this is 2 over it, 1.07× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: LspInteraction crates/pyrefly_lsp_test/src/object_model.rs:1332— TooManyMethods — 31 methods. The bar is 30 methods; this is 1 over it, 1.03× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: Quantified crates/pyrefly_types/src/quantified.rs:163— TooManyMethods — 31 methods, declared across 2 files: src/quantified.rs (30), src/type_var.rs (1). The bar is 30 methods; this is 1 over it, 1.03× the bar. That list is where to read them, not a suggestion to split the file: the members belong to the type wherever they are declared, so moving them between files leaves the count unchanged. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: Server pyrefly/lib/lsp/non_wasm/server.rs:1156— ClassTooLong — 4132 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 110 methods, 3 blocks, lines 1156-7771. The bar is 400 significant lines; this is 3732 over it, 10.33× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: CallGraphVisitor pyrefly/lib/report/pysa/call_graph.rs:1501— ClassTooLong — 2044 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 48 methods, 3 blocks, lines 1501-4480. The bar is 400 significant lines; this is 1644 over it, 5.11× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: Scopes pyrefly/lib/binding/scope.rs:1787— ClassTooLong — 1515 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 156 methods, 2 blocks, lines 1787-4447. The bar is 400 significant lines; this is 1115 over it, 3.79× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: StructurallyValidatedTypeShapeDslFunction crates/pyrefly_types/src/type_level_dsl.rs:929— ClassTooLong — 1473 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 18 methods, 8 blocks, lines 929-8573. The bar is 400 significant lines; this is 1073 over it, 3.68× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: Solver pyrefly/lib/solver/solver.rs:580— ClassTooLong — 1394 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 80 methods, 3 blocks, lines 580-2798. The bar is 400 significant lines; this is 994 over it, 3.49× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: BindingsBuilder pyrefly/lib/binding/bindings.rs:526— ClassTooLong — 1370 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 243 methods, 5 blocks, lines 526-3879. The bar is 400 significant lines; this is 970 over it, 3.43× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: Transaction pyrefly/lib/state/state.rs:760— ClassTooLong — 1285 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 318 methods, 2 blocks, lines 760-2871. The bar is 400 significant lines; this is 885 over it, 3.21× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: AnswersSolver pyrefly/lib/alt/answers_solver.rs:2166— ClassTooLong — 1196 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 1285 methods, 3 blocks, lines 2166-4325. The bar is 400 significant lines; this is 796 over it, 2.99× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: TypeDisplayContext crates/pyrefly_types/src/display.rs:166— ClassTooLong — 1169 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 41 methods, 2 blocks, lines 166-1847. The bar is 400 significant lines; this is 769 over it, 2.92× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: Type crates/pyrefly_types/src/types.rs:862— ClassTooLong — 1036 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 127 methods, 4 blocks, lines 862-2628. The bar is 400 significant lines; this is 636 over it, 2.59× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: ConfigFile crates/pyrefly_config/src/config.rs:611— ClassTooLong — 955 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 59 methods, 5 blocks, lines 611-2505. The bar is 400 significant lines; this is 555 over it, 2.39× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: TestClient crates/pyrefly_lsp_test/src/object_model.rs:271— ClassTooLong — 724 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 64 methods, 2 blocks, lines 271-1330. The bar is 400 significant lines; this is 324 over it, 1.81× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: ClassField pyrefly/lib/alt/class/class_field.rs:383— ClassTooLong — 606 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 48 methods, 2 blocks, lines 465-1321. The bar is 400 significant lines; this is 206 over it, 1.52× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: Subset pyrefly/lib/solver/solver.rs:3458— ClassTooLong — 591 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 59 methods, 2 blocks, lines 3458-4373. The bar is 400 significant lines; this is 191 over it, 1.48× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: CheckArgs pyrefly/lib/commands/check.rs:240— ClassTooLong — 586 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 10 methods, 2 blocks, lines 240-2586. The bar is 400 significant lines; this is 186 over it, 1.47× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: CalleesWithLocation pyrefly/lib/query.rs:378— ClassTooLong — 508 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 26 methods, 2 blocks, lines 378-1079. The bar is 400 significant lines; this is 108 over it, 1.27× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: Query pyrefly/lib/query.rs:153— ClassTooLong — 505 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 17 methods, 2 blocks, lines 153-1779. The bar is 400 significant lines; this is 105 over it, 1.26× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: Bindings pyrefly/lib/binding/bindings.rs:421— ClassTooLong — 486 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 49 methods, 3 blocks, lines 421-1378. The bar is 400 significant lines; this is 86 over it, 1.22× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: DefinitionsBuilder pyrefly/lib/export/definitions.rs:360— ClassTooLong — 447 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 12 methods, 2 blocks, lines 360-1205. The bar is 400 significant lines; this is 47 over it, 1.12× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: Errors pyrefly/lib/state/errors.rs:301— ClassTooLong — 445 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 20 methods, 2 blocks, lines 301-1024. The bar is 400 significant lines; this is 45 over it, 1.11× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: Binding pyrefly/lib/binding/binding.rs:2638— ClassTooLong — 445 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 1 methods, 3 blocks, lines 2638-3335. The bar is 400 significant lines; this is 45 over it, 1.11× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: LspInteraction crates/pyrefly_lsp_test/src/object_model.rs:1332— ClassTooLong — 429 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 31 methods, 2 blocks, lines 1332-2082. The bar is 400 significant lines; this is 29 over it, 1.07× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: NarrowOps pyrefly/lib/binding/narrow.rs:795— ClassTooLong — 420 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 16 methods. The bar is 400 significant lines; this is 20 over it, 1.05× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: Answers pyrefly/lib/alt/answers.rs:267— ClassTooLong — 412 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 35 methods, 3 blocks, lines 267-1846. The bar is 400 significant lines; this is 12 over it, 1.03× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: CalcStack pyrefly/lib/alt/answers_solver.rs:539— ClassTooLong — 401 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 36 methods, 2 blocks, lines 539-1411. The bar is 400 significant lines; this is 1 over it, 1.00× 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.
FunctionTooLong: pyrefly::lib::lsp::wasm::hover::keyword_documentation pyrefly/lib/lsp/wasm/hover.rs:876— FunctionTooLong — pyrefly::lib::lsp::wasm::hover::keyword_documentation runs 264 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 164 over it, 2.64× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: extension.activate lsp/src/extension.ts:241— FunctionTooLong — activate runs 243 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 143 over it, 2.43× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: pyrefly::lib::error::suppress::update_suppressions_in_files pyrefly/lib/error/suppress.rs:402— FunctionTooLong — pyrefly::lib::error::suppress::update_suppressions_in_files runs 239 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 139 over it, 2.39× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: pyrefly::lib::report::cinderx::convert::type_to_structured pyrefly/lib/report/cinderx/convert.rs:178— FunctionTooLong — pyrefly::lib::report::cinderx::convert::type_to_structured runs 217 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 117 over it, 2.17× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: pyrefly::lib::report::pysa::ast_visitor::visit_statement pyrefly/lib/report/pysa/ast_visitor.rs:264— FunctionTooLong — pyrefly::lib::report::pysa::ast_visitor::visit_statement runs 195 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 95 over it, 1.95× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: pyrefly::lib::query::type_table::type_to_indexed_shape pyrefly/lib/query/type_table.rs:267— FunctionTooLong — pyrefly::lib::query::type_table::type_to_indexed_shape runs 184 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 84 over it, 1.84× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: pyrefly::lib::lsp::wasm::hover::get_hover_with_verbosity pyrefly/lib/lsp/wasm/hover.rs:1572— FunctionTooLong — pyrefly::lib::lsp::wasm::hover::get_hover_with_verbosity runs 169 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 69 over it, 1.69× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: pyrefly::lib::binding::function::function_last_expressions pyrefly/lib/binding/function.rs:1257— FunctionTooLong — pyrefly::lib::binding::function::function_last_expressions runs 165 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 65 over it, 1.65× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: aiLandingPageHeader.AiLandingPageHeader website/src/components/landing-page/aiLandingPageHeader.tsx:21— FunctionTooLong — AiLandingPageHeader runs 143 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 43 over it, 1.43× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: pyrefly_types::einops::evaluate_einops_pattern crates/pyrefly_types/src/einops.rs:398— FunctionTooLong — pyrefly_types::einops::evaluate_einops_pattern runs 136 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 36 over it, 1.36× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: pyrefly::lib::module::finder::find_import_with_mode pyrefly/lib/module/finder.rs:667— FunctionTooLong — pyrefly::lib::module::finder::find_import_with_mode runs 124 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 24 over it, 1.24× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: pyrefly_python::folding::folding_ranges crates/pyrefly_python/src/folding.rs:30— FunctionTooLong — pyrefly_python::folding::folding_ranges runs 121 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 21 over it, 1.21× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: pyrefly::lib::lsp::non_wasm::will_rename_files::will_rename_files pyrefly/lib/lsp/non_wasm/will_rename_files.rs:164— FunctionTooLong — pyrefly::lib::lsp::non_wasm::will_rename_files::will_rename_files runs 120 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 20 over it, 1.20× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: presetLandingPageHeader.PresetLandingPageHeader website/src/components/landing-page/presetLandingPageHeader.tsx:22— FunctionTooLong — PresetLandingPageHeader runs 113 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 13 over it, 1.13× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: pyrefly_types::einops::parse_expression crates/pyrefly_types/src/einops.rs:163— FunctionTooLong — pyrefly_types::einops::parse_expression runs 110 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 10 over it, 1.10× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: whyPyreflyGridItem.WhyPyreflyGridItem website/src/components/landing-page/whyPyreflyGridItem.tsx:44— FunctionTooLong — WhyPyreflyGridItem runs 109 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 9 over it, 1.09× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: pyrefly::lib::lsp::non_wasm::server::capabilities pyrefly/lib/lsp/non_wasm/server.rs:1632— FunctionTooLong — pyrefly::lib::lsp::non_wasm::server::capabilities runs 103 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 3 over it, 1.03× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: pyrefly::lib::state::lsp::quick_fixes::deprecated_contextmanager::replace_return_code_action pyrefly/lib/state/lsp/quick_fixes/deprecated_contextmanager.rs:44— FunctionTooLong — pyrefly::lib::state::lsp::quick_fixes::deprecated_contextmanager::replace_return_code_action runs 103 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 3 over it, 1.03× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: InlayCodeBlock.InlayCodeBlock website/src/components/InlayCodeBlock.tsx:33— FunctionTooLong — InlayCodeBlock runs 103 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 3 over it, 1.03× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: pyrefly::lib::alt::regex::validate_pattern pyrefly/lib/alt/regex.rs:21— FunctionTooLong — pyrefly::lib::alt::regex::validate_pattern runs 101 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 1 over it, 1.01× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: pyrefly::lib::state::lsp::quick_fixes::change_signature::change_signature_code_actions pyrefly/lib/state/lsp/quick_fixes/change_signature.rs:65— FunctionTooLong — pyrefly::lib::state::lsp::quick_fixes::change_signature::change_signature_code_actions runs 101 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 1 over it, 1.01× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: pyrefly::lib::state::lsp::quick_fixes::extract_function::extract_function_code_actions pyrefly/lib/state/lsp/quick_fixes/extract_function.rs:39— FunctionTooLong — pyrefly::lib::state::lsp::quick_fixes::extract_function::extract_function_code_actions runs 101 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 1 over it, 1.01× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
Duplicated block (9 lines × 2) crates/pyrefly_lsp_test/src/object_model.rs:886— crates/pyrefly_lsp_test/src/object_model.rs:886-894 | crates/pyrefly_lsp_test/src/object_model.rs:904-912 — both copies are in the same file, so extract the 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, `crates/pyrefly_lsp_test/src/object_model.rs:885` calls `from_value`, `unwrap` and `crates/pyrefly_lsp_test/src/object_model.rs:903` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (9 lines × 2) crates/pyrefly_types/src/type_level_dsl.rs:3673— crates/pyrefly_types/src/type_level_dsl.rs:3673-3681 | crates/pyrefly_types/src/type_level_dsl.rs:3799-3807 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/pyrefly_types/src/type_level_dsl.rs:3673` it begins part-way through the construct above it, so those exact lines 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) crates/pyrefly_types/src/type_level_dsl.rs:7846— crates/pyrefly_types/src/type_level_dsl.rs:7846-7854 | crates/pyrefly_types/src/type_level_dsl.rs:7884-7892 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/pyrefly_types/src/type_level_dsl.rs:7846` it begins part-way through the construct above it, so those exact lines 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) pyrefly/lib/alt/call.rs:683— pyrefly/lib/alt/call.rs:683-691 | pyrefly/lib/alt/call.rs:706-714 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/alt/call.rs:683` it begins part-way through the construct above it, so those exact lines 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) pyrefly/lib/alt/class/class_field.rs:6519— pyrefly/lib/alt/class/class_field.rs:6519-6527 | pyrefly/lib/alt/class/class_field.rs:6551-6559 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/alt/class/class_field.rs:6519` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (9 lines × 2) pyrefly/lib/alt/class/class_field.rs:6603— pyrefly/lib/alt/class/class_field.rs:6603-6611 | pyrefly/lib/alt/class/class_field.rs:6648-6656 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/alt/class/class_field.rs:6603` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (9 lines × 2) pyrefly/lib/alt/class/enums.rs:270— pyrefly/lib/alt/class/enums.rs:270-279 | pyrefly/lib/alt/class/enums.rs:478-486 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/alt/class/enums.rs:270` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `pyrefly/lib/alt/class/enums.rs:280` calls `Some`, `type_of_enum_value` and `pyrefly/lib/alt/class/enums.rs:487` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (9 lines × 2) pyrefly/lib/alt/narrow.rs:1653— pyrefly/lib/alt/narrow.rs:1653-1661 | pyrefly/lib/alt/narrow.rs:1675-1683 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/alt/narrow.rs:1653` it does not close everything it opens, so those exact lines 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) pyrefly/lib/alt/operators.rs:858— pyrefly/lib/alt/operators.rs:858-866 | pyrefly/lib/alt/operators.rs:967-975 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/alt/operators.rs:858` it begins part-way through the construct above it, so those exact lines 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) pyrefly/lib/lsp/non_wasm/lsp.rs:23— pyrefly/lib/lsp/non_wasm/lsp.rs:23-31 | pyrefly/lib/lsp/non_wasm/lsp.rs:38-46 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
Duplicated block (9 lines × 2) pyrefly/lib/report/pysa.rs:642— pyrefly/lib/report/pysa.rs:642-650 | pyrefly/lib/report/pysa.rs:670-678 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/report/pysa.rs:642` it begins part-way through the construct above it, so those exact lines 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) pyrefly/lib/report/pysa.rs:652— pyrefly/lib/report/pysa.rs:652-660 | pyrefly/lib/report/pysa.rs:664-672 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/report/pysa.rs:652` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (9 lines × 2) pyrefly/lib/state/lsp.rs:5972— pyrefly/lib/state/lsp.rs:5972-5980 | pyrefly/lib/state/lsp.rs:5994-6002 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/state/lsp.rs:5994` it begins part-way through the construct above it, so those exact lines 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) pyrefly/lib/state/lsp/quick_fixes/pyrefly_ignore.rs:33— pyrefly/lib/state/lsp/quick_fixes/pyrefly_ignore.rs:33-41 | pyrefly/lib/state/lsp/quick_fixes/pyrefly_ignore.rs:47-55 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (9 lines × 2) pyrefly/lib/state/lsp/dict_completions.rs:690— pyrefly/lib/state/lsp/dict_completions.rs:690-698 | pyrefly/lib/state/lsp/dict_completions.rs:722-730 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/state/lsp/dict_completions.rs:690` it begins part-way through the construct above it, so those 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, `pyrefly/lib/state/lsp/dict_completions.rs:721` calls `string_literal_priority` and `pyrefly/lib/state/lsp/dict_completions.rs:689` 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) pyrefly/lib/report/pysa/capnp_writer.rs:652— pyrefly/lib/report/pysa/capnp_writer.rs:652-660 | pyrefly/lib/report/pysa/capnp_writer.rs:719-727 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/report/pysa/capnp_writer.rs:652` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9 lines × 2) pyrefly/lib/lsp/non_wasm/call_hierarchy.rs:64— pyrefly/lib/lsp/non_wasm/call_hierarchy.rs:64-75 | pyrefly/lib/lsp/non_wasm/type_hierarchy.rs:20-28 — 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 `pyrefly/lib/lsp/non_wasm/call_hierarchy.rs:64` it begins part-way through the construct above it, so those exact lines 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) crates/pyrefly_types/src/type_level_dsl.rs:3538— crates/pyrefly_types/src/type_level_dsl.rs:3538-3546 | crates/pyrefly_types/src/type_level_dsl.rs:3588-3596 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/pyrefly_types/src/type_level_dsl.rs:3538` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (9 lines × 2) tensor-shapes/pyrefly-torch-stubs/examples/unet.py:196— tensor-shapes/pyrefly-torch-stubs/examples/unet.py:196-204 | tensor-shapes/pyrefly-torch-stubs/examples/unet.py:256-264 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (8 lines × 2) crates/pyrefly_types/src/callable.rs:712— crates/pyrefly_types/src/callable.rs:712-719 | crates/pyrefly_types/src/callable.rs:726-733 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/pyrefly_types/src/callable.rs:712` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (8 lines × 2) crates/pyrefly_types/src/dimension.rs:1063— crates/pyrefly_types/src/dimension.rs:1063-1070 | crates/pyrefly_types/src/dimension.rs:1074-1083 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/pyrefly_types/src/dimension.rs:1063` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8 lines × 2) pyrefly/lib/alt/attr.rs:2213— pyrefly/lib/alt/attr.rs:2213-2220 | pyrefly/lib/alt/attr.rs:2335-2342 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/alt/attr.rs:2213` it begins part-way through the construct above it, so those exact lines 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) pyrefly/lib/alt/class/class_field.rs:926— pyrefly/lib/alt/class/class_field.rs:926-933 | pyrefly/lib/alt/class/class_field.rs:1248-1258 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/alt/class/class_field.rs:926` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8 lines × 2) pyrefly/lib/alt/expr.rs:1344— pyrefly/lib/alt/expr.rs:1344-1351 | pyrefly/lib/alt/expr.rs:1358-1365 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/alt/expr.rs:1344` it does not close everything it opens, so those exact lines 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) pyrefly/lib/alt/operators.rs:441— pyrefly/lib/alt/operators.rs:441-448 | pyrefly/lib/alt/operators.rs:455-462 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/alt/operators.rs:441` it does not close everything it opens, so those exact lines 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) pyrefly/lib/alt/unwrap.rs:209— pyrefly/lib/alt/unwrap.rs:209-216 | pyrefly/lib/alt/unwrap.rs:259-266 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (8 lines × 2) pyrefly/lib/alt/unwrap.rs:279— pyrefly/lib/alt/unwrap.rs:279-286 | pyrefly/lib/alt/unwrap.rs:445-452 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (8 lines × 2) pyrefly/lib/commands/init.rs:313— pyrefly/lib/commands/init.rs:313-320 | pyrefly/lib/commands/init.rs:365-372 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/commands/init.rs:313` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `pyrefly/lib/commands/init.rs:321` calls `to_string_pretty` and `pyrefly/lib/commands/init.rs:373` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (8 lines × 2) pyrefly/lib/lsp/non_wasm/server.rs:2486— pyrefly/lib/lsp/non_wasm/server.rs:2486-2493 | pyrefly/lib/lsp/non_wasm/server.rs:2608-2615 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/lsp/non_wasm/server.rs:2486` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8 lines × 2) pyrefly/lib/state/state.rs:1633— pyrefly/lib/state/state.rs:1633-1640 | pyrefly/lib/state/state.rs:2709-2716 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (8 lines × 2) pyrefly/lib/binding/expr.rs:1031— pyrefly/lib/binding/expr.rs:1031-1038 | pyrefly/lib/binding/expr.rs:1051-1058 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/binding/expr.rs:1031` it does not close everything it opens, so those exact lines 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) pyrefly/lib/export/definitions.rs:399— pyrefly/lib/export/definitions.rs:399-406 | pyrefly/lib/export/deprecation.rs:18-25 — 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 `pyrefly/lib/export/definitions.rs:399` it does not close everything it opens, so those exact lines 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) crates/pyrefly_build/src/query.rs:43— crates/pyrefly_build/src/query.rs:43-50 | crates/pyrefly_build/src/source_db/buck_check.rs:50-57 — 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) pyrefly/lib/lsp/non_wasm/convert_module_package.rs:116— pyrefly/lib/lsp/non_wasm/convert_module_package.rs:116-123 | pyrefly/lib/lsp/non_wasm/convert_module_package.rs:146-154 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/lsp/non_wasm/convert_module_package.rs:116` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (8 lines × 2) pyrefly/lib/state/lsp.rs:2351— pyrefly/lib/state/lsp.rs:2351-2358 | pyrefly/lib/state/lsp.rs:2824-2831 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (8 lines × 2) pyrefly/lib/alt/regex.rs:82— pyrefly/lib/alt/regex.rs:82-89 | pyrefly/lib/alt/regex.rs:95-102 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
Duplicated block (8 lines × 2) tensor-shapes/pyrefly-torch-stubs/examples/demucs.py:498— tensor-shapes/pyrefly-torch-stubs/examples/demucs.py:498-509 | tensor-shapes/pyrefly-torch-stubs/examples/demucs.py:514-521 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (8 lines × 2) tensor-shapes/jax-pyrefly-stubs/examples/bert.py:477— tensor-shapes/jax-pyrefly-stubs/examples/bert.py:477-484 | tensor-shapes/jax-pyrefly-stubs/examples/bert.py:490-497 — both copies are in the same file, so extract the 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) crates/pyrefly_types/src/type_level_dsl.rs:8319— crates/pyrefly_types/src/type_level_dsl.rs:8319-8324 | crates/pyrefly_types/src/type_level_dsl.rs:8346-8352 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/pyrefly_types/src/type_level_dsl.rs:8319` it begins part-way through the construct above it, so those exact lines 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) pyrefly/lib/alt/attr.rs:2799— pyrefly/lib/alt/attr.rs:2799-2804 | pyrefly/lib/alt/attr.rs:2960-2965 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/alt/attr.rs:2799` it does not close everything it opens, so those exact lines 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) pyrefly/lib/alt/class/dataclass.rs:423— pyrefly/lib/alt/class/dataclass.rs:423-428 | pyrefly/lib/alt/class/dataclass.rs:470-475 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/alt/class/dataclass.rs:423` it does not close everything it opens, so those exact lines 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) pyrefly/lib/alt/expr.rs:2364— pyrefly/lib/alt/expr.rs:2364-2369 | pyrefly/lib/alt/expr.rs:2376-2381 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/alt/expr.rs:2364` it does not close everything it opens, so those exact lines 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) pyrefly/lib/alt/function.rs:3073— pyrefly/lib/alt/function.rs:3073-3078 | pyrefly/lib/alt/function.rs:3170-3175 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/alt/function.rs:3073` it does not close everything it opens, so those exact lines 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) pyrefly/lib/binding/expr.rs:1210— pyrefly/lib/binding/expr.rs:1210-1215 | pyrefly/lib/binding/expr.rs:1217-1222 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
Duplicated block (6 lines × 2) pyrefly/lib/binding/stmt.rs:548— pyrefly/lib/binding/stmt.rs:548-553 | pyrefly/lib/binding/stmt.rs:588-593 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/binding/stmt.rs:548` it does not close everything it opens, so those exact lines 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) pyrefly/lib/commands/buck_check.rs:216— pyrefly/lib/commands/buck_check.rs:216-221 | pyrefly/lib/playground.rs:441-446 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (6 lines × 2) pyrefly/lib/error/suppress.rs:140— pyrefly/lib/error/suppress.rs:140-145 | pyrefly/lib/state/lsp/quick_fixes/unused_ignore.rs:26-31 — 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 `pyrefly/lib/error/suppress.rs:140` it does not close everything it opens, so those exact lines 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) pyrefly/lib/report/pysa/capnp_writer.rs:374— pyrefly/lib/report/pysa/capnp_writer.rs:374-379 | pyrefly/lib/report/pysa/capnp_writer.rs:388-393 — both copies are in the same file, so extract the 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) pyrefly/lib/solver/subset.rs:497— pyrefly/lib/solver/subset.rs:497-502 | pyrefly/lib/solver/subset.rs:508-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. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/solver/subset.rs:497` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (6 lines × 2) pyrefly/lib/state/lsp/quick_fixes/extract_field.rs:177— pyrefly/lib/state/lsp/quick_fixes/extract_field.rs:177-182 | pyrefly/lib/state/lsp/quick_fixes/introduce_parameter.rs:302-307 — 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 `pyrefly/lib/state/lsp/quick_fixes/extract_field.rs:177` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (6 lines × 2) crates/pyrefly_types/src/type_level_dsl.rs:7144— crates/pyrefly_types/src/type_level_dsl.rs:7144-7149 | crates/pyrefly_types/src/type_level_dsl.rs:7353-7358 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/pyrefly_types/src/type_level_dsl.rs:7144` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (6 lines × 2) crates/pyrefly_types/src/shape_index.rs:649— crates/pyrefly_types/src/shape_index.rs:649-654 | crates/pyrefly_types/src/shape_index.rs:662-667 — both copies are in the same file, so extract the 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) pyrefly/lib/error/collector.rs:199— pyrefly/lib/error/collector.rs:199-204 | pyrefly/lib/error/collector.rs:297-302 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/error/collector.rs:199` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `pyrefly/lib/error/collector.rs:205` calls `concat` and `pyrefly/lib/error/collector.rs:303` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (6 lines × 2) tensor-shapes/pyrefly-numpy-stubs/examples/physical_science.py:88— tensor-shapes/pyrefly-numpy-stubs/examples/physical_science.py:88-93 | tensor-shapes/pyrefly-numpy-stubs/examples/physical_science.py:145-150 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (6 lines × 2) tensor-shapes/pyrefly-torch-stubs/examples/stargan.py:213— tensor-shapes/pyrefly-torch-stubs/examples/stargan.py:213-218 | tensor-shapes/pyrefly-torch-stubs/examples/stargan.py:222-227 — both copies are in the same file, so extract the 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) tensor-shapes/pyrefly-torch-stubs/examples/stargan.py:231— tensor-shapes/pyrefly-torch-stubs/examples/stargan.py:231-236 | tensor-shapes/pyrefly-torch-stubs/examples/stargan.py:240-245 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
BindingsBuilder::stmt_impl (cyclomatic 188) pyrefly/lib/binding/stmt.rs:929— BindingsBuilder::stmt_impl has cyclomatic complexity 188 (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.
BindingsBuilder::bind_pattern (cyclomatic 86) pyrefly/lib/binding/pattern.rs:314— BindingsBuilder::bind_pattern has cyclomatic complexity 86 (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.
BindingsBuilder::ensure_expr (cyclomatic 80) pyrefly/lib/binding/expr.rs:796— BindingsBuilder::ensure_expr has cyclomatic complexity 80 (threshold 15). Of this number, 79 points are the body's own statements and 1 belongs to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
BindingsBuilder::ensure_type_impl (cyclomatic 35) pyrefly/lib/binding/expr.rs:1332— BindingsBuilder::ensure_type_impl has cyclomatic complexity 35 (threshold 15). Of this number, 34 points are the body's own statements and 1 belongs to one function item inside it that branches. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
BindingsBuilder::class_def_inner (cyclomatic 34) pyrefly/lib/binding/class.rs:253— BindingsBuilder::class_def_inner has cyclomatic complexity 34 (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.
BindingsBuilder::stmt_match (cyclomatic 34) pyrefly/lib/binding/pattern.rs:965— BindingsBuilder::stmt_match has cyclomatic complexity 34 (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.
BindingsBuilder::merged_flow_info (cyclomatic 29) pyrefly/lib/binding/scope.rs:4777— BindingsBuilder::merged_flow_info has cyclomatic complexity 29 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
BindingsBuilder::function_body (cyclomatic 28) pyrefly/lib/binding/function.rs:877— BindingsBuilder::function_body has cyclomatic complexity 28 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
BindingsBuilder::extract_pydantic_config_dict (cyclomatic 25) pyrefly/lib/binding/pydantic.rs:305— BindingsBuilder::extract_pydantic_config_dict has cyclomatic complexity 25 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
BindingsBuilder::merge_flow (cyclomatic 25) pyrefly/lib/binding/scope.rs:5047— BindingsBuilder::merge_flow has cyclomatic complexity 25 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
BindingsBuilder::stmts (cyclomatic 22) pyrefly/lib/binding/bindings.rs:1929— BindingsBuilder::stmts has cyclomatic complexity 22 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
BindingsBuilder::bind_single_name_assign (cyclomatic 22) pyrefly/lib/binding/target.rs:676— BindingsBuilder::bind_single_name_assign has cyclomatic complexity 22 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
BindingsBuilder::ensure_name_impl (cyclomatic 21) pyrefly/lib/binding/expr.rs:423— BindingsBuilder::ensure_name_impl 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.
BindingsBuilder::as_assert_in_test (cyclomatic 18) pyrefly/lib/binding/expr.rs:667— BindingsBuilder::as_assert_in_test has cyclomatic complexity 18 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
BindingsBuilder::shape_comment_target (cyclomatic 17) pyrefly/lib/binding/shape_type.rs:314— BindingsBuilder::shape_comment_target 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.
BindingsBuilder::extract_django_fields_from_class_body (cyclomatic 16) pyrefly/lib/binding/django.rs:62— BindingsBuilder::extract_django_fields_from_class_body 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.
BindingsBuilder::typealiastype_from_call (cyclomatic 16) pyrefly/lib/binding/stmt.rs:663— BindingsBuilder::typealiastype_from_call 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.
pyrefly_types::shape_index::lower_index_type_in_position (cognitive 59) crates/pyrefly_types/src/shape_index.rs:401— pyrefly_types::shape_index::lower_index_type_in_position has cognitive complexity 59 (threshold 15). Drivers by points: match/switch 10 (25 pts), if/else 15 (24 pts), loops 2 (6 pts), boolean chains 4 (nesting depth added 28). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
pyrefly_types::einops::evaluate_einops_pattern (cognitive 57) crates/pyrefly_types/src/einops.rs:398— pyrefly_types::einops::evaluate_einops_pattern has cognitive complexity 57 (threshold 15). Drivers by points: if/else 17 (34 pts), match/switch 6 (10 pts), boolean chains 7, loops 4 (6 pts) (nesting depth added 23). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
pyrefly_types::einops::parse_expression (cognitive 42) crates/pyrefly_types/src/einops.rs:163— pyrefly_types::einops::parse_expression has cognitive complexity 42 (threshold 15). Drivers by points: if/else 17 (33 pts), match/switch 3 (5 pts), boolean chains 3, loops 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.
pyrefly_types::einsum::parse_einops_einsum_equation (cognitive 38) crates/pyrefly_types/src/einsum.rs:178— pyrefly_types::einsum::parse_einops_einsum_equation has cognitive complexity 38 (threshold 15). Drivers by points: if/else 11 (27 pts), loops 3 (4 pts), match/switch 2 (4 pts), boolean chains 3 (nesting depth added 19). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
pyrefly_types::dimension::canonicalize_division (cognitive 35) crates/pyrefly_types/src/dimension.rs:973— pyrefly_types::dimension::canonicalize_division has cognitive complexity 35 (threshold 15). Drivers by points: if/else 16 (30 pts), boolean chains 2, loops 1 (2 pts), match/switch 1 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
pyrefly_types::shaped_array::reduce_axis_shape (cognitive 35) crates/pyrefly_types/src/shaped_array.rs:1041— pyrefly_types::shaped_array::reduce_axis_shape has cognitive complexity 35 (threshold 15). Drivers by points: if/else 16 (25 pts), boolean chains 5, match/switch 3 (4 pts), loops 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
pyrefly_types::dimension::canonicalize_product (cognitive 33) crates/pyrefly_types/src/dimension.rs:820— pyrefly_types::dimension::canonicalize_product has cognitive complexity 33 (threshold 15). Drivers by points: if/else 12 (22 pts), loops 3 (6 pts), match/switch 1 (3 pts), boolean chains 2 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
pyrefly_types::simplify::collapse_literals (cognitive 32) crates/pyrefly_types/src/simplify.rs:205— pyrefly_types::simplify::collapse_literals has cognitive complexity 32 (threshold 15). Drivers by points: if/else 6 (10 pts), match/switch 4 (10 pts), boolean chains 9, loops 3 (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.
pyrefly_types::type_level_dsl::lower_parameter (cognitive 27) crates/pyrefly_types/src/type_level_dsl.rs:8662— pyrefly_types::type_level_dsl::lower_parameter has cognitive complexity 27 (threshold 15). Drivers by points: match/switch 7 (17 pts), if/else 4 (8 pts), loops 1 (2 pts) (nesting depth added 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
pyrefly_types::gufunc::parse_gufunc_signature (cognitive 24) crates/pyrefly_types/src/gufunc.rs:241— pyrefly_types::gufunc::parse_gufunc_signature has cognitive complexity 24 (threshold 15). Drivers by points: match/switch 8 (11 pts), if/else 7 (9 pts), boolean chains 2, loops 2 (nesting depth added 5). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
pyrefly_types::einsum::evaluate_einops_einsum (cognitive 19) crates/pyrefly_types/src/einsum.rs:268— pyrefly_types::einsum::evaluate_einops_einsum has cognitive complexity 19 (threshold 15). Drivers by points: match/switch 3 (8 pts), if/else 3 (5 pts), loops 3 (4 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.
pyrefly_types::shape_index::index_shape_multi (cognitive 19) crates/pyrefly_types/src/shape_index.rs:799— pyrefly_types::shape_index::index_shape_multi has cognitive complexity 19 (threshold 15). Drivers by points: if/else 9 (15 pts), boolean chains 3, match/switch 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
pyrefly_types::simplify::collapse_quantifieds (cognitive 19) crates/pyrefly_types/src/simplify.rs:461— pyrefly_types::simplify::collapse_quantifieds has cognitive complexity 19 (threshold 15). Drivers by points: if/else 5 (12 pts), loops 3 (5 pts), match/switch 1 (2 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
pyrefly_types::einsum::parse_einsum_equation (cognitive 18) crates/pyrefly_types/src/einsum.rs:380— pyrefly_types::einsum::parse_einsum_equation has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (10 pts), match/switch 3 (6 pts), loops 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
pyrefly_types::einsum::evaluate_einsum (cognitive 18) crates/pyrefly_types/src/einsum.rs:482— pyrefly_types::einsum::evaluate_einsum has cognitive complexity 18 (threshold 15). Drivers by points: match/switch 4 (10 pts), if/else 3 (5 pts), loops 2, boolean chains 1 (nesting depth added 8). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
pyrefly_types::shape_index::lower_integer_type (cognitive 16) crates/pyrefly_types/src/shape_index.rs:124— pyrefly_types::shape_index::lower_integer_type has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (9 pts), match/switch 2 (4 pts), loops 1 (2 pts), boolean chains 1 (nesting depth added 5). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
pyrefly_types::shape_index::lower_integer_tuple (cognitive 16) crates/pyrefly_types/src/shape_index.rs:280— pyrefly_types::shape_index::lower_integer_tuple has cognitive complexity 16 (threshold 15). Drivers by points: match/switch 5 (9 pts), loops 2 (4 pts), if/else 2 (3 pts) (nesting depth added 7). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
Duplicated block (10 lines × 2) crates/pyrefly_types/src/display.rs:1562— crates/pyrefly_types/src/display.rs:1562-1571 | crates/pyrefly_types/src/display.rs:1587-1596 — both copies are in the same file, so extract the 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) crates/pyrefly_types/src/type_level_dsl.rs:2613— crates/pyrefly_types/src/type_level_dsl.rs:2613-2622 | crates/pyrefly_types/src/type_level_dsl.rs:2904-2913 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/pyrefly_types/src/type_level_dsl.rs:2613` it does not close everything it opens, so those exact lines 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) crates/pyrefly_types/src/type_level_dsl.rs:3654— crates/pyrefly_types/src/type_level_dsl.rs:3654-3663 | crates/pyrefly_types/src/type_level_dsl.rs:3780-3789 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/pyrefly_types/src/type_level_dsl.rs:3654` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (10 lines × 2) pyrefly/lib/binding/attrs.rs:140— pyrefly/lib/binding/attrs.rs:140-149 | pyrefly/lib/binding/attrs.rs:162-171 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/binding/attrs.rs:140` it does not close everything it opens, so those 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, `pyrefly/lib/binding/attrs.rs:160` calls `entry`, `clone`, `or_insert` and `pyrefly/lib/binding/attrs.rs:139` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (10 lines × 2) pyrefly/lib/commands/check.rs:2322— pyrefly/lib/commands/check.rs:2322-2331 | pyrefly/lib/state/errors.rs:373-382 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (10 lines × 2) pyrefly/lib/lsp/non_wasm/server.rs:5065— pyrefly/lib/lsp/non_wasm/server.rs:5065-5074 | pyrefly/lib/lsp/non_wasm/server.rs:5092-5101 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/lsp/non_wasm/server.rs:5065` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10 lines × 2) pyrefly/lib/solver/solver.rs:3834— pyrefly/lib/solver/solver.rs:3834-3843 | pyrefly/lib/solver/solver.rs:3845-3854 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/solver/solver.rs:3834` it does not close everything it opens, so those exact lines 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) pyrefly/lib/state/lsp/quick_fixes/convert_dict.rs:308— pyrefly/lib/state/lsp/quick_fixes/convert_dict.rs:308-317 | pyrefly/lib/state/lsp/quick_fixes/convert_dict.rs:342-351 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/state/lsp/quick_fixes/convert_dict.rs:308` it begins part-way through the construct above it, so those exact lines 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) pyrefly/lib/stubgen/extract.rs:290— pyrefly/lib/stubgen/extract.rs:290-300 | pyrefly/lib/stubgen/extract.rs:804-813 — both copies are in the same file, so extract the 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) pyrefly/lib/stubgen/extract.rs:611— pyrefly/lib/stubgen/extract.rs:611-620 | pyrefly/lib/stubgen/extract.rs:629-638 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. 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) pyrefly/lib/alt/expr.rs:1839— pyrefly/lib/alt/expr.rs:1839-1850 | pyrefly/lib/alt/expr.rs:1877-1886 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/alt/expr.rs:1839` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (10 lines × 2) pyrefly/lib/binding/scope.rs:3075— pyrefly/lib/binding/scope.rs:3075-3084 | pyrefly/lib/binding/scope.rs:3096-3106 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/binding/scope.rs:3075` it begins part-way through the construct above it, so those exact lines 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) pyrefly/lib/error/signature_diff.rs:160— pyrefly/lib/error/signature_diff.rs:160-170 | pyrefly/lib/error/signature_diff.rs:181-190 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/error/signature_diff.rs:160` it begins part-way through the construct above it, so those exact lines 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) pyrefly/lib/binding/stmt.rs:2421— pyrefly/lib/binding/stmt.rs:2421-2430 | pyrefly/lib/binding/stmt.rs:2435-2444 — both copies are in the same file, so extract the 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) pyrefly/lib/state/errors.rs:875— pyrefly/lib/state/errors.rs:875-884 | pyrefly/lib/state/errors.rs:895-904 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/state/errors.rs:875` it does not close everything it opens, so those exact lines 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) pyrefly/lib/tsp/type_conversion.rs:1042— pyrefly/lib/tsp/type_conversion.rs:1042-1051 | pyrefly/lib/tsp/type_conversion.rs:1057-1066 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/tsp/type_conversion.rs:1042` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10 lines × 2) pyrefly/lib/binding/narrow.rs:548— pyrefly/lib/binding/narrow.rs:548-557 | pyrefly/lib/binding/narrow.rs:559-568 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
pyrefly_types::einops::evaluate_einops_pattern (cyclomatic 40) crates/pyrefly_types/src/einops.rs:398— pyrefly_types::einops::evaluate_einops_pattern 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.
pyrefly_types::shape_index::lower_index_type_in_position (cyclomatic 40) crates/pyrefly_types/src/shape_index.rs:401— pyrefly_types::shape_index::lower_index_type_in_position has cyclomatic complexity 40 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
pyrefly_types::simplify::collapse_literals (cyclomatic 36) crates/pyrefly_types/src/simplify.rs:205— pyrefly_types::simplify::collapse_literals has cyclomatic complexity 36 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
pyrefly_types::einops::parse_expression (cyclomatic 27) crates/pyrefly_types/src/einops.rs:163— pyrefly_types::einops::parse_expression 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.
pyrefly_types::shaped_array::reduce_axis_shape (cyclomatic 22) crates/pyrefly_types/src/shaped_array.rs:1041— pyrefly_types::shaped_array::reduce_axis_shape has cyclomatic complexity 22 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
pyrefly_types::type_level_dsl::lower_parameter (cyclomatic 21) crates/pyrefly_types/src/type_level_dsl.rs:8662— pyrefly_types::type_level_dsl::lower_parameter has cyclomatic complexity 21 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
pyrefly_types::einsum::parse_einops_einsum_equation (cyclomatic 20) crates/pyrefly_types/src/einsum.rs:178— pyrefly_types::einsum::parse_einops_einsum_equation 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.
pyrefly_types::dimension::canonicalize_division (cyclomatic 19) crates/pyrefly_types/src/dimension.rs:973— pyrefly_types::dimension::canonicalize_division 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. This is NOT this file's highest cyclomatic complexity: pyrefly_types::dimension::compare_int (cyclomatic 22) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded function is counted neither in this dimension's figures nor in its score.
pyrefly_types::gufunc::parse_gufunc_signature (cyclomatic 19) crates/pyrefly_types/src/gufunc.rs:241— pyrefly_types::gufunc::parse_gufunc_signature has cyclomatic complexity 19 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
pyrefly_types::dimension::int_is_provably_negative (cyclomatic 18) crates/pyrefly_types/src/dimension.rs:338— pyrefly_types::dimension::int_is_provably_negative has cyclomatic complexity 18 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators. This is NOT this file's highest cyclomatic complexity: pyrefly_types::dimension::compare_int (cyclomatic 22) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded function is counted neither in this dimension's figures nor in its score.
pyrefly_types::literal::write_escaped_string (cyclomatic 18) crates/pyrefly_types/src/literal.rs:62— pyrefly_types::literal::write_escaped_string has cyclomatic complexity 18 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
pyrefly_types::shape_index::lower_integer_tuple (cyclomatic 18) crates/pyrefly_types/src/shape_index.rs:280— pyrefly_types::shape_index::lower_integer_tuple has cyclomatic complexity 18 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
pyrefly_types::dimension::canonicalize_product (cyclomatic 17) crates/pyrefly_types/src/dimension.rs:820— pyrefly_types::dimension::canonicalize_product 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 is NOT this file's highest cyclomatic complexity: pyrefly_types::dimension::compare_int (cyclomatic 22) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded function is counted neither in this dimension's figures nor in its score.
pyrefly_types::type_level_dsl::evaluate_dimension_arithmetic (cyclomatic 17) crates/pyrefly_types/src/type_level_dsl.rs:8731— pyrefly_types::type_level_dsl::evaluate_dimension_arithmetic has cyclomatic complexity 17 (threshold 15). Of this number, 12 points are the body's own statements and 5 belong to one function item inside it that branches. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
pyrefly_types::einsum::parse_einsum_equation (cyclomatic 16) crates/pyrefly_types/src/einsum.rs:380— pyrefly_types::einsum::parse_einsum_equation 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.
Transaction::completion_sorted_opt_with_incomplete (cyclomatic 58) pyrefly/lib/lsp/wasm/completion.rs:1250— Transaction::completion_sorted_opt_with_incomplete has cyclomatic complexity 58 (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.
Transaction::local_quickfix_code_actions_sorted (cyclomatic 57) pyrefly/lib/state/lsp.rs:3803— Transaction::local_quickfix_code_actions_sorted has cyclomatic complexity 57 (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.
Transaction::find_definition (cyclomatic 51) pyrefly/lib/state/lsp.rs:3076— Transaction::find_definition has cyclomatic complexity 51 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Transaction::inlay_hints (cyclomatic 49) pyrefly/lib/lsp/wasm/inlay_hints.rs:116— Transaction::inlay_hints has cyclomatic complexity 49 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Transaction::demand (cyclomatic 37) pyrefly/lib/state/state.rs:1559— Transaction::demand 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.
Transaction::add_match_class_keyword_completions (cyclomatic 31) pyrefly/lib/lsp/wasm/completion.rs:1086— Transaction::add_match_class_keyword_completions 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.
Transaction::find_operator_dunder (cyclomatic 25) pyrefly/lib/state/lsp.rs:2534— Transaction::find_operator_dunder has cyclomatic complexity 25 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Transaction::clean (cyclomatic 21) pyrefly/lib/state/state.rs:1389— Transaction::clean 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.
Transaction::pytest_fixture_definitions_for_parameter (cyclomatic 19) pyrefly/lib/state/lsp/pytest.rs:92— Transaction::pytest_fixture_definitions_for_parameter 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.
Transaction::extend_dict_key_suggestions (cyclomatic 18) pyrefly/lib/state/lsp/dict_completions.rs:1017— Transaction::extend_dict_key_suggestions has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Transaction::dataframe_slot_permitted (cyclomatic 16) pyrefly/lib/state/lsp/dict_completions.rs:298— Transaction::dataframe_slot_permitted has cyclomatic complexity 16 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
Transaction::add_dict_key_completions (cyclomatic 16) pyrefly/lib/state/lsp/dict_completions.rs:919— Transaction::add_dict_key_completions 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.
Transaction::find_definition_for_attribute_in_non_python_module (cyclomatic 16) pyrefly/lib/state/lsp/extra_extensions.rs:168— Transaction::find_definition_for_attribute_in_non_python_module 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.
Transaction::type_from_resolution (cyclomatic 16) pyrefly/lib/state/lsp.rs:1516— Transaction::type_from_resolution 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 is NOT this file's highest cyclomatic complexity: Transaction::identifier_from_covering_nodes (cyclomatic 22) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded function is counted neither in this dimension's figures nor in its score.
Duplicated block (11 lines × 2) crates/pyrefly_lsp_test/src/object_model.rs:562— crates/pyrefly_lsp_test/src/object_model.rs:562-572 | crates/pyrefly_lsp_test/src/object_model.rs:603-613 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
Duplicated block (11 lines × 2) crates/pyrefly_types/src/shape_index.rs:99— crates/pyrefly_types/src/shape_index.rs:99-109 | crates/pyrefly_types/src/shape_index.rs:288-298 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/pyrefly_types/src/shape_index.rs:99` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (11 lines × 2) pyrefly/lib/alt/shape_extension.rs:112— pyrefly/lib/alt/shape_extension.rs:112-122 | pyrefly/lib/alt/shape_flag.rs:186-196 — 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 `pyrefly/lib/alt/shape_extension.rs:112` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (11 lines × 2) pyrefly/lib/binding/stmt.rs:1086— pyrefly/lib/binding/stmt.rs:1086-1096 | pyrefly/lib/binding/stmt.rs:1110-1120 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/binding/stmt.rs:1086` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (11 lines × 2) pyrefly/lib/export/exports.rs:454— pyrefly/lib/export/exports.rs:454-464 | pyrefly/lib/export/exports.rs:477-487 — both copies are in the same file, so extract the 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) pyrefly/lib/report/cinderx/display.rs:26— pyrefly/lib/report/cinderx/display.rs:26-36 | pyrefly/lib/report/cinderx/display.rs:61-71 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (11 lines × 2) pyrefly/lib/binding/narrow.rs:1011— pyrefly/lib/binding/narrow.rs:1011-1021 | pyrefly/lib/binding/narrow.rs:1032-1042 — both copies are in the same file, so extract the 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) pyrefly/lib/state/lsp/quick_fixes/change_signature.rs:218— pyrefly/lib/state/lsp/quick_fixes/change_signature.rs:218-228 | pyrefly/lib/state/lsp/quick_fixes/introduce_parameter.rs:217-227 — before extracting anything, compare `pyrefly/lib/state/lsp/quick_fixes/change_signature.rs` and `pyrefly/lib/state/lsp/quick_fixes/introduce_parameter.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 62 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the 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 `pyrefly/lib/state/lsp/quick_fixes/change_signature.rs: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 (11 lines × 2) pyrefly/lib/alt/class/attrs.rs:71— pyrefly/lib/alt/class/attrs.rs:71-81 | pyrefly/lib/alt/class/attrs.rs:88-98 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/alt/class/attrs.rs:71` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (11 lines × 2) pyrefly/lib/binding/bindings.rs:3035— pyrefly/lib/binding/bindings.rs:3035-3045 | pyrefly/lib/binding/bindings.rs:3046-3056 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (11 lines × 2) crates/pyrefly_types/src/type_level_dsl.rs:3782— crates/pyrefly_types/src/type_level_dsl.rs:3782-3792 | crates/pyrefly_types/src/type_level_dsl.rs:5324-5334 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (11 lines × 2) crates/pyrefly_types/src/type_level_dsl.rs:2517— crates/pyrefly_types/src/type_level_dsl.rs:2517-2527 | crates/pyrefly_types/src/type_level_dsl.rs:5163-5173 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/pyrefly_types/src/type_level_dsl.rs:2517` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (11 lines × 2) scripts/github_utils.py:452— scripts/github_utils.py:452-462 | scripts/github_utils.py:473-483 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `scripts/github_utils.py:452` it begins part-way through the construct above it, so those exact lines 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) tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations_runnable.py:266— tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations_runnable.py:266-276 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var_runnable.py:270-280 — before extracting anything, compare `tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations_runnable.py` and `tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var_runnable.py` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 202 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the 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 `tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations_runnable.py:266` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (12 lines × 2) crates/pyrefly_types/src/display.rs:1340— crates/pyrefly_types/src/display.rs:1340-1351 | crates/pyrefly_types/src/display.rs:1559-1570 — both copies are in the same file, so extract the 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) crates/pyrefly_types/src/einsum.rs:201— crates/pyrefly_types/src/einsum.rs:201-212 | crates/pyrefly_types/src/einsum.rs:233-244 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/pyrefly_types/src/einsum.rs:201` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (12 lines × 2) crates/pyrefly_types/src/type_level_dsl.rs:6758— crates/pyrefly_types/src/type_level_dsl.rs:6758-6769 | crates/pyrefly_types/src/type_level_dsl.rs:6781-6792 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/pyrefly_types/src/type_level_dsl.rs:6758` it begins part-way through the construct above it, so those exact lines 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) crates/pyrefly_types/src/type_level_dsl.rs:7372— crates/pyrefly_types/src/type_level_dsl.rs:7372-7383 | crates/pyrefly_types/src/type_level_dsl.rs:7449-7460 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/pyrefly_types/src/type_level_dsl.rs:7372` it begins part-way through the construct above it, so those exact lines 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) pyrefly/lib/solver/subset.rs:912— pyrefly/lib/solver/subset.rs:912-923 | pyrefly/lib/solver/subset.rs:926-937 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/solver/subset.rs:912` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12 lines × 2) pyrefly/lib/state/lsp.rs:1133— pyrefly/lib/state/lsp.rs:1133-1144 | pyrefly/lib/state/lsp.rs:1167-1178 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/state/lsp.rs:1133` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (12 lines × 2) pyrefly/lib/state/lsp.rs:4181— pyrefly/lib/state/lsp.rs:4181-4192 | pyrefly/lib/state/lsp.rs:4208-4219 — both copies are in the same file, so extract the 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) pyrefly/lib/commands/init.rs:322— pyrefly/lib/commands/init.rs:322-333 | pyrefly/lib/commands/init.rs:373-384 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/commands/init.rs:322` it begins part-way through the construct above it, so those exact lines 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) crates/tsp_types/protocol_generator/generate_protocol.py:334— crates/tsp_types/protocol_generator/generate_protocol.py:334-345 | crates/tsp_types/protocol_generator/generate_protocol.py:349-360 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (12 lines × 2) crates/tsp_types/protocol_generator/generate_protocol.py:474— crates/tsp_types/protocol_generator/generate_protocol.py:474-485 | crates/tsp_types/protocol_generator/generate_protocol.py:523-534 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. 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, `crates/tsp_types/protocol_generator/generate_protocol.py:472` calls `rfind` and `crates/tsp_types/protocol_generator/generate_protocol.py:522` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (12 lines × 2) tensor-shapes/pyrefly-torch-stubs/examples/openpose.py:82— tensor-shapes/pyrefly-torch-stubs/examples/openpose.py:82-93 | tensor-shapes/pyrefly-torch-stubs/examples/openpose.py:355-366 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `tensor-shapes/pyrefly-torch-stubs/examples/openpose.py:82` it begins part-way through the construct above it, so those 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, `tensor-shapes/pyrefly-torch-stubs/examples/openpose.py:370` calls `Sequential`, `Conv2d` and `tensor-shapes/pyrefly-torch-stubs/examples/openpose.py:94` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (12 lines × 2) tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations_runnable.py:498— tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations_runnable.py:498-509 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var_runnable.py:493-504 — before extracting anything, compare `tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations_runnable.py` and `tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var_runnable.py` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 202 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (12 lines × 2) tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var.py:281— tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var.py:281-292 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var_runnable.py:229-240 — before extracting anything, compare `tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var.py` and `tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var_runnable.py` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 179 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
DslValidator::validate_condition (cyclomatic 79) crates/pyrefly_types/src/type_level_dsl.rs:4652— DslValidator::validate_condition has cyclomatic complexity 79 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
DslValidator::validate_return (cyclomatic 50) crates/pyrefly_types/src/type_level_dsl.rs:5137— DslValidator::validate_return has cyclomatic complexity 50 (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.
DslValidator::validate_dimension (cyclomatic 29) crates/pyrefly_types/src/type_level_dsl.rs:2531— DslValidator::validate_dimension has cyclomatic complexity 29 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
DslValidator::validate_assignment_value (cyclomatic 28) crates/pyrefly_types/src/type_level_dsl.rs:4103— DslValidator::validate_assignment_value 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.
DslValidator::validate_generator_source (cyclomatic 25) crates/pyrefly_types/src/type_level_dsl.rs:3160— DslValidator::validate_generator_source has cyclomatic complexity 25 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
DslValidator::validate_generator (cyclomatic 25) crates/pyrefly_types/src/type_level_dsl.rs:3358— DslValidator::validate_generator has cyclomatic complexity 25 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
DslValidator::collect_integer_expression_sources (cyclomatic 23) crates/pyrefly_types/src/type_level_dsl.rs:2195— DslValidator::collect_integer_expression_sources has cyclomatic complexity 23 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
DslValidator::validate_flag_int (cyclomatic 19) crates/pyrefly_types/src/type_level_dsl.rs:2868— DslValidator::validate_flag_int has cyclomatic complexity 19 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
DslValidator::validate_int_tuple_expression (cyclomatic 17) crates/pyrefly_types/src/type_level_dsl.rs:3974— DslValidator::validate_int_tuple_expression has cyclomatic complexity 17 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
DslValidator::classify_deferred_integer_expression (cyclomatic 17) crates/pyrefly_types/src/type_level_dsl.rs:4510— DslValidator::classify_deferred_integer_expression has cyclomatic complexity 17 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
DslValidator::validate_flag_slot (cyclomatic 16) crates/pyrefly_types/src/type_level_dsl.rs:2750— DslValidator::validate_flag_slot has cyclomatic complexity 16 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
D4 · Code Duplication· Members sharing a duplicated core (5 members, 50+ identical tokens) · ×11
Members sharing a duplicated core (5 members, 50+ identical tokens) tensor-shapes/jax-pyrefly-stubs/run_pyrefly.py:30— tensor-shapes/jax-pyrefly-stubs/run_pyrefly.py:30-83 | tensor-shapes/microtorch/run_pyrefly.py:24-50 | tensor-shapes/pyrefly-einops-stubs/run_pyrefly.py:29-79 | tensor-shapes/pyrefly-numpy-stubs/run_pyrefly.py:29-79 | tensor-shapes/pyrefly-torch-stubs/run_pyrefly.py:29-85 — 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) tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:106— tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:106-123 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations.py:109-126 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations_runnable.py:113-130 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var.py:127-144 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var_runnable.py:117-134 — 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) tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:229— tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:229-249 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations.py:232-252 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations_runnable.py:236-256 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var.py:250-270 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var_runnable.py:240-260 — 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) tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:280— tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:280-297 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations.py:283-300 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations_runnable.py:282-296 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var.py:301-318 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var_runnable.py:286-300 — 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) tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:494— tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:494-524 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations.py:497-527 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations_runnable.py:463-493 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var.py:506-536 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var_runnable.py:458-488 — 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) tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:75— tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:75-101 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations.py:75-101 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations_runnable.py:75-98 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var.py:76-102 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var_runnable.py:72-95 — 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) tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:334— tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:334-339 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations.py:334-339 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations_runnable.py:286-291 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var.py:315-320 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var_runnable.py:263-268 — 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) tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:395— tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:395-402 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations.py:395-402 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations_runnable.py:335-342 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var.py:376-383 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var_runnable.py:312-319 — 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) tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:406— tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:406-463 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations.py:406-463 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations_runnable.py:346-403 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var.py:387-444 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var_runnable.py:323-380 — 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) tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:467— tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:467-497 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations.py:467-497 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations_runnable.py:407-437 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var.py:448-478 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var_runnable.py:384-414 — 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) tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:500— tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:500-513 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations.py:500-513 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations_runnable.py:440-453 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var.py:481-494 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var_runnable.py:417-430 — 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 (11 corresponding lines) · ×11
Edited copy of a member (11 corresponding lines) crates/pyrefly_types/src/type_level_dsl.rs:1082— crates/pyrefly_types/src/type_level_dsl.rs:1082-1092 | crates/pyrefly_types/src/type_level_dsl.rs:1094-1104 — These two members are one piece of code written twice and then edited apart: 11 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (11 corresponding lines) crates/pyrefly_types/src/dimension.rs:767— crates/pyrefly_types/src/dimension.rs:767-777 | crates/pyrefly_types/src/dimension.rs:960-970 — These two members are one piece of code written twice and then edited apart: 11 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (11 corresponding lines) pyrefly/lib/alt/class/class_field.rs:646— pyrefly/lib/alt/class/class_field.rs:646-656 | pyrefly/lib/alt/class/class_field.rs:882-892 — These two members are one piece of code written twice and then edited apart: 11 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (11 corresponding lines) pyrefly/lib/alt/class/class_field.rs:923— pyrefly/lib/alt/class/class_field.rs:923-933 | pyrefly/lib/alt/class/class_field.rs:1027-1039 — These two members are one piece of code written twice and then edited apart: 11 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (11 corresponding lines) pyrefly/lib/binding/scope.rs:694— pyrefly/lib/binding/scope.rs:694-704 | pyrefly/lib/binding/scope.rs:2881-2891 — These two members are one piece of code written twice and then edited apart: 11 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (11 corresponding lines) pyrefly/lib/report/pysa/types.rs:175— pyrefly/lib/report/pysa/types.rs:175-185 | pyrefly/lib/report/pysa/types.rs:187-197 — These two members are one piece of code written twice and then edited apart: 11 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (11 corresponding lines) pyrefly/lib/error/baseline.rs:206— pyrefly/lib/error/baseline.rs:206-216 | pyrefly/lib/state/errors.rs:372-384 — These two members are one piece of code written twice and then edited apart: 11 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (11 corresponding lines) pyrefly/lib/state/state.rs:3265— pyrefly/lib/state/state.rs:3265-3275 | pyrefly/lib/state/state.rs:3328-3339 — These two members are one piece of code written twice and then edited apart: 11 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (11 corresponding lines) pyrefly/lib/alt/answers_solver.rs:1136— pyrefly/lib/alt/answers_solver.rs:1136-1148 | pyrefly/lib/alt/answers_solver.rs:1400-1410 — These two members are one piece of code written twice and then edited apart: 11 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (11 corresponding lines) crates/pyrefly_python/src/ast.rs:226— crates/pyrefly_python/src/ast.rs:226-236 | pyrefly/lib/binding/stmt.rs:204-215 — These two members are one piece of code written twice and then edited apart: 11 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (11 corresponding lines) tensor-shapes/pyrefly-torch-stubs/examples/tacotron2.py:109— tensor-shapes/pyrefly-torch-stubs/examples/tacotron2.py:109-119 | tensor-shapes/pyrefly-torch-stubs/examples/tacotron2.py:163-176 — These two members are one piece of code written twice and then edited apart: 11 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Duplicated block (15 lines × 2) crates/pyrefly_types/src/display.rs:994— crates/pyrefly_types/src/display.rs:994-1008 | crates/pyrefly_types/src/display.rs:1010-1024 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
Duplicated block (15 lines × 2) pyrefly/lib/alt/attr.rs:2197— pyrefly/lib/alt/attr.rs:2197-2211 | pyrefly/lib/alt/attr.rs:2319-2333 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/alt/attr.rs:2197` it does not close everything it opens, so those exact lines 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) pyrefly/lib/alt/class/pydantic.rs:771— pyrefly/lib/alt/class/pydantic.rs:771-785 | pyrefly/lib/alt/class/pydantic.rs:1314-1328 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/alt/class/pydantic.rs: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 (15 lines × 2) pyrefly/lib/binding/class.rs:849— pyrefly/lib/binding/class.rs:849-863 | pyrefly/lib/binding/class.rs:896-910 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/binding/class.rs:849` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (15 lines × 2) pyrefly/lib/lsp/non_wasm/server.rs:7348— pyrefly/lib/lsp/non_wasm/server.rs:7348-7362 | pyrefly/lib/lsp/non_wasm/server.rs:7401-7415 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/lsp/non_wasm/server.rs:7348` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (15 lines × 2) pyrefly/lib/report/pysa/ast_visitor.rs:345— pyrefly/lib/report/pysa/ast_visitor.rs:345-359 | pyrefly/lib/report/pysa/ast_visitor.rs:453-467 — both copies are in the same file, so extract the 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, `pyrefly/lib/report/pysa/ast_visitor.rs:362` calls `Some` and `pyrefly/lib/report/pysa/ast_visitor.rs:469` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (15 lines × 2) pyrefly/lib/solver/solver.rs:1184— pyrefly/lib/solver/solver.rs:1184-1198 | pyrefly/lib/solver/solver.rs:1249-1263 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (15 lines × 2) pyrefly/lib/state/lsp/quick_fixes/change_signature.rs:401— pyrefly/lib/state/lsp/quick_fixes/change_signature.rs:401-415 | pyrefly/lib/state/lsp/quick_fixes/introduce_parameter.rs:527-541 — before extracting anything, compare `pyrefly/lib/state/lsp/quick_fixes/change_signature.rs` and `pyrefly/lib/state/lsp/quick_fixes/introduce_parameter.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 62 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the 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 `pyrefly/lib/state/lsp/quick_fixes/change_signature.rs:401` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (15 lines × 2) crates/pyrefly_lsp_test/src/object_model.rs:2044— crates/pyrefly_lsp_test/src/object_model.rs:2044-2058 | crates/pyrefly_lsp_test/src/object_model.rs:2067-2081 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/pyrefly_lsp_test/src/object_model.rs:2044` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (15 lines × 2) tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations_runnable.py:446— tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations_runnable.py:446-460 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var_runnable.py:441-455 — before extracting anything, compare `tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations_runnable.py` and `tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var_runnable.py` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 202 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the 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 `tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations_runnable.py:446` it does not close everything it opens, so those exact lines 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) tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations_runnable.py:282— tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations_runnable.py:282-296 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var_runnable.py:286-300 — before extracting anything, compare `tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations_runnable.py` and `tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var_runnable.py` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 202 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the 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.
Server::process_event (cognitive 276) pyrefly/lib/lsp/non_wasm/server.rs:2099— Server::process_event has cognitive complexity 276 (threshold 15). Drivers by points: if/else 89 (179 pts), match/switch 22 (85 pts), boolean chains 9, loops 1 (3 pts) (nesting depth added 155). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
Server::code_action (cognitive 97) pyrefly/lib/lsp/non_wasm/server.rs:5268— Server::code_action has cognitive complexity 97 (threshold 15). Drivers by points: if/else 33 (77 pts), loops 4 (11 pts), match/switch 1 (6 pts), boolean chains 3 (nesting depth added 56). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
Server::notebook_document_did_change (cognitive 50) pyrefly/lib/lsp/non_wasm/server.rs:4457— Server::notebook_document_did_change has cognitive complexity 50 (threshold 15). Drivers by points: if/else 16 (32 pts), loops 6 (17 pts), match/switch 1 (nesting depth added 27). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Server::type_hierarchy_subtype_items (cognitive 31) pyrefly/lib/lsp/non_wasm/server.rs:7210— Server::type_hierarchy_subtype_items has cognitive complexity 31 (threshold 15). Drivers by points: if/else 11 (26 pts), loops 2 (3 pts), boolean chains 2 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Server::prune_baselines (cognitive 28) pyrefly/lib/lsp/non_wasm/server.rs:4079— Server::prune_baselines has cognitive complexity 28 (threshold 15). Drivers by points: if/else 10 (19 pts), match/switch 2 (5 pts), loops 3 (4 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Server::publish_for_handles (cognitive 24) pyrefly/lib/lsp/non_wasm/server.rs:3532— Server::publish_for_handles has cognitive complexity 24 (threshold 15). Drivers by points: loops 7 (11 pts), if/else 6 (9 pts), match/switch 1 (3 pts), boolean chains 1 (nesting depth added 9). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
Server::get_diag_if_shown (cognitive 22) pyrefly/lib/lsp/non_wasm/server.rs:3335— Server::get_diag_if_shown has cognitive complexity 22 (threshold 15). Drivers by points: if/else 6 (12 pts), boolean chains 7, match/switch 1 (3 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Server::async_go_to_implementations (cognitive 18) pyrefly/lib/lsp/non_wasm/server.rs:5132— Server::async_go_to_implementations has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (11 pts), loops 3 (5 pts), boolean chains 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Server::async_find_references_helper (cognitive 17) pyrefly/lib/lsp/non_wasm/server.rs:5717— Server::async_find_references_helper has cognitive complexity 17 (threshold 15). Drivers by points: if/else 3 (9 pts), loops 4 (7 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.
Server::setup_file_watcher_if_necessary (cognitive 16) pyrefly/lib/lsp/non_wasm/server.rs:6709— Server::setup_file_watcher_if_necessary has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (9 pts), loops 2 (4 pts), boolean chains 2, match/switch 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Duplicated block (14 lines × 2) crates/pyrefly_types/src/type_level_dsl.rs:8323— crates/pyrefly_types/src/type_level_dsl.rs:8323-8336 | crates/pyrefly_types/src/type_level_dsl.rs:8431-8444 — both copies are in the same file, so extract the 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) pyrefly/lib/alt/attr.rs:2963— pyrefly/lib/alt/attr.rs:2963-2976 | pyrefly/lib/alt/attr.rs:2987-3000 — both copies are in the same file, so extract the 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) pyrefly/lib/alt/call.rs:2697— pyrefly/lib/alt/call.rs:2697-2710 | pyrefly/lib/alt/call.rs:2720-2733 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/alt/call.rs:2697` it does not close everything it opens, so those exact lines 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) pyrefly/lib/alt/class/class_metadata.rs:1457— pyrefly/lib/alt/class/class_metadata.rs:1457-1470 | pyrefly/lib/alt/class/class_metadata.rs:1490-1503 — both copies are in the same file, so extract the 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) pyrefly/lib/alt/polars_specials.rs:3298— pyrefly/lib/alt/polars_specials.rs:3298-3311 | pyrefly/lib/alt/polars_specials.rs:3330-3343 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/alt/polars_specials.rs:3298` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `pyrefly/lib/alt/polars_specials.rs:3295` calls `chain`, `get`, `unwrap_or` and `pyrefly/lib/alt/polars_specials.rs:3327` 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) pyrefly/lib/alt/solve.rs:6007— pyrefly/lib/alt/solve.rs:6007-6020 | pyrefly/lib/alt/solve.rs:7326-7339 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/alt/solve.rs:6007` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (14 lines × 2) pyrefly/lib/lsp/wasm/completion.rs:787— pyrefly/lib/lsp/wasm/completion.rs:787-800 | pyrefly/lib/lsp/wasm/completion.rs:819-832 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/lsp/wasm/completion.rs:787` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (14 lines × 2) pyrefly/lib/playground.rs:379— pyrefly/lib/playground.rs:379-392 | pyrefly/lib/playground.rs:407-420 — both copies are in the same file, so extract the 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) pyrefly/lib/state/lsp/quick_fixes/pytest_fixture.rs:329— pyrefly/lib/state/lsp/quick_fixes/pytest_fixture.rs:329-342 | pyrefly/lib/state/lsp/quick_fixes/pytest_fixture.rs:427-440 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/state/lsp/quick_fixes/pytest_fixture.rs:329` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (14 lines × 2) tensor-shapes/pyrefly-torch-stubs/examples/llama.py:501— tensor-shapes/pyrefly-torch-stubs/examples/llama.py:501-514 | tensor-shapes/pyrefly-torch-stubs/examples/llama.py:518-531 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Subset::is_subset_eq_no_recursive_check (cognitive 145) pyrefly/lib/solver/subset.rs:1922— Subset::is_subset_eq_no_recursive_check has cognitive complexity 145 (threshold 15). Drivers by points: if/else 42 (73 pts), boolean chains 49, match/switch 10 (21 pts), loops 1 (2 pts) (nesting depth added 43). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Subset::is_subset_eq_var (cognitive 98) pyrefly/lib/solver/solver.rs:3909— Subset::is_subset_eq_var has cognitive complexity 98 (threshold 15). Drivers by points: if/else 31 (68 pts), match/switch 10 (25 pts), boolean chains 5 (nesting depth added 52). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
Subset::is_subset_param_list_impl (cognitive 91) pyrefly/lib/solver/subset.rs:258— Subset::is_subset_param_list_impl has cognitive complexity 91 (threshold 15). Drivers by points: if/else 27 (51 pts), loops 12 (20 pts), match/switch 6 (15 pts), boolean chains 5 (nesting depth added 41). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Subset::bind_tensor_dimensions (cognitive 50) pyrefly/lib/solver/subset.rs:3125— Subset::bind_tensor_dimensions has cognitive complexity 50 (threshold 15). Drivers by points: if/else 15 (29 pts), loops 7 (14 pts), boolean chains 5, match/switch 2 (nesting depth added 21). Of this number, 49 points are the body's own statements and 1 belongs to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Subset::is_subset_eq_quantified (cognitive 39) pyrefly/lib/solver/solver.rs:3745— Subset::is_subset_eq_quantified has cognitive complexity 39 (threshold 15). Drivers by points: if/else 23 (33 pts), boolean chains 3, match/switch 2 (3 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Subset::is_subset_tuple (cognitive 34) pyrefly/lib/solver/subset.rs:833— Subset::is_subset_tuple has cognitive complexity 34 (threshold 15). Drivers by points: if/else 16 (25 pts), match/switch 4 (6 pts), boolean chains 3 (nesting depth added 11). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
Subset::check_targs (cognitive 25) pyrefly/lib/solver/subset.rs:3015— Subset::check_targs has cognitive complexity 25 (threshold 15). Drivers by points: if/else 9 (14 pts), boolean chains 5, match/switch 2 (5 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.
Subset::is_subset_overload (cognitive 22) pyrefly/lib/solver/subset.rs:1609— Subset::is_subset_overload has cognitive complexity 22 (threshold 15). Drivers by points: match/switch 5 (12 pts), if/else 3 (5 pts), loops 2 (4 pts), boolean chains 1 (nesting depth added 11). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
Subset::is_subset_protocol_inner (cognitive 20) pyrefly/lib/solver/subset.rs:757— Subset::is_subset_protocol_inner has cognitive complexity 20 (threshold 15). Drivers by points: if/else 8 (12 pts), boolean chains 5, match/switch 1 (2 pts), loops 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D4 · Code Duplication· Edited copy of a member (7 corresponding lines) · ×9
Edited copy of a member (7 corresponding lines) crates/pyrefly_python/src/qname.rs:143— crates/pyrefly_python/src/qname.rs:143-149 | crates/pyrefly_python/src/qname.rs:163-174 — These two members are one piece of code written twice and then edited apart: 7 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (7 corresponding lines) crates/pyrefly_build/src/source_db/map_db.rs:77— crates/pyrefly_build/src/source_db/map_db.rs:77-83 | crates/pyrefly_build/src/source_db/map_db.rs:91-97 — These two members are one piece of code written twice and then edited apart: 7 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (7 corresponding lines) crates/pyrefly_types/src/types.rs:2188— crates/pyrefly_types/src/types.rs:2188-2195 | crates/pyrefly_types/src/types.rs:2275-2281 — These two members are one piece of code written twice and then edited apart: 7 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (7 corresponding lines) crates/pyrefly_derive/src/type_eq.rs:20— crates/pyrefly_derive/src/type_eq.rs:20-26 | crates/pyrefly_derive/src/visit.rs:47-53 — These two members are one piece of code written twice and then edited apart: 7 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (7 corresponding lines) crates/pyrefly_types/src/types.rs:551— crates/pyrefly_types/src/types.rs:551-557 | crates/pyrefly_types/src/types.rs:705-712 — These two members are one piece of code written twice and then edited apart: 7 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (7 corresponding lines) pyrefly/lib/state/errors.rs:171— pyrefly/lib/state/errors.rs:171-182 | crates/pyrefly_python/src/ignore.rs:756-762 — These two members are one piece of code written twice and then edited apart: 7 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (7 corresponding lines) crates/pyrefly_python/src/module_name.rs:583— crates/pyrefly_python/src/module_name.rs:583-589 | pyrefly/lib/lsp/wasm/hover.rs:483-490 — These two members are one piece of code written twice and then edited apart: 7 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (7 corresponding lines) pyrefly/lib/report/scip/symbols.rs:399— pyrefly/lib/report/scip/symbols.rs:399-405 | pyrefly/lib/state/lsp/fastapi_endpoint_support/association_summary.rs:273-279 — These two members are one piece of code written twice and then edited apart: 7 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (7 corresponding lines) tensor-shapes/pyrefly-torch-stubs/examples/apg.py:414— tensor-shapes/pyrefly-torch-stubs/examples/apg.py:414-423 | tensor-shapes/pyrefly-torch-stubs/examples/tts_angular.py:408-414 — These two members are one piece of code written twice and then edited apart: 7 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Duplicated block (13 lines × 2) pyrefly/lib/alt/polars_specials.rs:3319— pyrefly/lib/alt/polars_specials.rs:3319-3331 | pyrefly/lib/alt/polars_specials.rs:3351-3363 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/alt/polars_specials.rs:3319` it does not close everything it opens, so those exact lines 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) pyrefly/lib/alt/unwrap.rs:263— pyrefly/lib/alt/unwrap.rs:263-275 | pyrefly/lib/alt/unwrap.rs:283-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. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/alt/unwrap.rs:263` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (13 lines × 2) pyrefly/lib/query/type_table.rs:290— pyrefly/lib/query/type_table.rs:290-302 | pyrefly/lib/query/type_table.rs:451-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 `pyrefly/lib/query/type_table.rs:290` it begins part-way through the construct above it, so those exact lines 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) pyrefly/lib/report/cinderx.rs:168— pyrefly/lib/report/cinderx.rs:168-180 | pyrefly/lib/report/cinderx.rs:200-212 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/report/cinderx.rs:168` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (13 lines × 2) pyrefly/lib/lsp/wasm/inlay_hints.rs:568— pyrefly/lib/lsp/wasm/inlay_hints.rs:568-580 | pyrefly/lib/state/lsp.rs:1291-1303 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (13 lines × 2) crates/pyrefly_types/src/type_level_dsl.rs:7776— crates/pyrefly_types/src/type_level_dsl.rs:7776-7788 | crates/pyrefly_types/src/type_level_dsl.rs:7807-7819 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/pyrefly_types/src/type_level_dsl.rs:7776` it begins part-way through the construct above it, so those exact lines 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) pyrefly/lib/alt/operators.rs:584— pyrefly/lib/alt/operators.rs:584-596 | pyrefly/lib/alt/operators.rs:948-960 — both copies are in the same file, so extract the 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) pyrefly/lib/state/lsp/quick_fixes/pytest_fixture.rs:394— pyrefly/lib/state/lsp/quick_fixes/pytest_fixture.rs:394-406 | pyrefly/lib/state/lsp/quick_fixes/pytest_fixture.rs:455-467 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (13 lines × 2) tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations_runnable.py:372— tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations_runnable.py:372-384 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var_runnable.py:371-383 — before extracting anything, compare `tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations_runnable.py` and `tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var_runnable.py` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 202 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the 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 `tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations_runnable.py:372` it does not close everything it opens, so those 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· Edited copy of a member (16 corresponding lines) · ×8
Edited copy of a member (16 corresponding lines) crates/pyrefly_types/src/types.rs:1915— crates/pyrefly_types/src/types.rs:1915-1930 | crates/pyrefly_types/src/types.rs:1933-1948 — These two members are one piece of code written twice and then edited apart: 16 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (16 corresponding lines) pyrefly/lib/alt/call.rs:2974— pyrefly/lib/alt/call.rs:2974-2989 | pyrefly/lib/alt/call.rs:2999-3014 — These two members are one piece of code written twice and then edited apart: 16 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (16 corresponding lines) pyrefly/lib/alt/solve.rs:5029— pyrefly/lib/alt/solve.rs:5029-5044 | pyrefly/lib/alt/solve.rs:5058-5074 — These two members are one piece of code written twice and then edited apart: 16 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (16 corresponding lines) pyrefly/lib/lsp/wasm/completion.rs:915— pyrefly/lib/lsp/wasm/completion.rs:915-931 | pyrefly/lib/state/lsp.rs:473-488 — These two members are one piece of code written twice and then edited apart: 16 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (16 corresponding lines) pyrefly/lib/lsp/wasm/signature_help.rs:354— pyrefly/lib/lsp/wasm/signature_help.rs:354-371 | pyrefly/lib/lsp/wasm/signature_help.rs:378-393 — These two members are one piece of code written twice and then edited apart: 16 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (16 corresponding lines) pyrefly/lib/tsp/type_conversion.rs:623— pyrefly/lib/tsp/type_conversion.rs:623-639 | pyrefly/lib/tsp/type_conversion.rs:695-710 — These two members are one piece of code written twice and then edited apart: 16 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (16 corresponding lines) crates/pyrefly_types/src/shaped_array.rs:887— crates/pyrefly_types/src/shaped_array.rs:887-902 | pyrefly/lib/solver/subset.rs:989-1004 — These two members are one piece of code written twice and then edited apart: 16 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (16 corresponding lines) tensor-shapes/pyrefly-torch-stubs/examples/drq.py:166— tensor-shapes/pyrefly-torch-stubs/examples/drq.py:166-181 | tensor-shapes/pyrefly-torch-stubs/examples/soft_actor_critic.py:434-450 — These two members are one piece of code written twice and then edited apart: 16 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (17 corresponding lines) · ×8
Edited copy of a member (17 corresponding lines) pyrefly/lib/alt/class/class_field.rs:1080— pyrefly/lib/alt/class/class_field.rs:1080-1096 | pyrefly/lib/alt/class/class_field.rs:1098-1114 — These two members are one piece of code written twice and then edited apart: 17 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (17 corresponding lines) crates/pyrefly_build/src/query.rs:52— crates/pyrefly_build/src/query.rs:52-68 | crates/pyrefly_build/src/source_db/buck_check.rs:121-137 — These two members are one piece of code written twice and then edited apart: 17 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (17 corresponding lines) pyrefly/lib/state/lsp/quick_fixes/move_members.rs:133— pyrefly/lib/state/lsp/quick_fixes/move_members.rs:133-149 | pyrefly/lib/state/lsp/quick_fixes/move_module.rs:132-149 — These two members are one piece of code written twice and then edited apart: 17 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (17 corresponding lines) pyrefly/lib/error/error.rs:491— pyrefly/lib/error/error.rs:491-507 | pyrefly/lib/error/error.rs:612-629 — These two members are one piece of code written twice and then edited apart: 17 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (17 corresponding lines) crates/pyrefly_config/src/module_wildcard.rs:90— crates/pyrefly_config/src/module_wildcard.rs:90-109 | crates/pyrefly_python/src/sys_info.rs:136-152 — These two members are one piece of code written twice and then edited apart: 17 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (17 corresponding lines) crates/pyrefly_types/src/type_info.rs:228— crates/pyrefly_types/src/type_info.rs:228-244 | crates/pyrefly_types/src/type_info.rs:249-267 — These two members are one piece of code written twice and then edited apart: 17 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (17 corresponding lines) pyrefly/lib/commands/check.rs:892— pyrefly/lib/commands/check.rs:892-910 | pyrefly/lib/commands/check.rs:916-932 — These two members are one piece of code written twice and then edited apart: 17 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (17 corresponding lines) pyrefly/lib/state/lsp.rs:3558— pyrefly/lib/state/lsp.rs:3558-3575 | pyrefly/lib/state/lsp.rs:3621-3637 — These two members are one piece of code written twice and then edited apart: 17 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (9 corresponding lines) · ×8
Edited copy of a member (9 corresponding lines) pyrefly/lib/error/collector.rs:198— pyrefly/lib/error/collector.rs:198-207 | pyrefly/lib/error/collector.rs:296-304 — These two members are one piece of code written twice and then edited apart: 9 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (9 corresponding lines) pyrefly/lib/state/state.rs:1331— pyrefly/lib/state/state.rs:1331-1339 | pyrefly/lib/state/state.rs:1369-1382 — These two members are one piece of code written twice and then edited apart: 9 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (9 corresponding lines) pyrefly/lib/report/cinderx/convert.rs:126— pyrefly/lib/report/cinderx/convert.rs:126-135 | pyrefly/lib/report/cinderx/convert.rs:163-171 — These two members are one piece of code written twice and then edited apart: 9 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (9 corresponding lines) crates/pyrefly_python/src/qname.rs:133— crates/pyrefly_python/src/qname.rs:133-141 | crates/pyrefly_python/src/qname.rs:153-161 — These two members are one piece of code written twice and then edited apart: 9 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (9 corresponding lines) pyrefly/lib/query/type_table.rs:603— pyrefly/lib/query/type_table.rs:603-611 | crates/pyrefly_types/src/callable.rs:910-918 — These two members are one piece of code written twice and then edited apart: 9 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (9 corresponding lines) pyrefly/lib/lsp/non_wasm/server.rs:3520— pyrefly/lib/lsp/non_wasm/server.rs:3520-3529 | pyrefly/lib/lsp/wasm/completion.rs:176-184 — These two members are one piece of code written twice and then edited apart: 9 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (9 corresponding lines) tensor-shapes/pyrefly-torch-stubs/examples/resnet.py:37— tensor-shapes/pyrefly-torch-stubs/examples/resnet.py:37-45 | tensor-shapes/pyrefly-torch-stubs/examples/resnet.py:66-75 — These two members are one piece of code written twice and then edited apart: 9 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (9 corresponding lines) tensor-shapes/pyrefly-torch-stubs/examples/demucs.py:498— tensor-shapes/pyrefly-torch-stubs/examples/demucs.py:498-510 | tensor-shapes/pyrefly-torch-stubs/examples/demucs.py:514-522 — These two members are one piece of code written twice and then edited apart: 9 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (10 corresponding lines) · ×8
Edited copy of a member (10 corresponding lines) pyrefly/lib/commands/lsp.rs:168— pyrefly/lib/commands/lsp.rs:168-177 | pyrefly/lib/commands/tsp.rs:171-190 — These two members are one piece of code written twice and then edited apart: 10 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (10 corresponding lines) pyrefly/lib/query.rs:1303— pyrefly/lib/query.rs:1303-1312 | pyrefly/lib/query.rs:1327-1340 — These two members are one piece of code written twice and then edited apart: 10 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (10 corresponding lines) pyrefly/lib/report/pysa/capnp_writer.rs:372— pyrefly/lib/report/pysa/capnp_writer.rs:372-381 | pyrefly/lib/report/pysa/capnp_writer.rs:543-556 — These two members are one piece of code written twice and then edited apart: 10 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (10 corresponding lines) crates/pyrefly_lsp_test/src/object_model.rs:1626— crates/pyrefly_lsp_test/src/object_model.rs:1626-1635 | crates/pyrefly_lsp_test/src/object_model.rs:1639-1652 — These two members are one piece of code written twice and then edited apart: 10 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (10 corresponding lines) pyrefly/lib/report/cinderx/types.rs:241— pyrefly/lib/report/cinderx/types.rs:241-252 | pyrefly/lib/report/cinderx/types.rs:294-303 — These two members are one piece of code written twice and then edited apart: 10 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (10 corresponding lines) pyrefly/lib/state/lsp/quick_fixes/enum_member.rs:45— pyrefly/lib/state/lsp/quick_fixes/enum_member.rs:45-54 | pyrefly/lib/state/lsp/quick_fixes/redundant_cast.rs:20-29 — These two members are one piece of code written twice and then edited apart: 10 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (10 corresponding lines) pyrefly/lib/commands/buck_check.rs:311— pyrefly/lib/commands/buck_check.rs:311-320 | pyrefly/lib/commands/check.rs:678-687 — These two members are one piece of code written twice and then edited apart: 10 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (10 corresponding lines) tensor-shapes/pyrefly-torch-stubs/examples/background_matting.py:133— tensor-shapes/pyrefly-torch-stubs/examples/background_matting.py:133-142 | tensor-shapes/pyrefly-torch-stubs/examples/unet.py:48-57 — 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 (5 corresponding lines) · ×8
Edited copy of a member (5 corresponding lines) crates/pyrefly_types/src/callable.rs:958— crates/pyrefly_types/src/callable.rs:958-962 | crates/pyrefly_types/src/type_alias.rs:128-132 — 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) tensor-shapes/pyrefly-torch-stubs/examples/resnet.py:80— tensor-shapes/pyrefly-torch-stubs/examples/resnet.py:80-86 | tensor-shapes/pyrefly-torch-stubs/examples/unet.py:83-87 — 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) tensor-shapes/pyrefly-torch-stubs/examples/dlrm.py:82— tensor-shapes/pyrefly-torch-stubs/examples/dlrm.py:82-86 | tensor-shapes/pyrefly-torch-stubs/examples/dlrm.py:109-113 — 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) tensor-shapes/pyrefly-torch-stubs/examples/resnet.py:246— tensor-shapes/pyrefly-torch-stubs/examples/resnet.py:246-250 | tensor-shapes/pyrefly-torch-stubs/examples/resnet.py:254-258 — 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) tensor-shapes/pyrefly-torch-stubs/examples/demucs.py:463— tensor-shapes/pyrefly-torch-stubs/examples/demucs.py:463-467 | tensor-shapes/pyrefly-torch-stubs/examples/tacotron2.py:604-608 — 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) tensor-shapes/pyrefly-torch-stubs/examples/soft_actor_critic.py:278— tensor-shapes/pyrefly-torch-stubs/examples/soft_actor_critic.py:278-284 | tensor-shapes/pyrefly-torch-stubs/examples/sam.py:1028-1032 — 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) tensor-shapes/pyrefly-torch-stubs/examples/dlrm.py:409— tensor-shapes/pyrefly-torch-stubs/examples/dlrm.py:409-413 | tensor-shapes/pyrefly-torch-stubs/examples/tacotron2.py:580-584 — 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) tensor-shapes/jax-pyrefly-stubs/examples/bert.py:55— tensor-shapes/jax-pyrefly-stubs/examples/bert.py:55-59 | tensor-shapes/jax-pyrefly-stubs/examples/nanogpt.py:52-56 — 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.
Subset::is_subset_eq_no_recursive_check (cyclomatic 251) pyrefly/lib/solver/subset.rs:1922— Subset::is_subset_eq_no_recursive_check has cyclomatic complexity 251 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
Subset::is_subset_param_list_impl (cyclomatic 71) pyrefly/lib/solver/subset.rs:258— Subset::is_subset_param_list_impl has cyclomatic complexity 71 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
Subset::is_subset_eq_var (cyclomatic 55) pyrefly/lib/solver/solver.rs:3909— Subset::is_subset_eq_var has cyclomatic complexity 55 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Subset::bind_tensor_dimensions (cyclomatic 32) pyrefly/lib/solver/subset.rs:3125— Subset::bind_tensor_dimensions has cyclomatic complexity 32 (threshold 15). Of this number, 30 points are the body's own statements and 2 belong to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Subset::is_subset_tuple (cyclomatic 31) pyrefly/lib/solver/subset.rs:833— Subset::is_subset_tuple 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.
Subset::is_subset_eq_quantified (cyclomatic 21) pyrefly/lib/solver/solver.rs:3745— Subset::is_subset_eq_quantified 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.
Subset::check_targs (cyclomatic 18) pyrefly/lib/solver/subset.rs:3015— Subset::check_targs has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
DslValidator::validate_condition (cognitive 107) crates/pyrefly_types/src/type_level_dsl.rs:4652— DslValidator::validate_condition has cognitive complexity 107 (threshold 15). Drivers by points: if/else 35 (58 pts), boolean chains 22, match/switch 12 (21 pts), loops 2 (6 pts) (nesting depth added 36). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
DslValidator::validate_return (cognitive 92) crates/pyrefly_types/src/type_level_dsl.rs:5137— DslValidator::validate_return has cognitive complexity 92 (threshold 15). Drivers by points: if/else 21 (67 pts), match/switch 6 (20 pts), loops 1 (3 pts), boolean chains 2 (nesting depth added 62). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
DslValidator::collect_integer_expression_sources (cognitive 34) crates/pyrefly_types/src/type_level_dsl.rs:2195— DslValidator::collect_integer_expression_sources has cognitive complexity 34 (threshold 15). Drivers by points: if/else 7 (15 pts), loops 3 (11 pts), boolean chains 4, match/switch 2 (4 pts) (nesting depth added 18). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
DslValidator::validate_generator_source (cognitive 30) crates/pyrefly_types/src/type_level_dsl.rs:3160— DslValidator::validate_generator_source has cognitive complexity 30 (threshold 15). Drivers by points: if/else 10 (17 pts), boolean chains 5, match/switch 3 (5 pts), loops 1 (3 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
DslValidator::validate_generator (cognitive 26) crates/pyrefly_types/src/type_level_dsl.rs:3358— DslValidator::validate_generator has cognitive complexity 26 (threshold 15). Drivers by points: if/else 9 (14 pts), match/switch 5 (6 pts), loops 4 (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.
DslValidator::validate_assignment_value (cognitive 25) crates/pyrefly_types/src/type_level_dsl.rs:4103— DslValidator::validate_assignment_value has cognitive complexity 25 (threshold 15). Drivers by points: if/else 14 (22 pts), match/switch 2 (3 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
DslValidator::validate_dimension (cognitive 19) crates/pyrefly_types/src/type_level_dsl.rs:2531— DslValidator::validate_dimension has cognitive complexity 19 (threshold 15). Drivers by points: match/switch 5 (10 pts), if/else 5 (8 pts), boolean chains 1 (nesting depth added 8). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
TooManyFields: Stdlib crates/pyrefly_types/src/stdlib.rs:50— TooManyFields — 66 stored fields beside 83 methods. The bar is 30 stored fields; this is 36 over it, 2.20× the bar. This is width in DATA, not behaviour: every reader that takes the whole type couples to all of its fields, so a change to any one of them is a change every reader has to be checked against. To reduce it, group the fields that are read together by the same callers into a smaller type of their own, and have this one hold that type as a single member — each reader then names only the group it uses.
TooManyFields: RuleOverrides crates/pyrefly_config/src/migration/pyright.rs:199— TooManyFields — 61 stored fields beside 1 method. The bar is 30 stored fields; this is 31 over it, 2.03× the bar. This is width in DATA, not behaviour: every reader that takes the whole type couples to all of its fields, so a change to any one of them is a change every reader has to be checked against. To reduce it, group the fields that are read together by the same callers into a smaller type of their own, and have this one hold that type as a single member — each reader then names only the group it uses.
TooManyFields: Server pyrefly/lib/lsp/non_wasm/server.rs:1156— TooManyFields — 50 stored fields beside 110 methods. The bar is 30 stored fields; this is 20 over it, 1.67× the bar. This is width in DATA, not behaviour: every reader that takes the whole type couples to all of its fields, so a change to any one of them is a change every reader has to be checked against. To reduce it, group the fields that are read together by the same callers into a smaller type of their own, and have this one hold that type as a single member — each reader then names only the group it uses.
TooManyFields: BindingsBuilder pyrefly/lib/binding/bindings.rs:526— TooManyFields — 48 stored fields beside 243 methods. The bar is 30 stored fields; this is 18 over it, 1.60× the bar. This is width in DATA, not behaviour: every reader that takes the whole type couples to all of its fields, so a change to any one of them is a change every reader has to be checked against. To reduce it, group the fields that are read together by the same callers into a smaller type of their own, and have this one hold that type as a single member — each reader then names only the group it uses.
TooManyFields: TelemetryTransactionStats crates/pyrefly_util/src/telemetry.rs:153— TooManyFields — 44 stored fields. The bar is 30 stored fields; this is 14 over it, 1.47× the bar. This is width in DATA, not behaviour: every reader that takes the whole type couples to all of its fields, so a change to any one of them is a change every reader has to be checked against. To reduce it, group the fields that are read together by the same callers into a smaller type of their own, and have this one hold that type as a single member — each reader then names only the group it uses.
TooManyFields: ConfigFile crates/pyrefly_config/src/config.rs:611— TooManyFields — 40 stored fields beside 59 methods. The bar is 30 stored fields; this is 10 over it, 1.33× the bar. This is width in DATA, not behaviour: every reader that takes the whole type couples to all of its fields, so a change to any one of them is a change every reader has to be checked against. To reduce it, group the fields that are read together by the same callers into a smaller type of their own, and have this one hold that type as a single member — each reader then names only the group it uses.
TooManyFields: OutputArgs pyrefly/lib/commands/check.rs:311— TooManyFields — 32 stored fields beside 4 methods. The bar is 30 stored fields; this is 2 over it, 1.07× the bar. This is width in DATA, not behaviour: every reader that takes the whole type couples to all of its fields, so a change to any one of them is a change every reader has to be checked against. To reduce it, group the fields that are read together by the same callers into a smaller type of their own, and have this one hold that type as a single member — each reader then names only the group it uses.
Change coupling: map_db.rs ↔ query_source_db.rs crates/pyrefly_build/src/source_db/map_db.rs:1— `crates/pyrefly_build/src/source_db/map_db.rs` and `crates/pyrefly_build/src/source_db/query_source_db.rs` change together 79% of the time (11 of the 14 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well, and counted over this repository's 10,000 most recent commits rather than its whole history — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets) with no explicit dependency between them. They sit in the same directory, but in this ecosystem each file is its own module — a sibling reference still needs an import — so the missing import edge is real: the coupling runs through shared behaviour, not a declared dependency. If they duplicate structure, extract the common part into one unit; otherwise the coupling is hidden and worth breaking. You can check this without leaving the row: of the 11 shared commits counted here, the most recent 3 are `b5aaf8c2` Split module enumeration from source DBs; `7ecb606d` Split live/incremental source DB methods; `d5331bb3` Avoid per-origin `shape_extensions` misses — run `git show` on any of them.
Change coupling: buck_check.rs ↔ map_db.rs crates/pyrefly_build/src/source_db/buck_check.rs:1— `crates/pyrefly_build/src/source_db/buck_check.rs` and `crates/pyrefly_build/src/source_db/map_db.rs` change together 79% of the time (11 of the 14 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well, and counted over this repository's 10,000 most recent commits rather than its whole history — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets) with no explicit dependency between them. They sit in the same directory, but in this ecosystem each file is its own module — a sibling reference still needs an import — so the missing import edge is real: the coupling runs through shared behaviour, not a declared dependency. If they duplicate structure, extract the common part into one unit; otherwise the coupling is hidden and worth breaking. You can check this without leaving the row: of the 11 shared commits counted here, the most recent 3 are `b5aaf8c2` Split module enumeration from source DBs; `7ecb606d` Split live/incremental source DB methods; `d5331bb3` Avoid per-origin `shape_extensions` misses — run `git show` on any of them.
Change coupling: call_graph.rs ↔ override_graph.rs pyrefly/lib/report/pysa/call_graph.rs:1— `pyrefly/lib/report/pysa/call_graph.rs` and `pyrefly/lib/report/pysa/override_graph.rs` change together 70% of the time (7 of the 10 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well, and counted over this repository's 10,000 most recent commits rather than its whole history — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets) with no explicit dependency between them. They sit in the same directory, but in this ecosystem each file is its own module — a sibling reference still needs an import — so the missing import edge is real: the coupling runs through shared behaviour, not a declared dependency. If they duplicate structure, extract the common part into one unit; otherwise the coupling is hidden and worth breaking. You can check this without leaving the row: of the 7 shared commits counted here, the most recent 3 are `d3abc3d9` Borrow read-only solver helper inputs; `2ef9d847` Remove override graph building in pyrefly; `4f7937c3` Back out "Revert D93807796: [pyrefly] add opt-in telemetry to ad_hoc_… — run `git show` on any of them.
Change coupling: type_table.rs ↔ convert.rs pyrefly/lib/query/type_table.rs:1— `pyrefly/lib/query/type_table.rs` and `pyrefly/lib/report/cinderx/convert.rs` change together 64% of the time (18 of the 28 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well, and counted over this repository's 10,000 most recent commits rather than its whole history — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets) with no explicit dependency — the edge is real but nothing declares it. Read the pair before acting: if one registers itself into the other through a hook or an initialiser, the missing dependency is DELIBERATE — the registration is the link, and it is meant not to be an import — and the thing to add is a comment on each side naming the other, not a merge; if they simply belong together, co-locate them; if neither holds, the coupling is hidden and worth breaking. You can check this without leaving the row: of the 18 shared commits counted here, the most recent 3 are `419b9e66` Remove duplicates of TypeVarLike methods; `13e8d458` Delete the disconnected ShapedArray type representation; `47026780` Delete the unused legacy NNModule carrier — run `git show` on any of them.
Change coupling: type_table.rs ↔ type_conversion.rs pyrefly/lib/query/type_table.rs:1— `pyrefly/lib/query/type_table.rs` and `pyrefly/lib/tsp/type_conversion.rs` change together 54% of the time (15 of the 28 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well, and counted over this repository's 10,000 most recent commits rather than its whole history — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets) with no explicit dependency — the edge is real but nothing declares it. Read the pair before acting: if one registers itself into the other through a hook or an initialiser, the missing dependency is DELIBERATE — the registration is the link, and it is meant not to be an import — and the thing to add is a comment on each side naming the other, not a merge; if they simply belong together, co-locate them; if neither holds, the coupling is hidden and worth breaking. You can check this without leaving the row: of the 15 shared commits counted here, the most recent 3 are `419b9e66` Remove duplicates of TypeVarLike methods; `13e8d458` Delete the disconnected ShapedArray type representation; `47026780` Delete the unused legacy NNModule carrier — run `git show` on any of them.
Change coupling: solve.rs ↔ ide.rs pyrefly/lib/alt/solve.rs:1— `pyrefly/lib/alt/solve.rs` and `pyrefly/lib/state/ide.rs` change together 52% of the time (21 of the 40 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well, and counted over this repository's 10,000 most recent commits rather than its whole history — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets) with no explicit dependency — the edge is real but nothing declares it. Read the pair before acting: if one registers itself into the other through a hook or an initialiser, the missing dependency is DELIBERATE — the registration is the link, and it is meant not to be an import — and the thing to add is a comment on each side naming the other, not a merge; if they simply belong together, co-locate them; if neither holds, the coupling is hidden and worth breaking. You can check this without leaving the row: of the 21 shared commits counted here, the most recent 3 are `10fba794` fix False negative: Pyrefly does not emit an unpacking error in for k…; `c0ac8823` Compact binding storage; `d461a1ce` Detect illegal legacy type parameter shadowing — run `git show` on any of them.
Change coupling: hover.rs ↔ provide_type.rs pyrefly/lib/lsp/wasm/hover.rs:1— `pyrefly/lib/lsp/wasm/hover.rs` and `pyrefly/lib/lsp/wasm/provide_type.rs` change together 50% of the time (5 of the 10 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well, and counted over this repository's 10,000 most recent commits rather than its whole history — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets) with no explicit dependency between them. They sit in the same directory, but in this ecosystem each file is its own module — a sibling reference still needs an import — so the missing import edge is real: the coupling runs through shared behaviour, not a declared dependency. If they duplicate structure, extract the common part into one unit; otherwise the coupling is hidden and worth breaking. You can check this without leaving the row: of the 5 shared commits counted here, the most recent 3 are `bb937314` Delete the now-equivalent display read accessors; `e37d1c3a` preserve residuals in user-facing type display; `787e442c` provide type: fixes and features (#2971) — run `git show` on any of them.
D4 · Code Duplication· Edited copy of a member (13 corresponding lines) · ×7
Edited copy of a member (13 corresponding lines) pyrefly/lib/export/definitions.rs:394— pyrefly/lib/export/definitions.rs:394-410 | pyrefly/lib/export/deprecation.rs:17-29 — These two members are one piece of code written twice and then edited apart: 13 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (13 corresponding lines) pyrefly/lib/stubgen/extract.rs:610— pyrefly/lib/stubgen/extract.rs:610-622 | pyrefly/lib/stubgen/extract.rs:628-640 — These two members are one piece of code written twice and then edited apart: 13 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (13 corresponding lines) pyrefly/lib/report/pysa/types.rs:529— pyrefly/lib/report/pysa/types.rs:529-543 | pyrefly/lib/report/pysa/types.rs:545-557 — These two members are one piece of code written twice and then edited apart: 13 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (13 corresponding lines) pyrefly/lib/tsp/type_conversion.rs:1039— pyrefly/lib/tsp/type_conversion.rs:1039-1051 | pyrefly/lib/tsp/type_conversion.rs:1054-1066 — These two members are one piece of code written twice and then edited apart: 13 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (13 corresponding lines) pyrefly/lib/alt/class/attrs.rs:69— pyrefly/lib/alt/class/attrs.rs:69-81 | pyrefly/lib/alt/class/attrs.rs:86-98 — These two members are one piece of code written twice and then edited apart: 13 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (13 corresponding lines) crates/pyrefly_util/src/ruff_visitors.rs:44— crates/pyrefly_util/src/ruff_visitors.rs:44-56 | crates/pyrefly_util/src/ruff_visitors.rs:61-73 — These two members are one piece of code written twice and then edited apart: 13 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (13 corresponding lines) tensor-shapes/pyrefly-torch-stubs/examples/background_matting.py:169— tensor-shapes/pyrefly-torch-stubs/examples/background_matting.py:169-181 | tensor-shapes/pyrefly-torch-stubs/examples/background_matting.py:207-221 — These two members are one piece of code written twice and then edited apart: 13 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (14 corresponding lines) · ×7
Edited copy of a member (14 corresponding lines) pyrefly/lib/alt/class/typed_dict.rs:876— pyrefly/lib/alt/class/typed_dict.rs:876-889 | pyrefly/lib/alt/class/typed_dict.rs:896-909 — These two members are one piece of code written twice and then edited apart: 14 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (14 corresponding lines) crates/pyrefly_lsp_test/src/object_model.rs:861— crates/pyrefly_lsp_test/src/object_model.rs:861-878 | crates/pyrefly_lsp_test/src/object_model.rs:884-897 — These two members are one piece of code written twice and then edited apart: 14 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (14 corresponding lines) crates/pyrefly_types/src/types.rs:1440— crates/pyrefly_types/src/types.rs:1440-1464 | crates/pyrefly_types/src/types.rs:1467-1480 — These two members are one piece of code written twice and then edited apart: 14 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (14 corresponding lines) pyrefly/lib/alt/narrow.rs:973— pyrefly/lib/alt/narrow.rs:973-989 | pyrefly/lib/alt/narrow.rs:1021-1034 — These two members are one piece of code written twice and then edited apart: 14 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (14 corresponding lines) pyrefly/lib/alt/int_list_literal.rs:26— pyrefly/lib/alt/int_list_literal.rs:26-39 | pyrefly/lib/alt/regular_nested_list.rs:40-54 — These two members are one piece of code written twice and then edited apart: 14 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (14 corresponding lines) tensor-shapes/pyrefly-torch-stubs/examples/dlrm.py:428— tensor-shapes/pyrefly-torch-stubs/examples/dlrm.py:428-445 | tensor-shapes/pyrefly-torch-stubs/examples/dlrm.py:449-462 — These two members are one piece of code written twice and then edited apart: 14 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (14 corresponding lines) tensor-shapes/pyrefly-torch-stubs/examples/unet.py:196— tensor-shapes/pyrefly-torch-stubs/examples/unet.py:196-209 | tensor-shapes/pyrefly-torch-stubs/examples/unet.py:256-269 — These two members are one piece of code written twice and then edited apart: 14 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Duplicated block (16 lines × 2) pyrefly/lib/alt/function.rs:1598— pyrefly/lib/alt/function.rs:1598-1613 | pyrefly/lib/alt/function.rs:1632-1647 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/alt/function.rs:1598` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (16 lines × 2) pyrefly/lib/binding/narrow.rs:954— pyrefly/lib/binding/narrow.rs:954-969 | pyrefly/lib/binding/narrow.rs:987-1002 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/binding/narrow.rs:954` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (16 lines × 2) pyrefly/lib/state/lsp.rs:2286— pyrefly/lib/state/lsp.rs:2286-2301 | pyrefly/lib/state/lsp.rs:2317-2332 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/state/lsp.rs:2286` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (16 lines × 2) pyrefly/lib/binding/class.rs:1340— pyrefly/lib/binding/class.rs:1340-1355 | pyrefly/lib/binding/class.rs:1614-1630 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/binding/class.rs:1340` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (16 lines × 2) pyrefly/lib/alt/special_calls.rs:117— pyrefly/lib/alt/special_calls.rs:117-132 | pyrefly/lib/alt/special_calls.rs:280-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. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/alt/special_calls.rs:117` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (16 lines × 2) pyrefly/lib/state/lsp/quick_fixes/change_signature.rs:155— pyrefly/lib/state/lsp/quick_fixes/change_signature.rs:155-170 | pyrefly/lib/state/lsp/quick_fixes/change_signature.rs:176-191 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/state/lsp/quick_fixes/change_signature.rs:155` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (16 lines × 2) pyrefly/lib/state/lsp/quick_fixes/change_signature.rs:134— pyrefly/lib/state/lsp/quick_fixes/change_signature.rs:134-149 | pyrefly/lib/state/lsp/quick_fixes/change_signature.rs:155-170 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/state/lsp/quick_fixes/change_signature.rs:134` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication· Edited copies of one member (3 members, 5+ corresponding lines) · ×7
Edited copies of one member (3 members, 5+ corresponding lines) tensor-shapes/pyrefly-torch-stubs/examples/background_matting.py:533— tensor-shapes/pyrefly-torch-stubs/examples/background_matting.py:533-538 | tensor-shapes/pyrefly-torch-stubs/examples/dcgan.py:291-300 | tensor-shapes/pyrefly-torch-stubs/examples/openpose.py:477-481 — 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.
Edited copies of one member (3 members, 5+ corresponding lines) tensor-shapes/pyrefly-torch-stubs/examples/sam.py:1319— tensor-shapes/pyrefly-torch-stubs/examples/sam.py:1319-1326 | tensor-shapes/pyrefly-torch-stubs/examples/sam.py:1354-1358 | tensor-shapes/pyrefly-torch-stubs/examples/sam.py:1362-1376 — 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.
Edited copies of one member (3 members, 5+ corresponding lines) tensor-shapes/pyrefly-torch-stubs/examples/demucs.py:539— tensor-shapes/pyrefly-torch-stubs/examples/demucs.py:539-547 | tensor-shapes/pyrefly-torch-stubs/examples/mixtral_moe.py:479-483 | tensor-shapes/pyrefly-torch-stubs/examples/speech_transformer.py:504-509 — 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.
Edited copies of one member (3 members, 5+ corresponding lines) tensor-shapes/pyrefly-torch-stubs/examples/sam.py:1338— tensor-shapes/pyrefly-torch-stubs/examples/sam.py:1338-1342 | tensor-shapes/pyrefly-torch-stubs/examples/sam.py:1424-1429 | tensor-shapes/pyrefly-torch-stubs/examples/unet.py:314-318 — 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.
Edited copies of one member (3 members, 5+ corresponding lines) tensor-shapes/pyrefly-torch-stubs/examples/dcgan.py:161— tensor-shapes/pyrefly-torch-stubs/examples/dcgan.py:161-165 | tensor-shapes/pyrefly-torch-stubs/examples/dcgan.py:248-252 | tensor-shapes/pyrefly-torch-stubs/examples/resnet.py:231-237 — 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.
Edited copies of one member (3 members, 5+ corresponding lines) tensor-shapes/pyrefly-torch-stubs/examples/speech_transformer.py:527— tensor-shapes/pyrefly-torch-stubs/examples/speech_transformer.py:527-531 | tensor-shapes/pyrefly-torch-stubs/examples/tacotron2.py:640-644 | tensor-shapes/pyrefly-torch-stubs/examples/tts_angular.py:384-388 — 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.
Edited copies of one member (3 members, 5+ corresponding lines) tensor-shapes/pyrefly-torch-stubs/examples/dlrm.py:401— tensor-shapes/pyrefly-torch-stubs/examples/dlrm.py:401-405 | tensor-shapes/pyrefly-torch-stubs/examples/soft_actor_critic.py:459-463 | tensor-shapes/pyrefly-torch-stubs/examples/tacotron2.py:648-652 — 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 (22 corresponding lines) · ×6
Edited copy of a member (22 corresponding lines) pyrefly/lib/lsp/non_wasm/server.rs:5080— pyrefly/lib/lsp/non_wasm/server.rs:5080-5101 | pyrefly/lib/lsp/non_wasm/server.rs:5107-5130 — 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) pyrefly/lib/state/lsp.rs:2034— pyrefly/lib/state/lsp.rs:2034-2055 | pyrefly/lib/state/lsp.rs:5768-5792 — 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) crates/pyrefly_types/src/simplify.rs:612— crates/pyrefly_types/src/simplify.rs:612-633 | pyrefly/lib/alt/class/variance_inference.rs:321-342 — 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) pyrefly/lib/report/pysa/call_graph.rs:3712— pyrefly/lib/report/pysa/call_graph.rs:3712-3733 | pyrefly/lib/report/pysa/call_graph.rs:4158-4185 — 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) pyrefly/lib/state/lsp.rs:2895— pyrefly/lib/state/lsp.rs:2895-2916 | pyrefly/lib/state/lsp/extra_extensions.rs:80-101 — 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) tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:470— tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:470-491 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations.py:473-494 — These two members are one piece of code written twice and then edited apart: 22 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (18 corresponding lines) · ×6
Edited copy of a member (18 corresponding lines) pyrefly/lib/alt/class/dataclass.rs:1525— pyrefly/lib/alt/class/dataclass.rs:1525-1547 | pyrefly/lib/alt/class/dataclass.rs:1549-1566 — These two members are one piece of code written twice and then edited apart: 18 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (18 corresponding lines) pyrefly/lib/state/lsp/quick_fixes/change_signature.rs:196— pyrefly/lib/state/lsp/quick_fixes/change_signature.rs:196-213 | pyrefly/lib/state/lsp/quick_fixes/introduce_parameter.rs:192-212 — These two members are one piece of code written twice and then edited apart: 18 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (18 corresponding lines) pyrefly/lib/lsp/non_wasm/connection.rs:109— pyrefly/lib/lsp/non_wasm/connection.rs:109-126 | pyrefly/lib/lsp/non_wasm/connection.rs:131-148 — These two members are one piece of code written twice and then edited apart: 18 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (18 corresponding lines) pyrefly/lib/report/pysa/call_graph.rs:3419— pyrefly/lib/report/pysa/call_graph.rs:3419-3438 | pyrefly/lib/report/pysa/call_graph.rs:4218-4235 — These two members are one piece of code written twice and then edited apart: 18 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (18 corresponding lines) tensor-shapes/pyrefly-torch-stubs/examples/background_matting.py:422— tensor-shapes/pyrefly-torch-stubs/examples/background_matting.py:422-441 | tensor-shapes/pyrefly-torch-stubs/examples/stargan.py:169-186 — These two members are one piece of code written twice and then edited apart: 18 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (18 corresponding lines) tensor-shapes/pyrefly-torch-stubs/examples/tts_angular.py:227— tensor-shapes/pyrefly-torch-stubs/examples/tts_angular.py:227-245 | tensor-shapes/pyrefly-torch-stubs/examples/tts_angular.py:265-282 — These two members are one piece of code written twice and then edited apart: 18 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (12 corresponding lines) · ×6
Edited copy of a member (12 corresponding lines) pyrefly/lib/binding/expr.rs:756— pyrefly/lib/binding/expr.rs:756-767 | pyrefly/lib/binding/expr.rs:769-783 — These two members are one piece of code written twice and then edited apart: 12 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (12 corresponding lines) crates/pyrefly_types/src/map_int_tuples.rs:178— crates/pyrefly_types/src/map_int_tuples.rs:178-193 | crates/pyrefly_types/src/map_int_tuples.rs:200-211 — These two members are one piece of code written twice and then edited apart: 12 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (12 corresponding lines) pyrefly/lib/alt/answers_solver.rs:452— pyrefly/lib/alt/answers_solver.rs:452-463 | pyrefly/lib/alt/answers_solver.rs:465-476 — These two members are one piece of code written twice and then edited apart: 12 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (12 corresponding lines) pyrefly/lib/alt/answers_solver.rs:345— pyrefly/lib/alt/answers_solver.rs:345-356 | pyrefly/lib/alt/answers_solver.rs:362-374 — These two members are one piece of code written twice and then edited apart: 12 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (12 corresponding lines) pyrefly/lib/state/lsp/quick_fixes/inline_variable.rs:154— pyrefly/lib/state/lsp/quick_fixes/inline_variable.rs:154-165 | pyrefly/lib/state/lsp/quick_fixes/inline_variable.rs:167-179 — These two members are one piece of code written twice and then edited apart: 12 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (12 corresponding lines) tensor-shapes/pyrefly-torch-stubs/examples/sam.py:132— tensor-shapes/pyrefly-torch-stubs/examples/sam.py:132-149 | tensor-shapes/pyrefly-torch-stubs/examples/sam.py:165-176 — These two members are one piece of code written twice and then edited apart: 12 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (8 corresponding lines) · ×6
Edited copy of a member (8 corresponding lines) pyrefly/lib/commands/check.rs:958— pyrefly/lib/commands/check.rs:958-965 | pyrefly/lib/commands/check.rs:1260-1267 — These two members are one piece of code written twice and then edited apart: 8 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (8 corresponding lines) pyrefly/lib/state/lsp/quick_fixes/convert_star_import.rs:169— pyrefly/lib/state/lsp/quick_fixes/convert_star_import.rs:169-176 | pyrefly/lib/state/lsp/quick_fixes/extract_shared.rs:531-538 — These two members are one piece of code written twice and then edited apart: 8 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (8 corresponding lines) pyrefly/lib/solver/solver.rs:433— pyrefly/lib/solver/solver.rs:433-440 | pyrefly/lib/solver/solver.rs:442-449 — These two members are one piece of code written twice and then edited apart: 8 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (8 corresponding lines) pyrefly/lib/lsp/non_wasm/type_hierarchy.rs:49— pyrefly/lib/lsp/non_wasm/type_hierarchy.rs:49-56 | pyrefly/lib/state/lsp/quick_fixes/move_members.rs:240-247 — These two members are one piece of code written twice and then edited apart: 8 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (8 corresponding lines) crates/pyrefly_types/src/type_var.rs:233— crates/pyrefly_types/src/type_var.rs:233-242 | crates/pyrefly_types/src/type_var_tuple.rs:85-92 — These two members are one piece of code written twice and then edited apart: 8 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (8 corresponding lines) tensor-shapes/pyrefly-torch-stubs/examples/soft_actor_critic.py:398— tensor-shapes/pyrefly-torch-stubs/examples/soft_actor_critic.py:398-408 | tensor-shapes/pyrefly-torch-stubs/examples/super_slomo.py:216-223 — These two members are one piece of code written twice and then edited apart: 8 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Duplicated block (9 lines × 3) pyrefly/lib/lsp/non_wasm/convert_module_package.rs:37— pyrefly/lib/lsp/non_wasm/convert_module_package.rs:37-45 | pyrefly/lib/lsp/non_wasm/move_symbol_new_file.rs:54-62 | pyrefly/lib/lsp/non_wasm/safe_delete_file.rs:62-70 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
Duplicated block (9 lines × 3) pyrefly/lib/stubgen/extract.rs:345— pyrefly/lib/stubgen/extract.rs:345-353 | pyrefly/lib/stubgen/extract.rs:364-372 | pyrefly/lib/stubgen/extract.rs:393-401 — 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 `pyrefly/lib/stubgen/extract.rs:345` it begins part-way through the construct above it, so those exact lines 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) pyrefly/lib/lsp/module_helpers.rs:41— pyrefly/lib/lsp/module_helpers.rs:41-49 | pyrefly/lib/lsp/module_helpers.rs:53-61 | pyrefly/lib/lsp/module_helpers.rs:65-76 — 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 `pyrefly/lib/lsp/module_helpers.rs:41` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9 lines × 3) tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:565— tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:565-573 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations.py:568-576 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var.py:572-580 — before extracting anything, compare `tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py` and `tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations.py` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 247 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (9 lines × 3) tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:213— tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:213-221 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations.py:213-221 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var.py:210-218 — before extracting anything, compare `tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py` and `tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 392 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (9 lines × 3) tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:198— tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:198-206 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations.py:198-206 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var.py:195-203 — before extracting anything, compare `tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py` and `tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 392 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (8 lines × 3) crates/pyrefly_lsp_test/src/object_model.rs:711— crates/pyrefly_lsp_test/src/object_model.rs:711-718 | crates/pyrefly_lsp_test/src/object_model.rs:722-729 | crates/pyrefly_lsp_test/src/object_model.rs: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. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
Duplicated block (8 lines × 3) pyrefly/lib/alt/class/class_field.rs:3272— pyrefly/lib/alt/class/class_field.rs:3272-3279 | pyrefly/lib/alt/class/class_field.rs:3303-3310 | pyrefly/lib/alt/class/class_field.rs:3312-3319 — 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. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
Duplicated block (8 lines × 3) pyrefly/lib/lsp/non_wasm/convert_module_package.rs:24— pyrefly/lib/lsp/non_wasm/convert_module_package.rs:24-31 | pyrefly/lib/lsp/non_wasm/move_symbol_new_file.rs:41-48 | pyrefly/lib/lsp/non_wasm/safe_delete_file.rs:49-56 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once.
Duplicated block (8 lines × 3) pyrefly/lib/alt/polars_specials.rs:3287— pyrefly/lib/alt/polars_specials.rs:3287-3294 | pyrefly/lib/alt/polars_specials.rs:3320-3327 | pyrefly/lib/alt/polars_specials.rs:3352-3359 — 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 `pyrefly/lib/alt/polars_specials.rs:3287` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `pyrefly/lib/alt/polars_specials.rs:3295` calls `chain`, `get`, `unwrap_or` and `pyrefly/lib/alt/polars_specials.rs:3328` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (8 lines × 3) pyrefly/lib/alt/narrow.rs:2389— pyrefly/lib/alt/narrow.rs:2389-2396 | pyrefly/lib/alt/narrow.rs:2417-2424 | pyrefly/lib/alt/narrow.rs:2449-2456 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (8 lines × 3) tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:347— tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:347-354 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations.py:350-357 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var.py:363-370 — before extracting anything, compare `tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py` and `tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations.py` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 247 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (6 lines × 3) crates/pyrefly_config/src/args.rs:582— crates/pyrefly_config/src/args.rs:582-587 | crates/pyrefly_config/src/args.rs:589-594 | crates/pyrefly_config/src/args.rs:596-601 — 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 `crates/pyrefly_config/src/args.rs:582` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (6 lines × 3) crates/pyrefly_types/src/type_level_dsl.rs:2850— crates/pyrefly_types/src/type_level_dsl.rs:2850-2855 | crates/pyrefly_types/src/type_level_dsl.rs:3624-3629 | crates/pyrefly_types/src/type_level_dsl.rs:4795-4800 — 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 `crates/pyrefly_types/src/type_level_dsl.rs:2850` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (6 lines × 3) crates/pyrefly_types/src/type_level_dsl.rs:7106— crates/pyrefly_types/src/type_level_dsl.rs:7106-7111 | crates/pyrefly_types/src/type_level_dsl.rs:7781-7786 | crates/pyrefly_types/src/type_level_dsl.rs:7812-7817 — 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 `crates/pyrefly_types/src/type_level_dsl.rs:7106` it does not close everything it opens, so those exact lines 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) pyrefly/lib/alt/attr.rs:2213— pyrefly/lib/alt/attr.rs:2213-2219 | pyrefly/lib/alt/attr.rs:2248-2253 | pyrefly/lib/alt/attr.rs:2335-2341 — 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 `pyrefly/lib/alt/attr.rs:2213` it begins part-way through the construct above it, so those exact lines 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) pyrefly/lib/module/third_party.rs:105— pyrefly/lib/module/third_party.rs:105-110 | pyrefly/lib/module/typeshed.rs:353-358 | pyrefly/lib/module/typeshed_third_party.rs:106-111 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once.
Duplicated block (6 lines × 3) tensor-shapes/pyrefly-torch-stubs/examples/openpose.py:82— tensor-shapes/pyrefly-torch-stubs/examples/openpose.py:82-87 | tensor-shapes/pyrefly-torch-stubs/examples/openpose.py:265-270 | tensor-shapes/pyrefly-torch-stubs/examples/openpose.py:355-360 — 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 `tensor-shapes/pyrefly-torch-stubs/examples/openpose.py:82` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Server::process_event (cyclomatic 136) pyrefly/lib/lsp/non_wasm/server.rs:2099— Server::process_event has cyclomatic complexity 136 (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.
Server::code_action (cyclomatic 42) pyrefly/lib/lsp/non_wasm/server.rs:5268— Server::code_action has cyclomatic complexity 42 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Server::notebook_document_did_change (cyclomatic 23) pyrefly/lib/lsp/non_wasm/server.rs:4457— Server::notebook_document_did_change 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.
Server::publish_for_handles (cyclomatic 16) pyrefly/lib/lsp/non_wasm/server.rs:3532— Server::publish_for_handles has cyclomatic complexity 16 (threshold 15). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
Server::prune_baselines (cyclomatic 16) pyrefly/lib/lsp/non_wasm/server.rs:4079— Server::prune_baselines 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.
Solver::finish_quantified_with_captures (cognitive 76) pyrefly/lib/solver/solver.rs:2233— Solver::finish_quantified_with_captures has cognitive complexity 76 (threshold 15). Drivers by points: if/else 22 (46 pts), loops 9 (14 pts), match/switch 5 (10 pts), boolean chains 6 (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.
Solver::simplify_mut (cognitive 30) pyrefly/lib/solver/solver.rs:1277— Solver::simplify_mut has cognitive complexity 30 (threshold 15). Drivers by points: if/else 11 (16 pts), loops 2 (6 pts), match/switch 3 (6 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.
Solver::erase_unsolved_variables (cognitive 21) pyrefly/lib/solver/solver.rs:1376— Solver::erase_unsolved_variables has cognitive complexity 21 (threshold 15). Drivers by points: if/else 3 (9 pts), match/switch 3 (6 pts), loops 2 (5 pts), boolean chains 1 (nesting depth added 12). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
Solver::build_overload_rows (cognitive 16) pyrefly/lib/solver/solver.rs:1864— Solver::build_overload_rows has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (9 pts), loops 3 (6 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.
Solver::prune_one_argument (cognitive 16) pyrefly/lib/solver/solver.rs:2045— Solver::prune_one_argument has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (10 pts), boolean chains 3, match/switch 1 (2 pts), loops 1 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, 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.
pyrefly_python::folding::folding_ranges (cognitive 42) crates/pyrefly_python/src/folding.rs:30— pyrefly_python::folding::folding_ranges has cognitive complexity 42 (threshold 15). Drivers by points: if/else 15 (29 pts), loops 5 (8 pts), match/switch 3, boolean chains 2 (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.
pyrefly_python::docstring::parse_google_params (cognitive 30) crates/pyrefly_python/src/docstring.rs:603— pyrefly_python::docstring::parse_google_params has cognitive complexity 30 (threshold 15). Drivers by points: if/else 12 (26 pts), boolean chains 3, loops 1 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
pyrefly_python::docstring::parse_numpydoc_params (cognitive 27) crates/pyrefly_python/src/docstring.rs:711— pyrefly_python::docstring::parse_numpydoc_params has cognitive complexity 27 (threshold 15). Drivers by points: if/else 9 (19 pts), boolean chains 7, 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.
pyrefly_python::ignore::parse_ignore_all (cognitive 27) crates/pyrefly_python/src/ignore.rs:774— pyrefly_python::ignore::parse_ignore_all has cognitive complexity 27 (threshold 15). Drivers by points: if/else 10 (21 pts), boolean chains 5, loops 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
pyrefly_python::docstring::parse_sphinx_params (cognitive 23) crates/pyrefly_python/src/docstring.rs:513— pyrefly_python::docstring::parse_sphinx_params has cognitive complexity 23 (threshold 15). Drivers by points: if/else 8 (19 pts), match/switch 1 (3 pts), loops 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D4 · Code Duplication· Edited copy of a member (19 corresponding lines) · ×5
Edited copy of a member (19 corresponding lines) pyrefly/lib/alt/type_level_dsl.rs:1334— pyrefly/lib/alt/type_level_dsl.rs:1334-1355 | pyrefly/lib/alt/type_level_dsl.rs:1357-1375 — These two members are one piece of code written twice and then edited apart: 19 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (19 corresponding lines) pyrefly/lib/state/lsp.rs:4170— pyrefly/lib/state/lsp.rs:4170-4194 | pyrefly/lib/state/lsp.rs:4203-4221 — These two members are one piece of code written twice and then edited apart: 19 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (19 corresponding lines) pyrefly/lib/alt/unwrap.rs:444— pyrefly/lib/alt/unwrap.rs:444-466 | pyrefly/lib/alt/unwrap.rs:468-486 — These two members are one piece of code written twice and then edited apart: 19 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (19 corresponding lines) pyrefly/lib/lsp/non_wasm/server.rs:7667— pyrefly/lib/lsp/non_wasm/server.rs:7667-7698 | pyrefly/lib/lsp/non_wasm/server.rs:7707-7725 — These two members are one piece of code written twice and then edited apart: 19 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (19 corresponding lines) crates/tsp_types/protocol_generator/generate_protocol.py:681— crates/tsp_types/protocol_generator/generate_protocol.py:681-699 | crates/tsp_types/protocol_generator/generate_protocol.py:705-723 — These two members are one piece of code written twice and then edited apart: 19 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (15 corresponding lines) · ×5
Edited copy of a member (15 corresponding lines) pyrefly/lib/binding/narrow.rs:1008— pyrefly/lib/binding/narrow.rs:1008-1024 | pyrefly/lib/binding/narrow.rs:1030-1044 — These two members are one piece of code written twice and then edited apart: 15 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (15 corresponding lines) pyrefly/lib/alt/narrow.rs:1424— pyrefly/lib/alt/narrow.rs:1424-1438 | pyrefly/lib/alt/narrow.rs:1447-1464 — These two members are one piece of code written twice and then edited apart: 15 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (15 corresponding lines) pyrefly/lib/binding/bindings.rs:1020— pyrefly/lib/binding/bindings.rs:1020-1034 | pyrefly/lib/binding/bindings.rs:1044-1058 — These two members are one piece of code written twice and then edited apart: 15 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (15 corresponding lines) pyrefly/lib/binding/scope.rs:3070— pyrefly/lib/binding/scope.rs:3070-3084 | pyrefly/lib/binding/scope.rs:3091-3106 — These two members are one piece of code written twice and then edited apart: 15 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (15 corresponding lines) tensor-shapes/pyrefly-numpy-stubs/examples/stats.py:130— tensor-shapes/pyrefly-numpy-stubs/examples/stats.py:130-144 | tensor-shapes/pyrefly-numpy-stubs/examples/stats.py:148-164 — 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 (6 corresponding lines) · ×5
Edited copy of a member (6 corresponding lines) crates/pyrefly_util/src/suggest.rs:147— crates/pyrefly_util/src/suggest.rs:147-153 | pyrefly/lib/binding/scope.rs:449-454 — These two members are one piece of code written twice and then edited apart: 6 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (6 corresponding lines) pyrefly/lib/alt/class/class_field.rs:1484— pyrefly/lib/alt/class/class_field.rs:1484-1489 | pyrefly/lib/alt/narrow.rs:1390-1398 — These two members are one piece of code written twice and then edited apart: 6 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (6 corresponding lines) crates/pyrefly_util/src/small_map1.rs:63— crates/pyrefly_util/src/small_map1.rs:63-68 | crates/pyrefly_util/src/small_set1.rs:63-68 — These two members are one piece of code written twice and then edited apart: 6 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (6 corresponding lines) tensor-shapes/pyrefly-torch-stubs/examples/soft_actor_critic.py:467— tensor-shapes/pyrefly-torch-stubs/examples/soft_actor_critic.py:467-472 | tensor-shapes/pyrefly-torch-stubs/examples/soft_actor_critic.py:476-481 — These two members are one piece of code written twice and then edited apart: 6 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (6 corresponding lines) tensor-shapes/pyrefly-numpy-stubs/examples/physical_science.py:112— tensor-shapes/pyrefly-numpy-stubs/examples/physical_science.py:112-118 | tensor-shapes/pyrefly-numpy-stubs/examples/stats.py:74-79 — These two members are one piece of code written twice and then edited apart: 6 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Duplicated block (11–12 lines × 2) pyrefly/lib/alt/class/class_field.rs:1264— pyrefly/lib/alt/class/class_field.rs:1264-1275 | pyrefly/lib/alt/class/class_field.rs:1280-1290 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
Duplicated block (11–12 lines × 2) pyrefly/lib/lsp/non_wasm/server.rs:5185— pyrefly/lib/lsp/non_wasm/server.rs:5185-5195 | pyrefly/lib/lsp/non_wasm/server.rs:5794-5805 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/lsp/non_wasm/server.rs:5185` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (11–12 lines × 2) pyrefly/lib/state/lsp.rs:2671— pyrefly/lib/state/lsp.rs:2671-2682 | pyrefly/lib/state/lsp.rs:2688-2698 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/state/lsp.rs:2671` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (11–12 lines × 2) pyrefly/lib/state/lsp.rs:3887— pyrefly/lib/state/lsp.rs:3887-3897 | pyrefly/lib/state/lsp.rs:3899-3910 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/state/lsp.rs:3887` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (11–12 lines × 2) conformance/conformance_output.py:226— conformance/conformance_output.py:226-236 | conformance/conformance_output.py:266-277 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `conformance/conformance_output.py:226` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. 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.
StructurallyValidatedTypeShapeDslFunction::evaluate_expression (cyclomatic 278) crates/pyrefly_types/src/type_level_dsl.rs:6986— StructurallyValidatedTypeShapeDslFunction::evaluate_expression has cyclomatic complexity 278 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
StructurallyValidatedTypeShapeDslFunction::evaluate_condition (cyclomatic 105) crates/pyrefly_types/src/type_level_dsl.rs:8129— StructurallyValidatedTypeShapeDslFunction::evaluate_condition has cyclomatic complexity 105 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
StructurallyValidatedTypeShapeDslFunction::evaluate_generator (cyclomatic 37) crates/pyrefly_types/src/type_level_dsl.rs:6726— StructurallyValidatedTypeShapeDslFunction::evaluate_generator has cyclomatic complexity 37 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
StructurallyValidatedTypeShapeDslFunction::evaluate_any_generator (cyclomatic 24) crates/pyrefly_types/src/type_level_dsl.rs:7998— StructurallyValidatedTypeShapeDslFunction::evaluate_any_generator has cyclomatic complexity 24 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
pyrefly_python::folding::folding_ranges (cyclomatic 38) crates/pyrefly_python/src/folding.rs:30— pyrefly_python::folding::folding_ranges has cyclomatic complexity 38 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
pyrefly_python::docstring::parse_numpydoc_params (cyclomatic 17) crates/pyrefly_python/src/docstring.rs:711— pyrefly_python::docstring::parse_numpydoc_params 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.
pyrefly_python::ignore::parse_ignore_all (cyclomatic 17) crates/pyrefly_python/src/ignore.rs:774— pyrefly_python::ignore::parse_ignore_all 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.
pyrefly_python::docstring::parse_google_params (cyclomatic 16) crates/pyrefly_python/src/docstring.rs:603— pyrefly_python::docstring::parse_google_params 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.
HackComment pyrefly/lib/alt/call.rs:2138— // hack — a workaround marked in source: record what it is compensating for and what would allow its removal (the upstream fix, the API it is waiting on, the invariant it restores), so the next reader can judge whether it is still needed rather than rediscovering why it is there.
HackComment pyrefly/lib/alt/callable.rs:312— // Hack: keep mutable builtin containers as expressions, since they often need to be — a workaround marked in source: record what it is compensating for and what would allow its removal (the upstream fix, the API it is waiting on, the invariant it restores), so the next reader can judge whether it is still needed rather than rediscovering why it is there.
HackComment pyrefly/lib/alt/callable.rs:2637— // hack: we inserted a class type into the args list, but we need to substitute it — a workaround marked in source: record what it is compensating for and what would allow its removal (the upstream fix, the API it is waiting on, the invariant it restores), so the next reader can judge whether it is still needed rather than rediscovering why it is there.
HackComment pyrefly/lib/alt/types/class_bases.rs:560— // HACK HACK HACK - TypedDict instances behave very differently from instances of other — a workaround marked in source: record what it is compensating for and what would allow its removal (the upstream fix, the API it is waiting on, the invariant it restores), so the next reader can judge whether it is still needed rather than rediscovering why it is there.
StructurallyValidatedTypeShapeDslFunction::evaluate_expression (cognitive 282) crates/pyrefly_types/src/type_level_dsl.rs:6986— StructurallyValidatedTypeShapeDslFunction::evaluate_expression has cognitive complexity 282 (threshold 15). Drivers by points: match/switch 67 (144 pts), if/else 60 (121 pts), loops 6 (12 pts), boolean chains 5 (nesting depth added 144). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
StructurallyValidatedTypeShapeDslFunction::evaluate_condition (cognitive 130) crates/pyrefly_types/src/type_level_dsl.rs:8129— StructurallyValidatedTypeShapeDslFunction::evaluate_condition has cognitive complexity 130 (threshold 15). Drivers by points: if/else 41 (78 pts), match/switch 21 (48 pts), boolean chains 2, loops 1 (2 pts) (nesting depth added 65). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
StructurallyValidatedTypeShapeDslFunction::evaluate_generator (cognitive 43) crates/pyrefly_types/src/type_level_dsl.rs:6726— StructurallyValidatedTypeShapeDslFunction::evaluate_generator has cognitive complexity 43 (threshold 15). Drivers by points: if/else 12 (20 pts), match/switch 10 (18 pts), loops 3 (4 pts), boolean chains 1 (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
StructurallyValidatedTypeShapeDslFunction::evaluate_any_generator (cognitive 31) crates/pyrefly_types/src/type_level_dsl.rs:7998— StructurallyValidatedTypeShapeDslFunction::evaluate_any_generator has cognitive complexity 31 (threshold 15). Drivers by points: match/switch 6 (15 pts), if/else 8 (12 pts), boolean chains 3, loops 1 (nesting depth added 13). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
pyrefly_build::module_resolver::find_one_part_prefix (cognitive 69) crates/pyrefly_build/src/module_resolver.rs:864— pyrefly_build::module_resolver::find_one_part_prefix has cognitive complexity 69 (threshold 15). Drivers by points: if/else 12 (49 pts), loops 4 (11 pts), match/switch 1 (6 pts), boolean chains 3 (nesting depth added 49). 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.
pyrefly_build::module_resolver::find_one_part_in_root (cognitive 46) crates/pyrefly_build/src/module_resolver.rs:411— pyrefly_build::module_resolver::find_one_part_in_root has cognitive complexity 46 (threshold 15). Drivers by points: if/else 19 (34 pts), loops 4 (6 pts), match/switch 1 (4 pts), boolean chains 2 (nesting depth added 20). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
pyrefly_build::module_resolver::find_module_prefixes (cognitive 19) crates/pyrefly_build/src/module_resolver.rs:936— pyrefly_build::module_resolver::find_module_prefixes has cognitive complexity 19 (threshold 15). Drivers by points: if/else 8 (14 pts), match/switch 1 (3 pts), loops 1 (2 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
pyrefly_build::module_resolver::find_one_part (cognitive 17) crates/pyrefly_build/src/module_resolver.rs:518— pyrefly_build::module_resolver::find_one_part has cognitive complexity 17 (threshold 15). Drivers by points: match/switch 5 (15 pts), if/else 1, loops 1 (nesting depth added 10). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D4 · Code Duplication· Edited copy of a member (27 corresponding lines) · ×4
Edited copy of a member (27 corresponding lines) pyrefly/lib/alt/expr.rs:2674— pyrefly/lib/alt/expr.rs:2674-2701 | pyrefly/lib/alt/expr.rs:2711-2737 — These two members are one piece of code written twice and then edited apart: 27 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (27 corresponding lines) pyrefly/lib/report/cinderx.rs:154— pyrefly/lib/report/cinderx.rs:154-180 | pyrefly/lib/report/cinderx.rs:182-212 — These two members are one piece of code written twice and then edited apart: 27 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (27 corresponding lines) pyrefly/lib/binding/narrow.rs:946— pyrefly/lib/binding/narrow.rs:946-973 | pyrefly/lib/binding/narrow.rs:980-1006 — These two members are one piece of code written twice and then edited apart: 27 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (27 corresponding lines) pyrefly/lib/alt/expr.rs:1837— pyrefly/lib/alt/expr.rs:1837-1866 | pyrefly/lib/alt/expr.rs:1875-1901 — These two members are one piece of code written twice and then edited apart: 27 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (25 corresponding lines) · ×4
Edited copy of a member (25 corresponding lines) pyrefly/lib/state/lsp/quick_fixes/convert_dict.rs:301— pyrefly/lib/state/lsp/quick_fixes/convert_dict.rs:301-325 | pyrefly/lib/state/lsp/quick_fixes/convert_dict.rs:335-359 — These two members are one piece of code written twice and then edited apart: 25 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (25 corresponding lines) crates/pyrefly_util/src/small_map1.rs:37— crates/pyrefly_util/src/small_map1.rs:37-61 | crates/pyrefly_util/src/small_set1.rs:37-61 — These two members are one piece of code written twice and then edited apart: 25 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (25 corresponding lines) pyrefly/lib/state/lsp/quick_fixes/extract_field.rs:172— pyrefly/lib/state/lsp/quick_fixes/extract_field.rs:172-197 | pyrefly/lib/state/lsp/quick_fixes/introduce_parameter.rs:296-320 — These two members are one piece of code written twice and then edited apart: 25 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (25 corresponding lines) pyrefly/lib/state/lsp.rs:2284— pyrefly/lib/state/lsp.rs:2284-2308 | pyrefly/lib/state/lsp.rs:2315-2339 — These two members are one piece of code written twice and then edited apart: 25 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (23 corresponding lines) · ×4
Edited copy of a member (23 corresponding lines) pyrefly/lib/alt/polars_specials.rs:3285— pyrefly/lib/alt/polars_specials.rs:3285-3311 | pyrefly/lib/alt/polars_specials.rs:3350-3372 — These two members are one piece of code written twice and then edited apart: 23 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (23 corresponding lines) pyrefly/lib/error/error.rs:300— pyrefly/lib/error/error.rs:300-323 | pyrefly/lib/error/error.rs:366-388 — These two members are one piece of code written twice and then edited apart: 23 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (23 corresponding lines) pyrefly/lib/alt/class/targs.rs:315— pyrefly/lib/alt/class/targs.rs:315-339 | pyrefly/lib/alt/class/targs.rs:341-363 — These two members are one piece of code written twice and then edited apart: 23 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (23 corresponding lines) crates/pyrefly_types/src/shape_index.rs:185— crates/pyrefly_types/src/shape_index.rs:185-207 | crates/pyrefly_types/src/shape_index.rs:337-360 — 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.
Duplicated block (12–13 lines × 2) pyrefly/lib/alt/class/class_field.rs:6385— pyrefly/lib/alt/class/class_field.rs:6385-6397 | pyrefly/lib/alt/class/class_field.rs:6590-6601 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/alt/class/class_field.rs:6385` it does not close everything it opens, so those exact lines 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) pyrefly/lib/alt/narrow.rs:671— pyrefly/lib/alt/narrow.rs:671-682 | pyrefly/lib/alt/narrow.rs:2152-2164 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/alt/narrow.rs:671` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (12–13 lines × 2) pyrefly/lib/lsp/non_wasm/server.rs:5777— pyrefly/lib/lsp/non_wasm/server.rs:5777-5789 | pyrefly/lib/lsp/non_wasm/server.rs:7034-7045 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/lsp/non_wasm/server.rs:5777` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12–13 lines × 2) pyrefly/lib/lsp/wasm/signature_help.rs:355— pyrefly/lib/lsp/wasm/signature_help.rs:355-367 | pyrefly/lib/lsp/wasm/signature_help.rs:379-390 — both copies are in the same file, so extract the 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 × 3) crates/pyrefly_lsp_test/src/object_model.rs:436— crates/pyrefly_lsp_test/src/object_model.rs:436-446 | crates/pyrefly_lsp_test/src/object_model.rs:454-464 | crates/pyrefly_lsp_test/src/object_model.rs:472-482 — 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. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
Duplicated block (11 lines × 3) pyrefly/lib/query/type_table.rs:289— pyrefly/lib/query/type_table.rs:289-299 | pyrefly/lib/query/type_table.rs:450-460 | pyrefly/lib/query/type_table.rs:508-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 `pyrefly/lib/query/type_table.rs:289` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (11 lines × 3) pyrefly/lib/alt/polars_specials.rs:3296— pyrefly/lib/alt/polars_specials.rs:3296-3306 | pyrefly/lib/alt/polars_specials.rs:3328-3338 | pyrefly/lib/alt/polars_specials.rs:3360-3370 — 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 `pyrefly/lib/alt/polars_specials.rs:3296` it begins part-way through the construct above it, so those 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, `pyrefly/lib/alt/polars_specials.rs:3295` calls `chain`, `get`, `unwrap_or` and `pyrefly/lib/alt/polars_specials.rs:3327` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (11 lines × 3) tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:75— tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:75-85 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations.py:75-85 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var.py:76-86 — before extracting anything, compare `tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py` and `tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 392 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (7 lines × 3) pyrefly/lib/alt/map_int_tuples.rs:764— pyrefly/lib/alt/map_int_tuples.rs:764-770 | pyrefly/lib/alt/shape_extension.rs:324-330 | pyrefly/lib/alt/shape_extension.rs:347-353 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart.
Duplicated block (7 lines × 3) pyrefly/lib/report/cinderx/display.rs:25— pyrefly/lib/report/cinderx/display.rs:25-32 | pyrefly/lib/report/cinderx/display.rs:61-67 | pyrefly/lib/report/cinderx/display.rs:85-91 — 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 `pyrefly/lib/report/cinderx/display.rs:25` it begins part-way through the construct above it, so those exact lines 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) pyrefly/lib/state/lsp/quick_fixes/extract_field.rs:42— pyrefly/lib/state/lsp/quick_fixes/extract_field.rs:42-48 | pyrefly/lib/state/lsp/quick_fixes/extract_variable.rs:37-43 | pyrefly/lib/state/lsp/quick_fixes/introduce_parameter.rs:98-104 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `pyrefly/lib/state/lsp/quick_fixes/extract_field.rs:41` calls `contents` and `pyrefly/lib/state/lsp/quick_fixes/extract_variable.rs:36` 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) tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:187— tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:187-193 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations.py:187-193 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var.py:186-192 — before extracting anything, compare `tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py` and `tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 392 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.
SemanticTokenBuilder::process_stmt (cyclomatic 37) pyrefly/lib/state/semantic_tokens.rs:716— SemanticTokenBuilder::process_stmt 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.
SemanticTokenBuilder::process_syntax_tokens (cyclomatic 22) pyrefly/lib/state/semantic_tokens.rs:476— SemanticTokenBuilder::process_syntax_tokens has cyclomatic complexity 22 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
SemanticTokenBuilder::process_expr (cyclomatic 17) pyrefly/lib/state/semantic_tokens.rs:640— SemanticTokenBuilder::process_expr has cyclomatic complexity 17 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
Scopes::finish_class_and_get_field_definitions (cyclomatic 27) pyrefly/lib/binding/scope.rs:3806— Scopes::finish_class_and_get_field_definitions 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.
Scopes::look_up_name_for_read (cyclomatic 19) pyrefly/lib/binding/scope.rs:4219— Scopes::look_up_name_for_read 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.
Scopes::current_exported_function_impl (cyclomatic 18) pyrefly/lib/report/pysa/ast_visitor.rs:117— Scopes::current_exported_function_impl has cyclomatic complexity 18 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
MemberRenderer::params (cyclomatic 19) pyrefly/lib/state/lsp/quick_fixes/implement_abstract_members.rs:441— MemberRenderer::params 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.
MemberRenderer::signature (cyclomatic 17) pyrefly/lib/state/lsp/quick_fixes/implement_abstract_members.rs:356— MemberRenderer::signature has cyclomatic complexity 17 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
MemberRenderer::member (cyclomatic 16) pyrefly/lib/state/lsp/quick_fixes/implement_abstract_members.rs:232— MemberRenderer::member 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.
TypeDisplayContext::fmt_helper_generic (cognitive 227) crates/pyrefly_types/src/display.rs:954— TypeDisplayContext::fmt_helper_generic has cognitive complexity 227 (threshold 15). Drivers by points: if/else 65 (158 pts), match/switch 16 (31 pts), loops 9 (24 pts), boolean chains 14 (nesting depth added 123). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
TypeDisplayContext::fmt_params_hover (cognitive 45) crates/pyrefly_types/src/display.rs:662— TypeDisplayContext::fmt_params_hover has cognitive complexity 45 (threshold 15). Drivers by points: if/else 13 (26 pts), loops 4 (12 pts), match/switch 3 (6 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.
TypeDisplayContext::fmt_shape_as_tuple_carrier (cognitive 20) crates/pyrefly_types/src/display.rs:452— TypeDisplayContext::fmt_shape_as_tuple_carrier has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (14 pts), loops 2 (4 pts), boolean chains 1, match/switch 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.
SemanticTokenBuilder::process_stmt (cognitive 71) pyrefly/lib/state/semantic_tokens.rs:716— SemanticTokenBuilder::process_stmt has cognitive complexity 71 (threshold 15). Drivers by points: if/else 19 (49 pts), loops 9 (21 pts), match/switch 1 (nesting depth added 42). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
SemanticTokenBuilder::process_syntax_tokens (cognitive 48) pyrefly/lib/state/semantic_tokens.rs:476— SemanticTokenBuilder::process_syntax_tokens has cognitive complexity 48 (threshold 15). Drivers by points: if/else 14 (36 pts), match/switch 3 (6 pts), loops 3 (5 pts), boolean chains 1 (nesting depth added 27). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SemanticTokenBuilder::process_expr (cognitive 19) pyrefly/lib/state/semantic_tokens.rs:640— SemanticTokenBuilder::process_expr has cognitive complexity 19 (threshold 15). Drivers by points: if/else 4 (8 pts), loops 4 (8 pts), match/switch 2 (3 pts) (nesting depth added 9). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
Scopes::finish_class_and_get_field_definitions (cognitive 39) pyrefly/lib/binding/scope.rs:3806— Scopes::finish_class_and_get_field_definitions has cognitive complexity 39 (threshold 15). Drivers by points: if/else 17 (29 pts), match/switch 3 (7 pts), boolean chains 3 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Scopes::look_up_name_for_read (cognitive 26) pyrefly/lib/binding/scope.rs:4219— Scopes::look_up_name_for_read has cognitive complexity 26 (threshold 15). Drivers by points: if/else 10 (16 pts), boolean chains 7, match/switch 2 (3 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Scopes::record_or_reject_return (cognitive 25) pyrefly/lib/binding/scope.rs:3678— Scopes::record_or_reject_return has cognitive complexity 25 (threshold 15). Drivers by points: if/else 3 (13 pts), loops 2 (6 pts), match/switch 2 (6 pts) (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ConfigFile::configure_at (cognitive 32) crates/pyrefly_config/src/config.rs:1808— ConfigFile::configure_at has cognitive complexity 32 (threshold 15). Drivers by points: if/else 20 (24 pts), match/switch 3 (4 pts), boolean chains 3, loops 1 (nesting depth added 5). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
ConfigFile::from_file::f (cognitive 21) crates/pyrefly_config/src/config.rs:2077— ConfigFile::from_file::f has cognitive complexity 21 (threshold 15). Drivers by points: if/else 10 (14 pts), match/switch 3 (4 pts), boolean chains 2, loops 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ConfigFile::query_source_db (cognitive 19) crates/pyrefly_config/src/config.rs:1699— ConfigFile::query_source_db has cognitive complexity 19 (threshold 15). Drivers by points: if/else 5 (9 pts), loops 4 (8 pts), match/switch 1 (2 pts) (nesting depth added 9). Of this number, 18 points are the body's own statements and 1 belongs to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
MemberRenderer::signature (cognitive 27) pyrefly/lib/state/lsp/quick_fixes/implement_abstract_members.rs:356— MemberRenderer::signature has cognitive complexity 27 (threshold 15). Drivers by points: if/else 5 (11 pts), loops 2 (6 pts), match/switch 3 (6 pts), boolean chains 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.
MemberRenderer::member (cognitive 26) pyrefly/lib/state/lsp/quick_fixes/implement_abstract_members.rs:232— MemberRenderer::member has cognitive complexity 26 (threshold 15). Drivers by points: if/else 18 (25 pts), loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
MemberRenderer::params (cognitive 26) pyrefly/lib/state/lsp/quick_fixes/implement_abstract_members.rs:441— MemberRenderer::params has cognitive complexity 26 (threshold 15). Drivers by points: if/else 11 (17 pts), match/switch 2 (6 pts), boolean chains 2, loops 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D30 · Dependency Vulnerabilities· Medium advisory (unmaintained) · ×3
D4 · Code Duplication· Edited copy of a member (36 corresponding lines) · ×3
Edited copy of a member (36 corresponding lines) pyrefly/lib/report/pysa/capnp_writer.rs:772— pyrefly/lib/report/pysa/capnp_writer.rs:772-810 | pyrefly/lib/report/pysa/capnp_writer.rs:816-851 — 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) pyrefly/lib/lsp/non_wasm/server.rs:7124— pyrefly/lib/lsp/non_wasm/server.rs:7124-7165 | pyrefly/lib/lsp/non_wasm/server.rs:7281-7316 — 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) conformance/conformance_output.py:206— conformance/conformance_output.py:206-241 | conformance/conformance_output.py:247-285 — 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 (26 corresponding lines) · ×3
Edited copy of a member (26 corresponding lines) pyrefly/lib/state/state.rs:281— pyrefly/lib/state/state.rs:281-311 | pyrefly/lib/state/state.rs:414-439 — These two members are one piece of code written twice and then edited apart: 26 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (26 corresponding lines) crates/pyrefly_util/src/telemetry.rs:478— crates/pyrefly_util/src/telemetry.rs:478-508 | crates/pyrefly_util/src/telemetry.rs:516-541 — These two members are one piece of code written twice and then edited apart: 26 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (26 corresponding lines) crates/pyrefly_config/src/migration/mypy/pyproject.rs:310— crates/pyrefly_config/src/migration/mypy/pyproject.rs:310-335 | crates/pyrefly_config/src/migration/pyright.rs:106-134 — These two members are one piece of code written twice and then edited apart: 26 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (20 corresponding lines) · ×3
Edited copy of a member (20 corresponding lines) pyrefly/lib/alt/polars_specials.rs:3262— pyrefly/lib/alt/polars_specials.rs:3262-3283 | pyrefly/lib/alt/polars_specials.rs:3380-3399 — These two members are one piece of code written twice and then edited apart: 20 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (20 corresponding lines) crates/pyrefly_lsp_test/src/object_model.rs:802— crates/pyrefly_lsp_test/src/object_model.rs:802-832 | crates/pyrefly_lsp_test/src/object_model.rs:1215-1234 — These two members are one piece of code written twice and then edited apart: 20 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (20 corresponding lines) pyrefly/lib/alt/class/class_field.rs:6839— pyrefly/lib/alt/class/class_field.rs:6839-6865 | pyrefly/lib/alt/class/class_field.rs:6875-6894 — These two members are one piece of code written twice and then edited apart: 20 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Duplicated block (20 lines × 2) crates/pyrefly_types/src/type_level_dsl.rs:4170— crates/pyrefly_types/src/type_level_dsl.rs:4170-4189 | crates/pyrefly_types/src/type_level_dsl.rs:4210-4229 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
Duplicated block (20 lines × 2) pyrefly/lib/commands/check.rs:1488— pyrefly/lib/commands/check.rs:1488-1507 | pyrefly/lib/lsp/non_wasm/type_error_display_status.rs:275-294 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (20 lines × 2) crates/tsp_types/protocol_generator/generate_protocol.py:613— crates/tsp_types/protocol_generator/generate_protocol.py:613-632 | crates/tsp_types/protocol_generator/generate_protocol.py:768-787 — both copies are in the same file, so extract the 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 (7–8 lines × 2) pyrefly/lib/alt/shape_extension.rs:221— pyrefly/lib/alt/shape_extension.rs:221-227 | pyrefly/lib/alt/shape_flag.rs:109-116 — 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 `pyrefly/lib/alt/shape_extension.rs:221` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7–8 lines × 2) pyrefly/lib/lsp/non_wasm/server/event_loop.rs:44— pyrefly/lib/lsp/non_wasm/server/event_loop.rs:44-50 | pyrefly/lib/tsp/server.rs:698-705 — 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 `pyrefly/lib/lsp/non_wasm/server/event_loop.rs:44` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7–8 lines × 2) pyrefly/lib/solver/subset.rs:2130— pyrefly/lib/solver/subset.rs:2130-2136 | pyrefly/lib/solver/subset.rs:2156-2163 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `pyrefly/lib/solver/subset.rs:2137` calls `canonicalize` and `pyrefly/lib/solver/subset.rs:2163` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (6 lines × 4) pyrefly/lib/state/lsp/dict_completions.rs:515— pyrefly/lib/state/lsp/dict_completions.rs:515-520 | pyrefly/lib/state/lsp/dict_completions.rs:719-724 | pyrefly/lib/state/lsp/dict_completions.rs:741-746 | pyrefly/lib/state/lsp/dict_completions.rs:773-781 — 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 `pyrefly/lib/state/lsp/dict_completions.rs:515` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (6 lines × 4) pyrefly/lib/state/semantic_tokens.rs:683— pyrefly/lib/state/semantic_tokens.rs:683-688 | pyrefly/lib/state/semantic_tokens.rs:690-695 | pyrefly/lib/state/semantic_tokens.rs:697-702 | pyrefly/lib/state/semantic_tokens.rs:703-709 — 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 (6 lines × 4) crates/pyrefly_types/src/type_level_dsl.rs:8318— crates/pyrefly_types/src/type_level_dsl.rs:8318-8323 | crates/pyrefly_types/src/type_level_dsl.rs:8345-8351 | crates/pyrefly_types/src/type_level_dsl.rs:8374-8379 | crates/pyrefly_types/src/type_level_dsl.rs:8404-8409 — 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 `crates/pyrefly_types/src/type_level_dsl.rs:8318` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Sync-over-async blocking pyrefly/benches/tsp/record/runner/index.js:56— `fs.statSync` in `size` blocks the event loop until it finishes — a blocking call inside async code stalls the event loop — every other request waits for as long as it runs.
Sync-over-async blocking pyrefly/benches/tsp/record/runner/index.js:79— `fs.readFileSync` in `run` blocks the event loop until it finishes — a blocking call inside async code stalls the event loop — every other request waits for as long as it runs.
Sync-over-async blocking pyrefly/benches/tsp/record/runner/index.js:91— `fs.readFileSync` in `run` blocks the event loop until it finishes — a blocking call inside async code stalls the event loop — every other request waits for as long as it runs.
R4 · Test Coverage· No test reaches this file · ×3
No test reaches this file pyrefly_wasm/pyrefly_wasm.js:1— No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
No test reaches this file lsp/esbuild.js:1— No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
No test reaches this file lsp/build-pyrefly.js:1— No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
TypeDisplayContext::fmt_helper_generic (cyclomatic 160) crates/pyrefly_types/src/display.rs:954— TypeDisplayContext::fmt_helper_generic has cyclomatic complexity 160 (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.
TypeDisplayContext::fmt_params_hover (cyclomatic 20) crates/pyrefly_types/src/display.rs:662— TypeDisplayContext::fmt_params_hover 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.
Solver::finish_quantified_with_captures (cyclomatic 41) pyrefly/lib/solver/solver.rs:2233— Solver::finish_quantified_with_captures has cyclomatic complexity 41 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Solver::simplify_mut (cyclomatic 21) pyrefly/lib/solver/solver.rs:1277— Solver::simplify_mut 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.
pyrefly_config::migration::mypy::pyproject::pyproject_to_ini (cyclomatic 31) crates/pyrefly_config/src/migration/mypy/pyproject.rs:128— pyrefly_config::migration::mypy::pyproject::pyproject_to_ini has cyclomatic complexity 31 (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.
pyrefly_config::migration::mypy::util::make_error_config (cyclomatic 18) crates/pyrefly_config/src/migration/mypy/util.rs:133— pyrefly_config::migration::mypy::util::make_error_config has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This is NOT this file's highest cyclomatic complexity: pyrefly_config::migration::mypy::util::code_to_kind (cyclomatic 39) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded function is counted neither in this dimension's figures nor in its score.
ConfigFile::configure_at (cyclomatic 26) crates/pyrefly_config/src/config.rs:1808— ConfigFile::configure_at has cyclomatic complexity 26 (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.
ConfigFile::from_file::f (cyclomatic 16) crates/pyrefly_config/src/config.rs:2077— ConfigFile::from_file::f 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.
pyrefly_build::module_resolver::find_one_part_in_root (cyclomatic 24) crates/pyrefly_build/src/module_resolver.rs:411— pyrefly_build::module_resolver::find_one_part_in_root 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.
pyrefly_build::module_resolver::find_one_part_prefix (cyclomatic 20) crates/pyrefly_build/src/module_resolver.rs:864— pyrefly_build::module_resolver::find_one_part_prefix 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.
GleanState::declare_statement (cyclomatic 21) pyrefly/lib/report/glean/convert.rs:1861— GleanState::declare_statement has cyclomatic complexity 21 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
GleanState::process_statement (cyclomatic 21) pyrefly/lib/report/glean/convert.rs:1988— GleanState::process_statement has cyclomatic complexity 21 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
DefinitionsBuilder::stmt (cognitive 183) pyrefly/lib/export/definitions.rs:667— DefinitionsBuilder::stmt has cognitive complexity 183 (threshold 15). Drivers by points: if/else 39 (103 pts), match/switch 13 (37 pts), loops 14 (30 pts), boolean chains 13 (nesting depth added 104). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
DefinitionsBuilder::resolve_module_entries (cognitive 16) pyrefly/lib/export/definitions.rs:642— DefinitionsBuilder::resolve_module_entries has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (11 pts), match/switch 1 (4 pts), loops 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
CheckArgs::finish_cli_run (cognitive 92) pyrefly/lib/commands/check.rs:2122— CheckArgs::finish_cli_run has cognitive complexity 92 (threshold 15). Drivers by points: if/else 50 (67 pts), loops 5 (9 pts), boolean chains 8, match/switch 4 (8 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.
CheckArgs::prepare_cli_run (cognitive 17) pyrefly/lib/commands/check.rs:2008— CheckArgs::prepare_cli_run has cognitive complexity 17 (threshold 15). Drivers by points: if/else 12 (13 pts), match/switch 2 (3 pts), boolean chains 1 (nesting depth added 2). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
Expectation::check (cognitive 42) pyrefly/lib/error/expectation.rs:143— Expectation::check has cognitive complexity 42 (threshold 15). Drivers by points: if/else 10 (30 pts), loops 3 (7 pts), match/switch 1 (4 pts), boolean chains 1 (nesting depth added 27). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Expectation::parse (cognitive 16) pyrefly/lib/error/expectation.rs:104— Expectation::parse has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (10 pts), loops 3 (5 pts), boolean chains 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SysInfo::evaluate (cognitive 37) crates/pyrefly_python/src/sys_info.rs:948— SysInfo::evaluate has cognitive complexity 37 (threshold 15). Drivers by points: match/switch 10 (26 pts), loops 2 (6 pts), boolean chains 5 (nesting depth added 20). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
SysInfo::subscript_tuple (cognitive 20) crates/pyrefly_python/src/sys_info.rs:1081— SysInfo::subscript_tuple has cognitive complexity 20 (threshold 15). Drivers by points: if/else 6 (12 pts), match/switch 4 (7 pts), boolean chains 1 (nesting depth added 9). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
pyrefly_config::migration::mypy::pyproject::pyproject_to_ini (cognitive 33) crates/pyrefly_config/src/migration/mypy/pyproject.rs:128— pyrefly_config::migration::mypy::pyproject::pyproject_to_ini has cognitive complexity 33 (threshold 15). Drivers by points: if/else 28 (30 pts), loops 2 (3 pts) (nesting depth added 3). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
pyrefly_config::migration::mypy::util::make_error_config (cognitive 22) crates/pyrefly_config/src/migration/mypy/util.rs:133— pyrefly_config::migration::mypy::util::make_error_config has cognitive complexity 22 (threshold 15). Drivers by points: if/else 11 (15 pts), boolean chains 5, loops 2 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Linearization::merge (cognitive 31) pyrefly/lib/alt/types/class_metadata.rs:1095— Linearization::merge has cognitive complexity 31 (threshold 15). Drivers by points: if/else 5 (14 pts), loops 5 (12 pts), match/switch 1 (5 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.
Linearization::new (cognitive 17) pyrefly/lib/alt/types/class_metadata.rs:987— Linearization::new has cognitive complexity 17 (threshold 15). Drivers by points: if/else 2 (7 pts), match/switch 3 (6 pts), loops 2 (4 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ImportTracker::from_ast (cognitive 30) pyrefly/lib/state/import_tracker.rs:48— ImportTracker::from_ast has cognitive complexity 30 (threshold 15). Drivers by points: if/else 7 (21 pts), loops 3 (7 pts), match/switch 1 (2 pts) (nesting depth added 19). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ImportTracker::resolve_annotation (cognitive 25) pyrefly/lib/state/import_tracker.rs:194— ImportTracker::resolve_annotation has cognitive complexity 25 (threshold 15). Drivers by points: if/else 10 (19 pts), boolean chains 3, match/switch 1 (2 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.
ArgsExpander::expand (cognitive 28) pyrefly/lib/alt/overload.rs:125— ArgsExpander::expand has cognitive complexity 28 (threshold 15). Drivers by points: match/switch 5 (13 pts), if/else 5 (10 pts), loops 2 (5 pts) (nesting depth added 16). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
ArgsExpander::expand_type (cognitive 19) pyrefly/lib/alt/overload.rs:211— ArgsExpander::expand_type has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (13 pts), match/switch 2 (3 pts), loops 1 (2 pts), boolean chains 1 (nesting depth added 9). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
Exports::invalid_dunder_all_entries (cognitive 26) pyrefly/lib/export/exports.rs:495— Exports::invalid_dunder_all_entries has cognitive complexity 26 (threshold 15). Drivers by points: if/else 8 (21 pts), loops 2 (4 pts), boolean chains 1 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Exports::wildcard (cognitive 16) pyrefly/lib/export/exports.rs:239— Exports::wildcard has cognitive complexity 16 (threshold 15). Drivers by points: if/else 3 (9 pts), loops 2 (5 pts), match/switch 1 (2 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Query::get_attributes (cognitive 22) pyrefly/lib/query.rs:1148— Query::get_attributes has cognitive complexity 22 (threshold 15). Drivers by points: if/else 10 (15 pts), match/switch 3 (5 pts), boolean chains 2 (nesting depth added 7). Of this number, 19 points are the body's own statements and 3 belong to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Query::find_imports::collect_attribute_prefixes (cognitive 18) pyrefly/lib/query.rs:1544— Query::find_imports::collect_attribute_prefixes has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (15 pts), loops 1 (3 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.
Workspaces::apply_client_configuration (cognitive 19) pyrefly/lib/lsp/non_wasm/workspace.rs:559— Workspaces::apply_client_configuration has cognitive complexity 19 (threshold 15). Drivers by points: if/else 12 (17 pts), boolean chains 1, match/switch 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.
Workspaces::update_workspace_config (cognitive 16) pyrefly/lib/lsp/non_wasm/workspace.rs:913— Workspaces::update_workspace_config has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (12 pts), match/switch 2 (4 pts) (nesting depth added 8). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
CallGraphVisitor::resolve_attribute_access (cognitive 18) pyrefly/lib/report/pysa/call_graph.rs:2671— CallGraphVisitor::resolve_attribute_access has cognitive complexity 18 (threshold 15). Drivers by points: if/else 9 (10 pts), boolean chains 5, match/switch 2, loops 1 (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
CallGraphVisitor::resolve_and_register_call (cognitive 18) pyrefly/lib/report/pysa/call_graph.rs:3195— CallGraphVisitor::resolve_and_register_call has cognitive complexity 18 (threshold 15). Drivers by points: match/switch 9 (11 pts), boolean chains 7 (nesting depth added 2). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D4 · Code Duplication· Edited copy of a member (34 corresponding lines) · ×2
Edited copy of a member (34 corresponding lines) pyrefly/lib/state/state.rs:3230— pyrefly/lib/state/state.rs:3230-3263 | pyrefly/lib/state/state.rs:3286-3326 — These two members are one piece of code written twice and then edited apart: 34 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (34 corresponding lines) pyrefly/lib/lsp/non_wasm/server.rs:5833— pyrefly/lib/lsp/non_wasm/server.rs:5833-5866 | pyrefly/lib/lsp/non_wasm/server.rs:5874-5910 — 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 (24 corresponding lines) · ×2
Edited copy of a member (24 corresponding lines) crates/pyrefly_derive/src/type_eq.rs:30— crates/pyrefly_derive/src/type_eq.rs:30-53 | crates/pyrefly_derive/src/visit.rs:62-85 — These two members are one piece of code written twice and then edited apart: 24 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (24 corresponding lines) pyrefly/lib/alt/solve.rs:2676— pyrefly/lib/alt/solve.rs:2676-2699 | pyrefly/lib/alt/solve.rs:6850-6876 — These two members are one piece of code written twice and then edited apart: 24 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (21 corresponding lines) · ×2
Edited copy of a member (21 corresponding lines) crates/pyrefly_lsp_test/src/object_model.rs:2038— crates/pyrefly_lsp_test/src/object_model.rs:2038-2058 | crates/pyrefly_lsp_test/src/object_model.rs:2061-2081 — These two members are one piece of code written twice and then edited apart: 21 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (21 corresponding lines) pyrefly/lib/export/exports.rs:447— pyrefly/lib/export/exports.rs:447-467 | pyrefly/lib/export/exports.rs:470-490 — These two members are one piece of code written twice and then edited apart: 21 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copies of one member (3 members, 8+ corresponding lines) · ×2
Edited copies of one member (3 members, 8+ corresponding lines) crates/pyrefly_types/src/literal.rs:162— crates/pyrefly_types/src/literal.rs:162-169 | crates/pyrefly_types/src/literal.rs:172-179 | crates/pyrefly_types/src/literal.rs:182-192 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 8 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
Edited copies of one member (3 members, 8+ corresponding lines) pyrefly/lib/alt/expr.rs:4631— pyrefly/lib/alt/expr.rs:4631-4649 | pyrefly/lib/alt/expr.rs:5223-5230 | pyrefly/lib/alt/type_level_dsl.rs:1214-1227 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 8 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication· Edited copies of one member (3 members, 9+ corresponding lines) · ×2
Edited copies of one member (3 members, 9+ corresponding lines) pyrefly/lib/query/type_table.rs:210— pyrefly/lib/query/type_table.rs:210-226 | pyrefly/lib/query/type_table.rs:232-240 | pyrefly/lib/query/type_table.rs:247-261 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 9 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
Edited copies of one member (3 members, 9+ corresponding lines) crates/pyrefly_python/src/ast.rs:130— crates/pyrefly_python/src/ast.rs:130-139 | pyrefly/lib/binding/function.rs:159-167 | pyrefly/lib/state/lsp/quick_fixes/extract_shared.rs:255-265 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 9 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication· Edited copies of one member (3 members, 10+ corresponding lines) · ×2
Edited copies of one member (3 members, 10+ corresponding lines) pyrefly/lib/state/lsp/quick_fixes/extract_field.rs:106— pyrefly/lib/state/lsp/quick_fixes/extract_field.rs:106-116 | pyrefly/lib/state/lsp/quick_fixes/extract_function.rs:312-321 | pyrefly/lib/state/lsp/quick_fixes/move_members.rs:155-165 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 10 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
Edited copies of one member (3 members, 10+ corresponding lines) tensor-shapes/jax-pyrefly-stubs/examples/bert.py:475— tensor-shapes/jax-pyrefly-stubs/examples/bert.py:475-484 | tensor-shapes/jax-pyrefly-stubs/examples/bert.py:488-497 | tensor-shapes/jax-pyrefly-stubs/examples/bert.py:501-512 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 10 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
Duplicated block (29 lines × 2) crates/pyrefly_config/src/args.rs:493— crates/pyrefly_config/src/args.rs:493-521 | pyrefly/lib/commands/check.rs:531-559 — 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 `crates/pyrefly_config/src/args.rs:493` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (29 lines × 2) tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations_runnable.py:463— tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations_runnable.py:463-491 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var_runnable.py:440-468 — before extracting anything, compare `tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations_runnable.py` and `tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var_runnable.py` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 288 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (28 lines × 2) pyrefly/lib/report/pysa/call_graph.rs:2331— pyrefly/lib/report/pysa/call_graph.rs:2331-2358 | pyrefly/lib/report/pysa/call_graph.rs:2362-2389 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
Duplicated block (28 lines × 2) tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations_runnable.py:401— tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations_runnable.py:401-428 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var_runnable.py:401-428 — before extracting anything, compare `tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations_runnable.py` and `tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var_runnable.py` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 202 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the 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 (23 lines × 2) pyrefly/lib/state/lsp/quick_fixes/move_module.rs:643— pyrefly/lib/state/lsp/quick_fixes/move_module.rs:643-665 | pyrefly/lib/state/lsp/quick_fixes/move_module.rs:681-703 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/state/lsp/quick_fixes/move_module.rs:643` it does not close everything it opens, so those 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 (23 lines × 2) tensor-shapes/pyrefly-torch-stubs/examples/unet.py:215— tensor-shapes/pyrefly-torch-stubs/examples/unet.py:215-237 | tensor-shapes/pyrefly-torch-stubs/examples/unet.py:275-297 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (22 lines × 2) pyrefly/lib/alt/solve.rs:7295— pyrefly/lib/alt/solve.rs:7295-7316 | pyrefly/lib/alt/solve.rs:7328-7349 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/alt/solve.rs:7295` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (22 lines × 2) pyrefly/lib/report/cinderx/convert.rs:91— pyrefly/lib/report/cinderx/convert.rs:91-112 | pyrefly/lib/report/cinderx/convert.rs:390-411 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/report/cinderx/convert.rs:91` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (19 lines × 2) pyrefly/lib/alt/solve.rs:6451— pyrefly/lib/alt/solve.rs:6451-6469 | pyrefly/lib/alt/solve.rs:6512-6530 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/alt/solve.rs:6451` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (19 lines × 2) crates/pyrefly_lsp_test/src/object_model.rs:1085— crates/pyrefly_lsp_test/src/object_model.rs:1085-1103 | crates/pyrefly_lsp_test/src/object_model.rs:1126-1144 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/pyrefly_lsp_test/src/object_model.rs:1085` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (17 lines × 3) pyrefly/lib/alt/narrow.rs:1999— pyrefly/lib/alt/narrow.rs:1999-2015 | pyrefly/lib/alt/narrow.rs:2026-2042 | pyrefly/lib/alt/narrow.rs:2058-2074 — 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 `pyrefly/lib/alt/narrow.rs:1999` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (17 lines × 3) tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:287— tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:287-303 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations.py:287-303 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var.py:267-283 — before extracting anything, compare `tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py` and `tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 392 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 `tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:287` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (17 lines × 2) crates/pyrefly_lsp_test/src/object_model.rs:1853— crates/pyrefly_lsp_test/src/object_model.rs:1853-1869 | crates/pyrefly_lsp_test/src/object_model.rs:1895-1911 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
Duplicated block (17 lines × 2) crates/tsp_types/protocol_generator/generate_protocol.py:116— crates/tsp_types/protocol_generator/generate_protocol.py:116-132 | crates/tsp_types/protocol_generator/generate_protocol.py:142-158 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (12–14 lines × 2) pyrefly/lib/alt/call.rs:867— pyrefly/lib/alt/call.rs:867-880 | pyrefly/lib/alt/call.rs:886-897 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/alt/call.rs:867` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12–14 lines × 2) pyrefly/lib/lsp/wasm/completion.rs:917— pyrefly/lib/lsp/wasm/completion.rs:917-928 | pyrefly/lib/state/lsp.rs:474-487 — 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 `pyrefly/lib/lsp/wasm/completion.rs:917` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (13–14 lines × 2) pyrefly/lib/alt/class/class_field.rs:6256— pyrefly/lib/alt/class/class_field.rs:6256-6269 | pyrefly/lib/alt/class/class_field.rs:6634-6646 — both copies are in the same file, so extract the 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, `pyrefly/lib/alt/class/class_field.rs:6647` calls `Some` and `pyrefly/lib/alt/class/class_field.rs:6270` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (13–14 lines × 2) pyrefly/lib/alt/expr.rs:2680— pyrefly/lib/alt/expr.rs:2680-2693 | pyrefly/lib/alt/expr.rs:2717-2729 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/alt/expr.rs:2680` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (10–13 lines × 2) pyrefly/lib/alt/class/variance_inference.rs:664— pyrefly/lib/alt/class/variance_inference.rs:664-676 | pyrefly/lib/alt/class/variance_inference.rs:686-695 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (10–13 lines × 2) pyrefly/lib/commands/infer.rs:345— pyrefly/lib/commands/infer.rs:345-354 | pyrefly/lib/commands/stubgen.rs:62-74 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (12 lines × 3) crates/pyrefly_types/src/type_level_dsl.rs:8328— crates/pyrefly_types/src/type_level_dsl.rs:8328-8339 | crates/pyrefly_types/src/type_level_dsl.rs:8357-8368 | crates/pyrefly_types/src/type_level_dsl.rs:8436-8447 — 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 `crates/pyrefly_types/src/type_level_dsl.rs:8328` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (12 lines × 3) tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:301— tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:301-312 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations.py:301-312 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations_runnable.py:253-264 — before extracting anything, compare `tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py` and `tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 392 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (10–12 lines × 2) crates/pyrefly_types/src/type_level_dsl.rs:2646— crates/pyrefly_types/src/type_level_dsl.rs:2646-2657 | crates/pyrefly_types/src/type_level_dsl.rs:3938-3947 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/pyrefly_types/src/type_level_dsl.rs:2646` it does not close everything it opens, so those exact lines 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) pyrefly/lib/alt/operators.rs:821— pyrefly/lib/alt/operators.rs:821-830 | pyrefly/lib/alt/operators.rs:930-941 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/alt/operators.rs:821` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9–10 lines × 2) crates/pyrefly_types/src/display.rs:883— crates/pyrefly_types/src/display.rs:883-892 | pyrefly/lib/annotation.rs:138-146 — 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 `crates/pyrefly_types/src/display.rs:883` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9–10 lines × 2) pyrefly/lib/commands/infer.rs:357— pyrefly/lib/commands/infer.rs:357-365 | pyrefly/lib/commands/stubgen.rs:74-83 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/commands/stubgen.rs:74` it begins part-way through the construct above it, so those 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, `pyrefly/lib/commands/infer.rs:356` calls `as_ref`, `cancellable_transaction`, `as_mut` and `pyrefly/lib/commands/stubgen.rs:74` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (9 lines × 5) pyrefly/lib/lsp/non_wasm/server.rs:2515— pyrefly/lib/lsp/non_wasm/server.rs:2515-2523 | pyrefly/lib/lsp/non_wasm/server.rs:2590-2598 | pyrefly/lib/lsp/non_wasm/server.rs:2907-2915 | pyrefly/lib/lsp/non_wasm/server.rs:2922-2930 | pyrefly/lib/lsp/non_wasm/server.rs:2952-2960 — 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 `pyrefly/lib/lsp/non_wasm/server.rs:2515` it begins part-way through the construct above it, so those exact lines 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) tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:332— tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:332-340 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations.py:335-343 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations_runnable.py:331-339 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var.py:348-356 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var_runnable.py:330-338 — before extracting anything, compare `tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py` and `tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations.py` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 247 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (7–9 lines × 2) pyrefly/lib/alt/function.rs:2919— pyrefly/lib/alt/function.rs:2919-2927 | pyrefly/lib/alt/function.rs:3000-3006 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/alt/function.rs:2919` it begins part-way through the construct above it, so those exact lines 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–9 lines × 2) pyrefly/lib/state/state.rs:1647— pyrefly/lib/state/state.rs:1647-1655 | pyrefly/lib/state/state.rs:2723-2729 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication· Edited copies of one member (5 members, 4+ corresponding lines) · ×2
Edited copies of one member (5 members, 4+ corresponding lines) tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:317— tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:317-320 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations.py:320-323 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations_runnable.py:316-319 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var.py:333-336 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var_runnable.py:315-318 — These 5 members are one piece of code written 5 times and then edited apart: every two of them correspond over at least 4 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 5 times and the copies will drift further apart.
Edited copies of one member (5 members, 4+ corresponding lines) tensor-shapes/pyrefly-torch-stubs/examples/demucs.py:478— tensor-shapes/pyrefly-torch-stubs/examples/demucs.py:478-482 | tensor-shapes/pyrefly-torch-stubs/examples/llama.py:442-446 | tensor-shapes/pyrefly-torch-stubs/examples/mixtral_moe.py:472-475 | tensor-shapes/pyrefly-torch-stubs/examples/speech_transformer.py:513-523 | tensor-shapes/pyrefly-torch-stubs/examples/tacotron2.py:588-592 — These 5 members are one piece of code written 5 times and then edited apart: every two of them correspond over at least 4 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 5 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) tensor-shapes/pyrefly-torch-stubs/examples/background_matting.py:554— tensor-shapes/pyrefly-torch-stubs/examples/background_matting.py:554-558 | tensor-shapes/pyrefly-torch-stubs/examples/dcgan.py:284-287 — 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) tensor-shapes/pyrefly-torch-stubs/examples/dlrm.py:103— tensor-shapes/pyrefly-torch-stubs/examples/dlrm.py:103-106 | tensor-shapes/pyrefly-torch-stubs/examples/soft_actor_critic.py:329-333 — 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.
D4 · Code Duplication· Edited copies of one member (5 members, 3+ corresponding lines) · ×2
Edited copies of one member (5 members, 3+ corresponding lines) tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:582— tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:582-584 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations.py:585-587 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations_runnable.py:543-545 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var.py:589-591 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var_runnable.py:533-535 — These 5 members are one piece of code written 5 times and then edited apart: every two of them correspond over at least 3 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, 3+ corresponding lines) tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:226— tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:226-228 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations.py:226-228 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations_runnable.py:183-185 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var.py:221-223 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var_runnable.py:174-176 — These 5 members are one piece of code written 5 times and then edited apart: every two of them correspond over at least 3 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 5 times and the copies will drift further apart.
D4 · Code Duplication· Edited copies of one member (3 members, 3+ corresponding lines) · ×2
Edited copies of one member (3 members, 3+ corresponding lines) tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations_runnable.py:40— tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations_runnable.py:40-42 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var_runnable.py:47-49 | tensor-shapes/pyrefly-torch-stubs/examples/sam.py:85-88 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 3 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
Edited copies of one member (3 members, 3+ corresponding lines) tensor-shapes/pyrefly-torch-stubs/examples/dlrm.py:76— tensor-shapes/pyrefly-torch-stubs/examples/dlrm.py:76-79 | tensor-shapes/pyrefly-torch-stubs/examples/soft_actor_critic.py:160-163 | tensor-shapes/pyrefly-torch-stubs/examples/tacotron2.py:67-69 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 3 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
Duplicated block (31 lines × 5) tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:494— tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:494-524 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations.py:497-527 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations_runnable.py:463-493 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var.py:506-536 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var_runnable.py:458-488 — before extracting anything, compare `tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py` and `tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations.py` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 247 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 (31 lines × 5) tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:467— tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:467-497 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations.py:467-497 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations_runnable.py:407-437 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var.py:448-478 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var_runnable.py:384-414 — before extracting anything, compare `tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py` and `tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 392 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (18 lines × 3) tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:280— tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:280-297 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations.py:283-300 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var.py:301-318 — before extracting anything, compare `tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py` and `tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations.py` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 247 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 `tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:280` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. 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 × 3) tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:377— tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:377-394 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations.py:380-397 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var.py:393-410 — before extracting anything, compare `tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py` and `tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations.py` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 247 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 `tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:377` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (16 lines × 3) tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:529— tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:529-544 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations.py:532-547 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var.py:541-556 — before extracting anything, compare `tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py` and `tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations.py` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 247 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 `tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:529` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. 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 × 3) tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:259— tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:259-274 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations.py:262-277 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var.py:280-295 — before extracting anything, compare `tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py` and `tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations.py` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 247 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 `tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:259` it does not close everything it opens, so those 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 × 5) tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:308— tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:308-315 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations.py:308-315 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations_runnable.py:260-267 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var.py:288-295 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var_runnable.py:236-243 — before extracting anything, compare `tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py` and `tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 392 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (8 lines × 5) tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:395— tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:395-402 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations.py:395-402 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations_runnable.py:335-342 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var.py:376-383 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var_runnable.py:312-319 — before extracting anything, compare `tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py` and `tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 392 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (5 lines × 3) tensor-shapes/pyrefly-torch-stubs/examples/super_slomo.py:380— tensor-shapes/pyrefly-torch-stubs/examples/super_slomo.py:380-384 | tensor-shapes/pyrefly-torch-stubs/examples/super_slomo.py:388-392 | tensor-shapes/pyrefly-torch-stubs/examples/unet.py:356-360 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart.
Duplicated block (5 lines × 3) tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:38— tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:38-42 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations.py:38-42 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var.py:49-53 — before extracting anything, compare `tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py` and `tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 392 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.
Low cohesion: NestingContext (LCOM4 5) crates/pyrefly_python/src/nesting_context.rs:24— NestingContext's methods fall into 5 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 5 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
Low cohesion: Solver (LCOM4 4) pyrefly/lib/solver/solver.rs:580— Solver's methods fall into 4 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 4 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
DefinitionsBuilder::stmt (cyclomatic 98) pyrefly/lib/export/definitions.rs:667— DefinitionsBuilder::stmt has cyclomatic complexity 98 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Binding::fmt (cyclomatic 80) pyrefly/lib/binding/binding.rs:2876— Binding::fmt has cyclomatic complexity 80 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
CheckArgs::finish_cli_run (cyclomatic 63) pyrefly/lib/commands/check.rs:2122— CheckArgs::finish_cli_run has cyclomatic complexity 63 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
NarrowOps::from_expr_helper (cyclomatic 56) pyrefly/lib/binding/narrow.rs:1050— NarrowOps::from_expr_helper has cyclomatic complexity 56 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
TypeConverter::convert (cyclomatic 55) pyrefly/lib/tsp/type_conversion.rs:314— TypeConverter::convert has cyclomatic complexity 55 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
SysInfo::evaluate (cyclomatic 41) crates/pyrefly_python/src/sys_info.rs:948— SysInfo::evaluate has cyclomatic complexity 41 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
ConfigOverrideArgs::override_config_at (cyclomatic 39) crates/pyrefly_config/src/args.rs:622— ConfigOverrideArgs::override_config_at has cyclomatic complexity 39 (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.
TypeCheckKind::format_error (cyclomatic 38) pyrefly/lib/error/display.rs:63— TypeCheckKind::format_error has cyclomatic complexity 38 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
extension.activate (cyclomatic 33) lsp/src/extension.ts:241— extension.activate has cyclomatic complexity 33 (threshold 15). Most of this is not in the body itself: 6 of the 33 points are its own statements and the rest belongs to 11 function literals inside it that branch (lines 489, 409, 551, …). The decisions are inside those literals, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literals' work into a named function or method at the enclosing scope and have each literal call it, then reduce whichever part then reads as the largest.
TypeShapeDslHelperCall::argument_domains (cyclomatic 28) crates/pyrefly_types/src/type_level_dsl.rs:210— TypeShapeDslHelperCall::argument_domains 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.
CalleesWithLocation::callee_from_type (cyclomatic 27) pyrefly/lib/query.rs:975— CalleesWithLocation::callee_from_type has cyclomatic complexity 27 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
Errors::collect_unused_ignore_errors_for_module (cyclomatic 26) pyrefly/lib/state/errors.rs:769— Errors::collect_unused_ignore_errors_for_module 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.
PolarsScalarDType::supertype (cyclomatic 25) crates/pyrefly_types/src/polars_dtype.rs:138— PolarsScalarDType::supertype has cyclomatic complexity 25 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
stub_coverage._literal_all (cyclomatic 25) tensor-shapes/stub_coverage.py:218— stub_coverage._literal_all has cyclomatic complexity 25 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
InitArgs::create_config (cyclomatic 24) pyrefly/lib/commands/init.rs:254— InitArgs::create_config has cyclomatic complexity 24 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
CallGraphVisitor::resolve_and_register_call (cyclomatic 24) pyrefly/lib/report/pysa/call_graph.rs:3195— CallGraphVisitor::resolve_and_register_call has cyclomatic complexity 24 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
generate_protocol.convert_json_to_model (cyclomatic 24) crates/tsp_types/protocol_generator/generate_protocol.py:62— generate_protocol.convert_json_to_model has cyclomatic complexity 24 (threshold 15). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
stub_coverage.parse_stub (cyclomatic 24) tensor-shapes/stub_coverage.py:285— stub_coverage.parse_stub 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.
ConfigBase::fill_unset_from (cyclomatic 23) crates/pyrefly_config/src/base.rs:451— ConfigBase::fill_unset_from 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.
InferArgs::run_inner (cyclomatic 23) pyrefly/lib/commands/infer.rs:339— InferArgs::run_inner 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.
OverrideCodeLensProvider.provideCodeLenses (cyclomatic 23) lsp/src/overrideCodeLens.ts:144— OverrideCodeLensProvider.provideCodeLenses has cyclomatic complexity 23 (threshold 15). Of this number, 20 points are the body's own statements and 3 belong to one function literal inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
BindingExpect::fmt (cyclomatic 22) pyrefly/lib/binding/binding.rs:1432— BindingExpect::fmt has cyclomatic complexity 22 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing. This is NOT this file's highest cyclomatic complexity: Key::fmt (cyclomatic 34) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded function is counted neither in this dimension's figures nor in its score.
TestAssertion::to_narrow_ops (cyclomatic 21) pyrefly/lib/binding/expr.rs:239— TestAssertion::to_narrow_ops has cyclomatic complexity 21 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
whyPyreflyGridItem.WhyPyreflyGridItem (cyclomatic 21) website/src/components/landing-page/whyPyreflyGridItem.tsx:44— whyPyreflyGridItem.WhyPyreflyGridItem has cyclomatic complexity 21 (threshold 15). Most of this is not in the body itself: 3 of the 21 points are its own statements and the rest belongs to 3 function items inside it that branch (a function literal at line 86, handleClick, handleKeyDown). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
SideParser::parse (cyclomatic 20) crates/pyrefly_types/src/gufunc.rs:156— SideParser::parse 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.
CallArg::pre_eval (cyclomatic 20) pyrefly/lib/alt/callable.rs:513— CallArg::pre_eval 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.
Value::compare (cyclomatic 19) crates/pyrefly_python/src/sys_info.rs:667— Value::compare has cyclomatic complexity 19 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
Bindings::new (cyclomatic 19) pyrefly/lib/binding/bindings.rs:1093— Bindings::new 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.
CancellableTransaction::override_code_lens_targets (cyclomatic 19) pyrefly/lib/state/lsp.rs:6040— CancellableTransaction::override_code_lens_targets 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. This is NOT this file's highest cyclomatic complexity: Transaction::identifier_from_covering_nodes (cyclomatic 22) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded function is counted neither in this dimension's figures nor in its score.
Int::fmt_prec (cyclomatic 18) crates/pyrefly_types/src/dimension.rs:450— Int::fmt_prec has cyclomatic complexity 18 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing. This is NOT this file's highest cyclomatic complexity: pyrefly_types::dimension::compare_int (cyclomatic 22) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded function is counted neither in this dimension's figures nor in its score.
Builder::visit_stmt (cyclomatic 18) pyrefly/lib/report/scip/symbols.rs:268— Builder::visit_stmt has cyclomatic complexity 18 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
Indexer::document (cyclomatic 18) pyrefly/lib/report/scip.rs:328— Indexer::document has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
generate_protocol.replace_integer_enum (cyclomatic 18) crates/tsp_types/protocol_generator/generate_protocol.py:726— generate_protocol.replace_integer_enum has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
UpwardSearch::directory_absolute (cyclomatic 17) crates/pyrefly_util/src/upward_search.rs:134— UpwardSearch::directory_absolute 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.
PysaModuleIndex::build (cyclomatic 17) pyrefly/lib/report/pysa/module_index.rs:141— PysaModuleIndex::build 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.
generate_protocol.replace_flag_enum (cyclomatic 17) crates/tsp_types/protocol_generator/generate_protocol.py:568— generate_protocol.replace_flag_enum 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.
EnvironmentArgs::override_environment_config (cyclomatic 16) crates/pyrefly_config/src/args.rs:226— EnvironmentArgs::override_environment_config 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.
IgnoreMissingImports::migrate_from_mypy (cyclomatic 16) crates/pyrefly_config/src/migration/ignore_missing_imports.rs:37— IgnoreMissingImports::migrate_from_mypy 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.
NarrowedFacet::join (cyclomatic 16) crates/pyrefly_types/src/type_info.rs:849— NarrowedFacet::join has cyclomatic complexity 16 (threshold 15). Of this number, 14 points are the body's own statements and 2 belong to one function item inside it that branches. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
ResolvedTypeShapeDslProgram::evaluate_suite (cyclomatic 16) crates/pyrefly_types/src/type_level_dsl.rs:6469— ResolvedTypeShapeDslProgram::evaluate_suite has cyclomatic complexity 16 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
ContextualTypeCollector::visit_stmt (cyclomatic 16) pyrefly/lib/report/cinderx/collect.rs:183— ContextualTypeCollector::visit_stmt 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.
ModuleChanges::overlaps (cyclomatic 16) pyrefly/lib/state/state.rs:281— ModuleChanges::overlaps 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.
conformance_output.main (cyclomatic 16) conformance/conformance_output.py:299— conformance_output.main 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.
No assertions: startup requests and diagnostics use the interpreter from the Python extension lsp/src/test/startup-settings/instant/instant.test.ts:23— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure*, in the test body and in the helpers it calls in the test and test-support code (a helper there that throws when its check fails counts as an assertion) — so verification routed through a callback object whose members hold the assertions, or through a harness in production code that fails by throwing, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
Repeated repair: pyrefly/lib/lsp/wasm/signature_help.rs pyrefly/lib/lsp/wasm/signature_help.rs:282— pyrefly/lib/lsp/wasm/signature_help.rs changed 7 times in last 90 days and 4 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 9 (its worst body is Transaction::filter_compatible_overloads at line 282), AT OR UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix bug: generic ABC is mistakenly allowed to be instantiated by providing a type argument to the constructor #4263 (#4283)”; “Fix issue 2500 (#5466)”; “Fix Go to Definition for standard library symbols (#5040)”; “fix [Inlay hints] Wrong call argument name for loguru.Logger #4936 (#4938)”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-08-15..2026-11-13, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-15 12:12:22 -08:00' --until='2026-11-13 12:12:22 -08:00' --full-history --no-merges -- pyrefly/lib/lsp/wasm/signature_help.rs`: 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.
XxxComment pyrefly/lib/state/lsp.rs:1267— // XXX(..., id=..., ...) — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
FixmeComment pyrefly/lib/alt/function.rs:3108— // FIXME: We're suppressing invalid type variables errors for all — 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.
Errors::collect_unused_ignore_errors_for_module (cognitive 66) pyrefly/lib/state/errors.rs:769— Errors::collect_unused_ignore_errors_for_module has cognitive complexity 66 (threshold 15). Drivers by points: if/else 16 (43 pts), loops 6 (15 pts), boolean chains 5, match/switch 1 (3 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.
NarrowOps::from_expr_helper (cognitive 63) pyrefly/lib/binding/narrow.rs:1050— NarrowOps::from_expr_helper has cognitive complexity 63 (threshold 15). Drivers by points: if/else 13 (27 pts), loops 5 (14 pts), match/switch 6 (13 pts), boolean chains 9 (nesting depth added 30). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SideParser::parse (cognitive 55) crates/pyrefly_types/src/gufunc.rs:156— SideParser::parse has cognitive complexity 55 (threshold 15). Drivers by points: if/else 14 (38 pts), loops 4 (14 pts), boolean chains 3 (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.
stub_coverage._literal_all (cognitive 55) tensor-shapes/stub_coverage.py:218— stub_coverage._literal_all has cognitive complexity 55 (threshold 15). Drivers by points: if/else 17 (46 pts), boolean chains 5, ternaries 2 (3 pts), loops 1 (nesting depth added 30). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
InferArgs::run_inner (cognitive 50) pyrefly/lib/commands/infer.rs:339— InferArgs::run_inner has cognitive complexity 50 (threshold 15). Drivers by points: if/else 18 (37 pts), boolean chains 6, match/switch 1 (4 pts), loops 2 (3 pts) (nesting depth added 23). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Binding::fmt (cognitive 44) pyrefly/lib/binding/binding.rs:2876— Binding::fmt has cognitive complexity 44 (threshold 15). Drivers by points: if/else 8 (19 pts), match/switch 10 (19 pts), loops 3 (6 pts) (nesting depth added 23). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
UpwardSearch::directory_absolute (cognitive 43) crates/pyrefly_util/src/upward_search.rs:134— UpwardSearch::directory_absolute has cognitive complexity 43 (threshold 15). Drivers by points: if/else 9 (24 pts), loops 6 (12 pts), match/switch 2 (6 pts), boolean chains 1 (nesting depth added 25). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PysaModuleIndex::build (cognitive 43) pyrefly/lib/report/pysa/module_index.rs:141— PysaModuleIndex::build has cognitive complexity 43 (threshold 15). Drivers by points: if/else 12 (37 pts), loops 4 (5 pts), boolean chains 1 (nesting depth added 26). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ConfigOverrideArgs::override_config_at (cognitive 42) crates/pyrefly_config/src/args.rs:622— ConfigOverrideArgs::override_config_at has cognitive complexity 42 (threshold 15). Drivers by points: if/else 30 (34 pts), loops 5, boolean chains 2, match/switch 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.
CallArg::pre_eval (cognitive 42) pyrefly/lib/alt/callable.rs:513— CallArg::pre_eval has cognitive complexity 42 (threshold 15). Drivers by points: if/else 9 (23 pts), loops 3 (10 pts), match/switch 3 (7 pts), boolean chains 2 (nesting depth added 25). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
generate_protocol.convert_json_to_model (cognitive 41) crates/tsp_types/protocol_generator/generate_protocol.py:62— generate_protocol.convert_json_to_model has cognitive complexity 41 (threshold 15). Drivers by points: loops 13 (21 pts), if/else 8 (15 pts), error handling 1 (3 pts), ternaries 1 (2 pts) (nesting depth added 18). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
TypeShapeDslHelperCall::argument_domains (cognitive 37) crates/pyrefly_types/src/type_level_dsl.rs:210— TypeShapeDslHelperCall::argument_domains has cognitive complexity 37 (threshold 15). Drivers by points: if/else 12 (25 pts), match/switch 5 (9 pts), boolean chains 3 (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
InitArgs::create_config (cognitive 37) pyrefly/lib/commands/init.rs:254— InitArgs::create_config has cognitive complexity 37 (threshold 15). Drivers by points: if/else 21 (32 pts), boolean chains 5 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
generate_protocol.replace_integer_enum (cognitive 34) crates/tsp_types/protocol_generator/generate_protocol.py:726— generate_protocol.replace_integer_enum has cognitive complexity 34 (threshold 15). Drivers by points: if/else 14 (27 pts), loops 4 (6 pts), boolean chains 1 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Indexer::document (cognitive 33) pyrefly/lib/report/scip.rs:328— Indexer::document has cognitive complexity 33 (threshold 15). Drivers by points: if/else 9 (23 pts), loops 4 (5 pts), match/switch 2 (3 pts), boolean chains 2 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ContextualTypeCollector::visit_stmt (cognitive 32) pyrefly/lib/report/cinderx/collect.rs:183— ContextualTypeCollector::visit_stmt has cognitive complexity 32 (threshold 15). Drivers by points: if/else 10 (22 pts), match/switch 2 (5 pts), boolean chains 3, loops 1 (2 pts) (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
CancellableTransaction::override_code_lens_targets (cognitive 32) pyrefly/lib/state/lsp.rs:6040— CancellableTransaction::override_code_lens_targets has cognitive complexity 32 (threshold 15). Drivers by points: if/else 10 (21 pts), loops 6 (9 pts), boolean chains 1, match/switch 1 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
conformance_output.main (cognitive 31) conformance/conformance_output.py:299— conformance_output.main has cognitive complexity 31 (threshold 15). Drivers by points: if/else 14 (24 pts), loops 2 (4 pts), ternaries 1 (3 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.
extension.activate (cognitive 30) lsp/src/extension.ts:241— extension.activate has cognitive complexity 30 (threshold 15). Drivers by points: if/else 20, boolean chains 5, error handling 3, ternaries 1 (2 pts) (nesting depth added 1). Most of this is not in the body itself: 5 of the 30 points are its own statements and the rest belongs to 11 function literals inside it that branch (lines 489, 551, 409, …). The decisions are inside those literals, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literals' work into a named function or method at the enclosing scope and have each literal call it, then reduce whichever part then reads as the largest.
OverrideCodeLensProvider.provideCodeLenses (cognitive 29) lsp/src/overrideCodeLens.ts:144— OverrideCodeLensProvider.provideCodeLenses has cognitive complexity 29 (threshold 15). Drivers by points: if/else 11 (16 pts), boolean chains 6, ternaries 2 (5 pts), error handling 1, loops 1 (nesting depth added 8). Of this number, 24 points are the body's own statements and 5 belong to one function literal inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Tuple::fmt_with_type (cognitive 27) crates/pyrefly_types/src/tuple.rs:80— Tuple::fmt_with_type has cognitive complexity 27 (threshold 15). Drivers by points: if/else 7 (18 pts), loops 3 (8 pts), match/switch 1 (nesting depth added 16). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
Bindings::new (cognitive 27) pyrefly/lib/binding/bindings.rs:1093— Bindings::new has cognitive complexity 27 (threshold 15). Drivers by points: if/else 14 (20 pts), loops 4, match/switch 1 (2 pts), boolean chains 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
stub_coverage.parse_stub (cognitive 26) tensor-shapes/stub_coverage.py:285— stub_coverage.parse_stub has cognitive complexity 26 (threshold 15). Drivers by points: if/else 6 (15 pts), boolean chains 10, 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.
Value::compare (cognitive 25) crates/pyrefly_python/src/sys_info.rs:667— Value::compare has cognitive complexity 25 (threshold 15). Drivers by points: match/switch 8 (21 pts), if/else 3 (4 pts) (nesting depth added 14). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
ResolvedTypeShapeDslProgram::evaluate_suite (cognitive 24) crates/pyrefly_types/src/type_level_dsl.rs:6469— ResolvedTypeShapeDslProgram::evaluate_suite has cognitive complexity 24 (threshold 15). Drivers by points: match/switch 5 (15 pts), if/else 2 (8 pts), loops 1 (nesting depth added 16). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
Claims::visit_stmt (cognitive 24) pyrefly/lib/binding/shape_comments.rs:446— Claims::visit_stmt has cognitive complexity 24 (threshold 15). Drivers by points: if/else 4 (11 pts), match/switch 3 (7 pts), loops 2 (4 pts), boolean chains 2 (nesting depth added 13). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
SourceBindings::from_ast (cognitive 24) pyrefly/lib/state/lsp/fastapi_endpoint_support/association_summary.rs:78— SourceBindings::from_ast has cognitive complexity 24 (threshold 15). Drivers by points: if/else 4 (12 pts), loops 3 (7 pts), match/switch 2 (4 pts), boolean chains 1 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
generate_protocol.replace_flag_enum (cognitive 24) crates/tsp_types/protocol_generator/generate_protocol.py:568— generate_protocol.replace_flag_enum has cognitive complexity 24 (threshold 15). Drivers by points: if/else 14 (20 pts), loops 3, boolean chains 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ErrorCollector::collect_sorted (cognitive 23) pyrefly/lib/error/collector.rs:608— ErrorCollector::collect_sorted has cognitive complexity 23 (threshold 15). Drivers by points: if/else 10 (17 pts), boolean chains 3, match/switch 1 (2 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.
ConfigBase::fill_unset_from (cognitive 22) crates/pyrefly_config/src/base.rs:451— ConfigBase::fill_unset_from has cognitive complexity 22 (threshold 15). Drivers by points: if/else 22. 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.
RenameUsageVisitor::visit_stmt (cognitive 22) pyrefly/lib/lsp/non_wasm/will_rename_files.rs:75— RenameUsageVisitor::visit_stmt has cognitive complexity 22 (threshold 15). Drivers by points: if/else 8 (16 pts), match/switch 2 (4 pts), loops 1 (2 pts) (nesting depth added 11). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
WorkspaceConfigConfigurer::configure (cognitive 22) pyrefly/lib/lsp/non_wasm/workspace.rs:88— WorkspaceConfigConfigurer::configure has cognitive complexity 22 (threshold 15). Drivers by points: if/else 10 (19 pts), boolean chains 2, loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
QuerySourceDatabase::update_with_target_manifest (cognitive 21) crates/pyrefly_build/src/source_db/query_source_db.rs:163— QuerySourceDatabase::update_with_target_manifest has cognitive complexity 21 (threshold 15). Drivers by points: if/else 7 (10 pts), loops 5 (9 pts), boolean chains 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ParamList::fmt_with_type (cognitive 21) crates/pyrefly_types/src/callable.rs:181— ParamList::fmt_with_type has cognitive complexity 21 (threshold 15). Drivers by points: if/else 8 (14 pts), boolean chains 4, loops 2 (3 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PolarsScalarDType::supertype (cognitive 21) crates/pyrefly_types/src/polars_dtype.rs:138— PolarsScalarDType::supertype has cognitive complexity 21 (threshold 15). Drivers by points: if/else 10, match/switch 4 (7 pts), boolean chains 4 (nesting depth added 3). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
Tarjan::root (cognitive 21) crates/pyrefly_util/src/tarjan.rs:64— Tarjan::root has cognitive complexity 21 (threshold 15). Drivers by points: if/else 3 (10 pts), match/switch 3 (6 pts), loops 2 (5 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.
Answers::solve (cognitive 21) pyrefly/lib/alt/answers.rs:1464— Answers::solve has cognitive complexity 21 (threshold 15). Drivers by points: if/else 7 (14 pts), loops 2 (3 pts), match/switch 1 (3 pts), boolean chains 1 (nesting depth added 10). Of this number, 18 points are the body's own statements and 3 belong to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
TypeCheckKind::format_error (cognitive 21) pyrefly/lib/error/display.rs:63— TypeCheckKind::format_error has cognitive complexity 21 (threshold 15). Drivers by points: if/else 8 (12 pts), match/switch 6 (9 pts) (nesting depth added 7). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
Builder::visit_stmt (cognitive 21) pyrefly/lib/report/scip/symbols.rs:268— Builder::visit_stmt has cognitive complexity 21 (threshold 15). Drivers by points: if/else 4 (8 pts), loops 3 (6 pts), match/switch 3 (6 pts), boolean chains 1 (nesting depth added 10). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
TspExtraConnection::run (cognitive 21) pyrefly/lib/tsp/server.rs:556— TspExtraConnection::run has cognitive complexity 21 (threshold 15). Drivers by points: if/else 3 (10 pts), match/switch 3 (9 pts), loops 2 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
shape_testing.check_suites (cognitive 21) tensor-shapes/shape_testing.py:217— shape_testing.check_suites has cognitive complexity 21 (threshold 15). Drivers by points: if/else 6 (12 pts), loops 3 (5 pts), ternaries 2 (3 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.
AdvancedIndexPlan::build (cognitive 20) crates/pyrefly_types/src/shape_index.rs:708— AdvancedIndexPlan::build has cognitive complexity 20 (threshold 15). Drivers by points: if/else 6 (14 pts), match/switch 2 (3 pts), boolean chains 2, loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PytestAliases::from_stmts (cognitive 20) pyrefly/lib/binding/pytest.rs:33— PytestAliases::from_stmts has cognitive complexity 20 (threshold 15). Drivers by points: if/else 3 (9 pts), loops 3 (7 pts), boolean chains 2, match/switch 1 (2 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
BaselineIndex::apply (cognitive 20) pyrefly/lib/error/baseline.rs:356— BaselineIndex::apply has cognitive complexity 20 (threshold 15). Drivers by points: loops 5 (11 pts), if/else 3 (6 pts), match/switch 2, boolean chains 1 (nesting depth added 9). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
GleanState::declare_statement (cognitive 20) pyrefly/lib/report/glean/convert.rs:1861— GleanState::declare_statement has cognitive complexity 20 (threshold 15). Drivers by points: loops 7 (12 pts), if/else 3 (7 pts), match/switch 1 (nesting depth added 9). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
ModuleChanges::overlaps (cognitive 20) pyrefly/lib/state/state.rs:281— ModuleChanges::overlaps has cognitive complexity 20 (threshold 15). Drivers by points: if/else 6 (11 pts), boolean chains 8, loops 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PyProject::update (cognitive 19) crates/pyrefly_config/src/pyproject.rs:78— PyProject::update has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (17 pts), boolean chains 2 (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.
TaskHeap::work (cognitive 19) crates/pyrefly_util/src/task_heap.rs:172— TaskHeap::work has cognitive complexity 19 (threshold 15). Drivers by points: if/else 5 (14 pts), boolean chains 2, match/switch 1 (2 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.
SemanticTokensLegends::convert_tokens_into_lsp_semantic_tokens (cognitive 19) pyrefly/lib/state/semantic_tokens.rs:190— SemanticTokensLegends::convert_tokens_into_lsp_semantic_tokens has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (13 pts), loops 3 (5 pts), boolean chains 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
view_types.inline_type (cognitive 19) pyrefly/lib/report/cinderx/view_types.py:27— view_types.inline_type has cognitive complexity 19 (threshold 15). Drivers by points: if/else 13 (19 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.
IgnoreMissingImports::migrate_from_mypy (cognitive 18) crates/pyrefly_config/src/migration/ignore_missing_imports.rs:37— IgnoreMissingImports::migrate_from_mypy has cognitive complexity 18 (threshold 15). Drivers by points: if/else 13 (15 pts), boolean chains 3 (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.
Ignore::parse (cognitive 18) crates/pyrefly_python/src/ignore.rs:545— Ignore::parse has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (13 pts), loops 2 (3 pts), boolean chains 2 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Callable::fmt_with_type (cognitive 18) crates/pyrefly_types/src/callable.rs:508— Callable::fmt_with_type has cognitive complexity 18 (threshold 15). Drivers by points: if/else 4 (12 pts), match/switch 2 (3 pts), loops 1 (2 pts), boolean chains 1 (nesting depth added 10). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
PolarsDType::fmt (cognitive 18) crates/pyrefly_types/src/polars_dtype.rs:383— PolarsDType::fmt has cognitive complexity 18 (threshold 15). Drivers by points: if/else 3 (10 pts), loops 2 (5 pts), match/switch 2 (3 pts) (nesting depth added 11). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
LegacyErrors::write_json (cognitive 18) pyrefly/lib/error/legacy.rs:185— LegacyErrors::write_json has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (12 pts), loops 4 (6 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.
ModuleDeps::invalidated_by (cognitive 18) pyrefly/lib/state/state.rs:414— ModuleDeps::invalidated_by has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (11 pts), boolean chains 6, loops 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
conformance_output.diff_expected_errors (cognitive 18) conformance/conformance_output.py:130— conformance_output.diff_expected_errors has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (11 pts), loops 4 (5 pts), boolean chains 2 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
stub_coverage.collect (cognitive 18) tensor-shapes/stub_coverage.py:431— stub_coverage.collect has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (12 pts), loops 3, error handling 1 (2 pts), boolean chains 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Solutions::changed_exports::check_table (cognitive 17) pyrefly/lib/alt/answers.rs:1099— Solutions::changed_exports::check_table has cognitive complexity 17 (threshold 15). Drivers by points: if/else 5 (12 pts), loops 2, match/switch 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.
conformance_output.get_expected_errors (cognitive 17) conformance/conformance_output.py:71— conformance_output.get_expected_errors has cognitive complexity 17 (threshold 15). Drivers by points: if/else 5 (10 pts), loops 4 (6 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.
code-lens.runTestAtLocation (cognitive 17) lsp/src/code-lens.ts:245— code-lens.runTestAtLocation has cognitive complexity 17 (threshold 15). Drivers by points: if/else 11 (16 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.
whyPyreflyGridItem.WhyPyreflyGridItem (cognitive 17) website/src/components/landing-page/whyPyreflyGridItem.tsx:44— whyPyreflyGridItem.WhyPyreflyGridItem has cognitive complexity 17 (threshold 15). Drivers by points: boolean chains 10, ternaries 4, if/else 3. Most of this is not in the body itself: 2 of the 17 points are its own statements and the rest belongs to 3 function items inside it that branch (a function literal at line 86, handleClick, handleKeyDown). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
pyrefly_bundled::extract_files_from_archive (cognitive 16) crates/pyrefly_bundled/src/lib.rs:68— pyrefly_bundled::extract_files_from_archive has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (13 pts), boolean chains 2, loops 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Type::finalize_type_level_dsl_at_boundary (cognitive 16) crates/pyrefly_types/src/types.rs:1805— Type::finalize_type_level_dsl_at_boundary has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (8 pts), match/switch 4 (7 pts), loops 1 (nesting depth added 6). None of this is in the body itself: all 16 points belong to 3 function items inside it that branch (force_nested, collect_errors, force_nested::force_call). Those helpers are already separate functions, so extracting the branching again is not available. To reduce it, move them out of the body to the enclosing scope, where each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
AttrSubsetError::to_error_msg (cognitive 16) pyrefly/lib/alt/attr.rs:138— AttrSubsetError::to_error_msg has cognitive complexity 16 (threshold 15). Drivers by points: if/else 10 (15 pts), match/switch 1 (nesting depth added 5). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
CallArgPreEval::post_check (cognitive 16) pyrefly/lib/alt/callable.rs:717— CallArgPreEval::post_check has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (9 pts), match/switch 3 (5 pts), boolean chains 2 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Static::stmts (cognitive 16) pyrefly/lib/binding/scope.rs:523— Static::stmts has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (8 pts), loops 4 (5 pts), boolean chains 3 (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.
ShapeComments::new (cognitive 16) pyrefly/lib/binding/shape_comments.rs:129— ShapeComments::new has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (12 pts), loops 2, match/switch 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.
ErrorBuilder::with_error_details (cognitive 16) pyrefly/lib/error/collector.rs:738— ErrorBuilder::with_error_details has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (12 pts), loops 2 (4 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
view_types.format_type (cognitive 16) pyrefly/lib/report/cinderx/view_types.py:92— view_types.format_type has cognitive complexity 16 (threshold 15). Drivers by points: if/else 11 (16 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
stub_coverage.stub_exports (cognitive 16) tensor-shapes/stub_coverage.py:339— stub_coverage.stub_exports has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (11 pts), loops 2 (4 pts), ternaries 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
TooManyFunctions: pyrefly::lib::state::lsp::quick_fixes::extract_shared pyrefly/lib/state/lsp/quick_fixes/extract_shared.rs:40— TooManyFunctions — 33 free functions. The bar is 30 free functions; this is 3 over it, 1.10× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
Change-coupling hub: binding_memory.rs → class_metadata.rs, solve.rs, class_metadata.rs pyrefly/lib/report/binding_memory.rs— `pyrefly/lib/report/binding_memory.rs` changes together with 3 other files — `pyrefly/lib/alt/class/class_metadata.rs`, `pyrefly/lib/alt/solve.rs`, `pyrefly/lib/alt/types/class_metadata.rs` — none of which declares a dependency on it: one file is the hub of 3 separate couplings, not 3 unrelated pairs. Read the hub first: if the others each duplicate a part of what it does, the shared concern belongs in ONE unit and extracting it clears every edge at once; if the hub is a registry, dispatcher or barrel that must name each of them, the coupling is structural and the question is whether that list can be discovered instead of enumerated. Fixing the hub is one change; breaking the couplings one pair at a time is 3.
Near-duplicate member pair (26 shared lines) crates/pyrefly_types/src/type_level_dsl.rs:3642— crates/pyrefly_types/src/type_level_dsl.rs:3642-3702 | crates/pyrefly_types/src/type_level_dsl.rs:3777-3820 — These two members are variants of one another: 26 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication· Members sharing a duplicated core (4 members, 50+ identical tokens) · ×1
Members sharing a duplicated core (4 members, 50+ identical tokens) crates/pyrefly_lsp_test/src/object_model.rs:1008— crates/pyrefly_lsp_test/src/object_model.rs:1008-1031 | crates/pyrefly_lsp_test/src/object_model.rs:1038-1063 | crates/pyrefly_lsp_test/src/object_model.rs:1070-1103 | crates/pyrefly_lsp_test/src/object_model.rs:1111-1144 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
D4 · Code Duplication· Edited copy of a member (60 corresponding lines) · ×1
Edited copy of a member (60 corresponding lines) crates/pyrefly_types/src/types.rs:1030— crates/pyrefly_types/src/types.rs:1030-1089 | crates/pyrefly_types/src/types.rs:1093-1152 — These two members are one piece of code written twice and then edited apart: 60 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) crates/pyrefly_types/src/types.rs:1507— crates/pyrefly_types/src/types.rs:1507-1554 | crates/pyrefly_types/src/types.rs:1561-1608 — 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 copy of a member (72 corresponding lines) · ×1
Edited copy of a member (72 corresponding lines) pyrefly/lib/state/lsp/quick_fixes/change_signature.rs:363— pyrefly/lib/state/lsp/quick_fixes/change_signature.rs:363-434 | pyrefly/lib/state/lsp/quick_fixes/introduce_parameter.rs:489-571 — These two members are one piece of code written twice and then edited apart: 72 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (54 corresponding lines) · ×1
Edited copy of a member (54 corresponding lines) crates/pyrefly_types/src/types.rs:565— crates/pyrefly_types/src/types.rs:565-618 | pyrefly/lib/alt/function.rs:2907-2981 — These two members are one piece of code written twice and then edited apart: 54 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (52 corresponding lines) · ×1
Edited copy of a member (52 corresponding lines) pyrefly/lib/alt/solve.rs:6407— pyrefly/lib/alt/solve.rs:6407-6469 | pyrefly/lib/alt/solve.rs:6479-6530 — These two members are one piece of code written twice and then edited apart: 52 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (35 corresponding lines) · ×1
Edited copy of a member (35 corresponding lines) crates/pyrefly_types/src/type_level_dsl.rs:3521— crates/pyrefly_types/src/type_level_dsl.rs:3521-3565 | crates/pyrefly_types/src/type_level_dsl.rs:3571-3605 — These two members are one piece of code written twice and then edited apart: 35 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (65 corresponding lines) · ×1
Edited copy of a member (65 corresponding lines) crates/pyrefly_config/src/args.rs:492— crates/pyrefly_config/src/args.rs:492-556 | pyrefly/lib/commands/check.rs:530-611 — These two members are one piece of code written twice and then edited apart: 65 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (31 corresponding lines) · ×1
Edited copy of a member (31 corresponding lines) pyrefly/lib/report/pysa/capnp_writer.rs:386— pyrefly/lib/report/pysa/capnp_writer.rs:386-420 | pyrefly/lib/report/pysa/capnp_writer.rs:488-518 — These two members are one piece of code written twice and then edited apart: 31 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (40 corresponding lines) · ×1
Edited copy of a member (40 corresponding lines) pyrefly/lib/alt/function.rs:2690— pyrefly/lib/alt/function.rs:2690-2729 | pyrefly/lib/alt/function.rs:2737-2792 — These two members are one piece of code written twice and then edited apart: 40 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (33 corresponding lines) · ×1
Edited copy of a member (33 corresponding lines) pyrefly/lib/state/lsp/quick_fixes/move_module.rs:641— pyrefly/lib/state/lsp/quick_fixes/move_module.rs:641-673 | pyrefly/lib/state/lsp/quick_fixes/move_module.rs:679-711 — These two members are one piece of code written twice and then edited apart: 33 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (28 corresponding lines) · ×1
Edited copy of a member (28 corresponding lines) pyrefly/lib/alt/callable.rs:1030— pyrefly/lib/alt/callable.rs:1030-1057 | pyrefly/lib/alt/class/class_field.rs:2829-2859 — These two members are one piece of code written twice and then edited apart: 28 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copies of one member (4 members, 21+ corresponding lines) · ×1
Edited copies of one member (4 members, 21+ corresponding lines) pyrefly/lib/lsp/non_wasm/workspace.rs:730— pyrefly/lib/lsp/non_wasm/workspace.rs:730-750 | pyrefly/lib/lsp/non_wasm/workspace.rs:757-777 | pyrefly/lib/lsp/non_wasm/workspace.rs:784-804 | pyrefly/lib/lsp/non_wasm/workspace.rs:886-909 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 21 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 4 times and the copies will drift further apart.
D4 · Code Duplication· Edited copies of one member (3 members, 17+ corresponding lines) · ×1
Edited copies of one member (3 members, 17+ corresponding lines) pyrefly/lib/lsp/non_wasm/workspace.rs:811— pyrefly/lib/lsp/non_wasm/workspace.rs:811-827 | pyrefly/lib/lsp/non_wasm/workspace.rs:831-848 | pyrefly/lib/lsp/non_wasm/workspace.rs:856-872 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 17 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication· Edited copies of one member (5 members, 12+ corresponding lines) · ×1
Edited copies of one member (5 members, 12+ corresponding lines) crates/pyrefly_types/src/dimension.rs:584— crates/pyrefly_types/src/dimension.rs:584-596 | crates/pyrefly_types/src/dimension.rs:1449-1463 | crates/pyrefly_types/src/dimension.rs:1467-1481 | crates/pyrefly_types/src/dimension.rs:1622-1635 | crates/pyrefly_types/src/shaped_array.rs:765-776 — These 5 members are one piece of code written 5 times and then edited apart: every two of them correspond over at least 12 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 5 times and the copies will drift further apart.
D4 · Code Duplication· Edited copies of one member (5 members, 13+ corresponding lines) · ×1
Edited copies of one member (5 members, 13+ corresponding lines) pyrefly/lib/lsp/non_wasm/workspace.rs:645— pyrefly/lib/lsp/non_wasm/workspace.rs:645-657 | pyrefly/lib/lsp/non_wasm/workspace.rs:664-678 | pyrefly/lib/lsp/non_wasm/workspace.rs:680-692 | pyrefly/lib/lsp/non_wasm/workspace.rs:695-707 | pyrefly/lib/lsp/non_wasm/workspace.rs:710-722 — These 5 members are one piece of code written 5 times and then edited apart: every two of them correspond over at least 13 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 5 times and the copies will drift further apart.
D4 · Code Duplication· Edited copies of one member (5 members, 11+ corresponding lines) · ×1
Edited copies of one member (5 members, 11+ corresponding lines) pyrefly/lib/alt/class/class_field.rs:1013— pyrefly/lib/alt/class/class_field.rs:1013-1025 | pyrefly/lib/alt/class/class_field.rs:1057-1078 | pyrefly/lib/alt/class/class_field.rs:1212-1222 | pyrefly/lib/alt/class/class_field.rs:1245-1258 | pyrefly/lib/alt/class/class_field.rs:1308-1320 — These 5 members are one piece of code written 5 times and then edited apart: every two of them correspond over at least 11 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 5 times and the copies will drift further apart.
D4 · Code Duplication· Edited copies of one member (3 members, 15+ corresponding lines) · ×1
Edited copies of one member (3 members, 15+ corresponding lines) crates/pyrefly_types/src/dimension.rs:235— crates/pyrefly_types/src/dimension.rs:235-249 | crates/pyrefly_types/src/dimension.rs:290-304 | crates/pyrefly_types/src/dimension.rs:322-336 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 15 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication· Edited copies of one member (3 members, 12+ corresponding lines) · ×1
Edited copies of one member (3 members, 12+ corresponding lines) crates/pyrefly_lsp_test/src/object_model.rs:620— crates/pyrefly_lsp_test/src/object_model.rs:620-631 | crates/pyrefly_lsp_test/src/object_model.rs:639-653 | crates/pyrefly_lsp_test/src/object_model.rs:669-686 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 12 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication· Edited copies of one member (6 members, 11+ corresponding lines) · ×1
Edited copies of one member (6 members, 11+ corresponding lines) pyrefly/lib/alt/unwrap.rs:190— pyrefly/lib/alt/unwrap.rs:190-205 | pyrefly/lib/alt/unwrap.rs:298-308 | pyrefly/lib/alt/unwrap.rs:311-321 | pyrefly/lib/alt/unwrap.rs:346-356 | pyrefly/lib/alt/unwrap.rs:358-368 | pyrefly/lib/alt/unwrap.rs:370-380 — These 6 members are one piece of code written 6 times and then edited apart: every two of them correspond over at least 11 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 6 times and the copies will drift further apart.
D4 · Code Duplication· Edited copies of one member (5 members, 9+ corresponding lines) · ×1
Edited copies of one member (5 members, 9+ corresponding lines) crates/pyrefly_lsp_test/src/object_model.rs:484— crates/pyrefly_lsp_test/src/object_model.rs:484-494 | crates/pyrefly_lsp_test/src/object_model.rs:524-536 | crates/pyrefly_lsp_test/src/object_model.rs:710-718 | crates/pyrefly_lsp_test/src/object_model.rs:721-729 | crates/pyrefly_lsp_test/src/object_model.rs:732-740 — These 5 members are one piece of code written 5 times and then edited apart: every two of them correspond over at least 9 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 5 times and the copies will drift further apart.
D4 · Code Duplication· Edited copies of one member (3 members, 11+ corresponding lines) · ×1
Edited copies of one member (3 members, 11+ corresponding lines) crates/pyrefly_types/src/types.rs:2120— crates/pyrefly_types/src/types.rs:2120-2130 | crates/pyrefly_types/src/types.rs:2132-2142 | pyrefly/lib/alt/class/class_field.rs:6897-6907 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 11 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
Duplicated block (37–40 lines × 2) pyrefly/lib/lsp/non_wasm/document_symbols.rs:89— pyrefly/lib/lsp/non_wasm/document_symbols.rs:89-128 | pyrefly/lib/lsp/non_wasm/document_symbols.rs:143-179 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/lsp/non_wasm/document_symbols.rs:89` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (36 lines × 2) pyrefly/lib/state/lsp/quick_fixes/change_signature.rs:364— pyrefly/lib/state/lsp/quick_fixes/change_signature.rs:364-399 | pyrefly/lib/state/lsp/quick_fixes/introduce_parameter.rs:490-525 — before extracting anything, compare `pyrefly/lib/state/lsp/quick_fixes/change_signature.rs` and `pyrefly/lib/state/lsp/quick_fixes/introduce_parameter.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 62 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the 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 `pyrefly/lib/state/lsp/quick_fixes/change_signature.rs:364` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (31–33 lines × 2) pyrefly/lib/alt/narrow.rs:1776— pyrefly/lib/alt/narrow.rs:1776-1806 | pyrefly/lib/alt/narrow.rs:1857-1889 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/alt/narrow.rs:1776` it does not close everything it opens, so those exact lines 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–33 lines × 2) pyrefly/lib/lsp/non_wasm/server.rs:7125— pyrefly/lib/lsp/non_wasm/server.rs:7125-7157 | pyrefly/lib/lsp/non_wasm/server.rs:7282-7308 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/lsp/non_wasm/server.rs:7125` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `params` to `lsp_types::CallHierarchyPrepareParams` in one and `lsp_types::TypeHierarchyPrepareParams` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (22–23 lines × 2) pyrefly/lib/alt/solve.rs:4871— pyrefly/lib/alt/solve.rs:4871-4892 | pyrefly/lib/alt/solve.rs:4910-4932 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/alt/solve.rs:4910` it begins part-way through the construct above it, so those exact lines 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) crates/pyrefly_util/src/telemetry.rs:485— crates/pyrefly_util/src/telemetry.rs:485-504 | crates/pyrefly_util/src/telemetry.rs:520-540 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/pyrefly_util/src/telemetry.rs:520` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (21 lines × 2) pyrefly/lib/alt/class/class_field.rs:965— pyrefly/lib/alt/class/class_field.rs:965-985 | pyrefly/lib/alt/class/class_field.rs:987-1007 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/alt/class/class_field.rs:965` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (18–20 lines × 3) pyrefly/lib/alt/solve.rs:7297— pyrefly/lib/alt/solve.rs:7297-7316 | pyrefly/lib/alt/solve.rs:7330-7349 | pyrefly/lib/alt/solve.rs:7548-7565 — 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 `pyrefly/lib/alt/solve.rs:7297` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (18–19 lines × 2) crates/pyrefly_derive/src/type_eq.rs:31— crates/pyrefly_derive/src/type_eq.rs:31-49 | crates/pyrefly_derive/src/visit.rs:63-80 — 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. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (15–16 lines × 2) pyrefly/lib/alt/attr.rs:3424— pyrefly/lib/alt/attr.rs:3424-3438 | pyrefly/lib/alt/attr.rs:3441-3456 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/alt/attr.rs:3424` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (14–15 lines × 2) pyrefly/lib/alt/polars_specials.rs:3263— pyrefly/lib/alt/polars_specials.rs:3263-3276 | pyrefly/lib/alt/polars_specials.rs:3381-3395 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/alt/polars_specials.rs:3263` it does not close everything it opens, so those 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, `pyrefly/lib/alt/polars_specials.rs:3277` calls `Some`, `resolve_column` and `pyrefly/lib/alt/polars_specials.rs:3396` 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–13 lines × 3) pyrefly/lib/alt/function.rs:3084— pyrefly/lib/alt/function.rs:3084-3092 | pyrefly/lib/alt/function.rs:3136-3144 | pyrefly/lib/alt/function.rs:3181-3193 — 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 `pyrefly/lib/alt/function.rs:3084` it does not close everything it opens, so those 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, `pyrefly/lib/alt/function.rs:3147` calls `for_display`, `clone` and `pyrefly/lib/alt/function.rs:3095` 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–13 lines × 2) pyrefly/lib/alt/operators.rs:831— pyrefly/lib/alt/operators.rs:831-839 | pyrefly/lib/alt/operators.rs:1056-1068 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/alt/operators.rs:831` it does not close everything it opens, so those 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 (8–11 lines × 2) pyrefly/lib/alt/solve.rs:6435— pyrefly/lib/alt/solve.rs:6435-6445 | pyrefly/lib/alt/solve.rs:6499-6506 — both copies are in the same file, so extract the 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–11 lines × 2) pyrefly/lib/lsp/non_wasm/server.rs:3928— pyrefly/lib/lsp/non_wasm/server.rs:3928-3934 | pyrefly/lib/lsp/non_wasm/server.rs:3969-3979 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/lsp/non_wasm/server.rs:3969` it begins part-way through the construct above it, so those exact lines 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) crates/pyrefly_types/src/type_level_dsl.rs:7129— crates/pyrefly_types/src/type_level_dsl.rs:7129-7138 | crates/pyrefly_types/src/type_level_dsl.rs:7190-7199 | crates/pyrefly_types/src/type_level_dsl.rs:7326-7335 — 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 `crates/pyrefly_types/src/type_level_dsl.rs:7129` it begins part-way through the construct above it, so those exact lines 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–10 lines × 2) pyrefly/lib/binding/class.rs:1458— pyrefly/lib/binding/class.rs:1458-1467 | pyrefly/lib/binding/class.rs:1519-1524 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/binding/class.rs:1458` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (8–9 lines × 4) crates/pyrefly_lsp_test/src/object_model.rs:1012— crates/pyrefly_lsp_test/src/object_model.rs:1012-1019 | crates/pyrefly_lsp_test/src/object_model.rs:1042-1050 | crates/pyrefly_lsp_test/src/object_model.rs:1074-1081 | crates/pyrefly_lsp_test/src/object_model.rs:1115-1122 — 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 `crates/pyrefly_lsp_test/src/object_model.rs:1012` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (8–9 lines × 2) crates/pyrefly_types/src/type_level_dsl.rs:6601— crates/pyrefly_types/src/type_level_dsl.rs:6601-6609 | crates/pyrefly_types/src/type_level_dsl.rs:6613-6620 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/pyrefly_types/src/type_level_dsl.rs:6601` it begins part-way through the construct above it, so those exact lines 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–9 lines × 2) pyrefly/lib/solver/subset.rs:2740— pyrefly/lib/solver/subset.rs:2740-2748 | pyrefly/lib/solver/subset.rs:2753-2757 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/solver/subset.rs:2740` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (8 lines × 10) pyrefly/lib/lsp/non_wasm/server.rs:2501— pyrefly/lib/lsp/non_wasm/server.rs:2501-2508 | pyrefly/lib/lsp/non_wasm/server.rs:2576-2583 | pyrefly/lib/lsp/non_wasm/server.rs:2661-2668 | pyrefly/lib/lsp/non_wasm/server.rs:2696-2703 | pyrefly/lib/lsp/non_wasm/server.rs:2744-2751 | pyrefly/lib/lsp/non_wasm/server.rs:2759-2766 | pyrefly/lib/lsp/non_wasm/server.rs:2774-2781 | pyrefly/lib/lsp/non_wasm/server.rs:2878-2885 | pyrefly/lib/lsp/non_wasm/server.rs:2893-2900 | pyrefly/lib/lsp/non_wasm/server.rs:2938-2945 — 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 `pyrefly/lib/lsp/non_wasm/server.rs:2501` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8 lines × 6) pyrefly/lib/alt/narrow.rs:1649— pyrefly/lib/alt/narrow.rs:1649-1656 | pyrefly/lib/alt/narrow.rs:1671-1678 | pyrefly/lib/alt/narrow.rs:1693-1700 | pyrefly/lib/alt/narrow.rs:1706-1713 | pyrefly/lib/alt/narrow.rs:1722-1729 | pyrefly/lib/alt/narrow.rs:1738-1745 — 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 `pyrefly/lib/alt/narrow.rs:1649` it does not close everything it opens, so those exact lines 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) pyrefly/lib/alt/special_calls.rs:120— pyrefly/lib/alt/special_calls.rs:120-134 | pyrefly/lib/alt/special_calls.rs:283-297 | pyrefly/lib/alt/special_calls.rs:405-419 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `pyrefly/lib/alt/special_calls.rs:120` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (9 lines × 4) pyrefly/lib/report/pysa/call_graph.rs:3278— pyrefly/lib/report/pysa/call_graph.rs:3278-3286 | pyrefly/lib/report/pysa/call_graph.rs:3291-3299 | pyrefly/lib/report/pysa/call_graph.rs:3304-3312 | pyrefly/lib/report/pysa/call_graph.rs:3317-3325 — 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 `pyrefly/lib/report/pysa/call_graph.rs:3278` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (45–46 lines × 4) tensor-shapes/jax-pyrefly-stubs/run_pyrefly.py:30— tensor-shapes/jax-pyrefly-stubs/run_pyrefly.py:30-75 | tensor-shapes/pyrefly-einops-stubs/run_pyrefly.py:29-73 | tensor-shapes/pyrefly-numpy-stubs/run_pyrefly.py:29-74 | tensor-shapes/pyrefly-torch-stubs/run_pyrefly.py:29-74 — `tensor-shapes/jax-pyrefly-stubs/run_pyrefly.py` and `tensor-shapes/pyrefly-einops-stubs/run_pyrefly.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 2 separate duplicated blocks between them, totalling at least 61 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `tensor-shapes/jax-pyrefly-stubs/run_pyrefly.py:30` it does not close everything it opens, so those 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 (27–28 lines × 2) tensor-shapes/jax-pyrefly-stubs/suites.py:19— tensor-shapes/jax-pyrefly-stubs/suites.py:19-46 | tensor-shapes/pyrefly-numpy-stubs/suites.py:19-45 — `tensor-shapes/jax-pyrefly-stubs/suites.py` and `tensor-shapes/pyrefly-numpy-stubs/suites.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 1 separate duplicated blocks between them, totalling at least 28 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (14–16 lines × 3) crates/tsp_types/protocol_generator/generate_protocol.py:571— crates/tsp_types/protocol_generator/generate_protocol.py:571-584 | crates/tsp_types/protocol_generator/generate_protocol.py:585-598 | crates/tsp_types/protocol_generator/generate_protocol.py:737-752 — 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 (14–15 lines × 5) tensor-shapes/jax-pyrefly-stubs/run_pyrefly.py:64— tensor-shapes/jax-pyrefly-stubs/run_pyrefly.py:64-78 | tensor-shapes/microtorch/run_pyrefly.py:35-48 | tensor-shapes/pyrefly-einops-stubs/run_pyrefly.py:63-76 | tensor-shapes/pyrefly-numpy-stubs/run_pyrefly.py:63-77 | tensor-shapes/pyrefly-torch-stubs/run_pyrefly.py:63-77 — `tensor-shapes/jax-pyrefly-stubs/run_pyrefly.py` and `tensor-shapes/pyrefly-einops-stubs/run_pyrefly.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 2 separate duplicated blocks between them, totalling at least 61 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `tensor-shapes/jax-pyrefly-stubs/run_pyrefly.py:64` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `tensor-shapes/pyrefly-torch-stubs/run_pyrefly.py:78` calls `venv_site_packages`, `venv_python` and `tensor-shapes/microtorch/run_pyrefly.py:49` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication· Near-duplicate member family (5 members, 23 shared lines) · ×1
Near-duplicate member family (5 members, 23 shared lines) tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:276— tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:276-315 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations.py:276-315 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations_runnable.py:233-267 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var.py:256-295 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var_runnable.py:209-243 — These 5 members are variants of one another: a block of 23 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
Near-duplicate member pair (80 shared lines) tensor-shapes/pyrefly-torch-stubs/examples/openpose.py:56— tensor-shapes/pyrefly-torch-stubs/examples/openpose.py:56-270 | tensor-shapes/pyrefly-torch-stubs/examples/openpose.py:323-444 — These two members are variants of one another: 80 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication· Members sharing a duplicated core (6 members, 50+ identical tokens) · ×1
Members sharing a duplicated core (6 members, 50+ identical tokens) tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:96— tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:96-102 | tensor-shapes/pyrefly-torch-stubs/examples/mixtral_moe.py:182-188 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations.py:99-105 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations_runnable.py:103-109 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var.py:117-123 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var_runnable.py:107-113 — 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 copies of one member (5 members, 8+ corresponding lines) · ×1
Edited copies of one member (5 members, 8+ corresponding lines) tensor-shapes/pyrefly-torch-stubs/examples/background_matting.py:542— tensor-shapes/pyrefly-torch-stubs/examples/background_matting.py:542-550 | tensor-shapes/pyrefly-torch-stubs/examples/sam.py:1390-1398 | tensor-shapes/pyrefly-torch-stubs/examples/sam.py:1402-1409 | tensor-shapes/pyrefly-torch-stubs/examples/speech_transformer.py:460-467 | tensor-shapes/pyrefly-torch-stubs/examples/tacotron2.py:612-620 — These 5 members are one piece of code written 5 times and then edited apart: every two of them correspond over at least 8 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 5 times and the copies will drift further apart.
D4 · Code Duplication· Edited copies of one member (3 members, 6+ corresponding lines) · ×1
Edited copies of one member (3 members, 6+ corresponding lines) tensor-shapes/pyrefly-torch-stubs/examples/drq.py:132— tensor-shapes/pyrefly-torch-stubs/examples/drq.py:132-139 | tensor-shapes/pyrefly-torch-stubs/examples/soft_actor_critic.py:389-394 | tensor-shapes/pyrefly-torch-stubs/examples/soft_actor_critic.py:424-431 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 6 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication· Edited copies of one member (3 members, 14+ corresponding lines) · ×1
Edited copies of one member (3 members, 14+ corresponding lines) tensor-shapes/pyrefly-torch-stubs/examples/llama.py:450— tensor-shapes/pyrefly-torch-stubs/examples/llama.py:450-463 | tensor-shapes/pyrefly-torch-stubs/examples/llama.py:467-480 | tensor-shapes/pyrefly-torch-stubs/examples/llama.py:484-497 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 14 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication· Edited copies of one member (6 members, 6+ corresponding lines) · ×1
Edited copies of one member (6 members, 6+ corresponding lines) tensor-shapes/pyrefly-torch-stubs/examples/speech_transformer.py:535— tensor-shapes/pyrefly-torch-stubs/examples/speech_transformer.py:535-540 | tensor-shapes/pyrefly-torch-stubs/examples/super_slomo.py:362-367 | tensor-shapes/pyrefly-torch-stubs/examples/super_slomo.py:371-376 | tensor-shapes/pyrefly-torch-stubs/examples/super_slomo.py:396-406 | tensor-shapes/pyrefly-torch-stubs/examples/unet.py:330-335 | tensor-shapes/pyrefly-torch-stubs/examples/unet.py:339-344 — 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, 6+ corresponding lines) · ×1
Edited copies of one member (4 members, 6+ corresponding lines) tensor-shapes/pyrefly-torch-stubs/examples/mixtral_moe.py:494— tensor-shapes/pyrefly-torch-stubs/examples/mixtral_moe.py:494-499 | tensor-shapes/pyrefly-torch-stubs/examples/mixtral_moe.py:503-508 | tensor-shapes/pyrefly-torch-stubs/examples/sam.py:1380-1386 | tensor-shapes/pyrefly-torch-stubs/examples/speech_transformer.py:479-484 — These 4 members are one piece of code written 4 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 4 times and the copies will drift further apart.
D4 · Code Duplication· Edited copies of one member (3 members, 7+ corresponding lines) · ×1
Edited copies of one member (3 members, 7+ corresponding lines) tensor-shapes/pyrefly-torch-stubs/examples/soft_actor_critic.py:192— tensor-shapes/pyrefly-torch-stubs/examples/soft_actor_critic.py:192-199 | tensor-shapes/pyrefly-torch-stubs/examples/soft_actor_critic.py:223-230 | tensor-shapes/pyrefly-torch-stubs/examples/soft_actor_critic.py:249-255 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 7 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication· Edited copy of a member (3 corresponding lines) · ×1
Edited copy of a member (3 corresponding lines) tensor-shapes/jax-pyrefly-stubs/examples/nanogpt.py:87— tensor-shapes/jax-pyrefly-stubs/examples/nanogpt.py:87-92 | tensor-shapes/jax-pyrefly-stubs/examples/bert.py:83-85 — These two members are one piece of code written twice and then edited apart: 3 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copies of one member (3 members, 4+ corresponding lines) · ×1
Edited copies of one member (3 members, 4+ corresponding lines) tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:362— tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:362-365 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations.py:365-368 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var.py:378-381 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 4 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
Duplicated block (58 lines × 5) tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:406— tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:406-463 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations.py:406-463 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations_runnable.py:346-403 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var.py:387-444 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var_runnable.py:323-380 — before extracting anything, compare `tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py` and `tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 392 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (45 lines × 2) tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations_runnable.py:103— tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations_runnable.py:103-147 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var_runnable.py:98-142 — before extracting anything, compare `tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations_runnable.py` and `tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var_runnable.py` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 288 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (44 lines × 3) tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:346— tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:346-389 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations.py:346-389 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var.py:327-370 — before extracting anything, compare `tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py` and `tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 392 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (75 lines × 3) tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:106— tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:106-180 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations.py:106-180 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var.py:105-179 — before extracting anything, compare `tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py` and `tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 392 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 `tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:106` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. 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) tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations_runnable.py:298— tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations_runnable.py:298-329 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var_runnable.py:275-306 — before extracting anything, compare `tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations_runnable.py` and `tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var_runnable.py` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 288 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (36 lines × 3) tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:523— tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:523-558 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations.py:523-558 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var.py:504-539 — before extracting anything, compare `tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py` and `tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 392 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (21 lines × 5) tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:229— tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:229-249 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations.py:232-252 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations_runnable.py:236-256 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var.py:250-270 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var_runnable.py:240-260 — before extracting anything, compare `tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py` and `tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations.py` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 247 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (18 lines × 5) tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:106— tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:106-123 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations.py:109-126 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations_runnable.py:113-130 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var.py:127-144 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var_runnable.py:117-134 — before extracting anything, compare `tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py` and `tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations.py` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 247 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 (17 lines × 5) tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:84— tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:84-100 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations.py:84-100 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations_runnable.py:82-98 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var.py:85-101 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var_runnable.py:79-95 — before extracting anything, compare `tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py` and `tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 392 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:101` calls `assert_type` and `tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations_runnable.py:100` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (15 lines × 5) tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:276— tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:276-290 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations.py:276-290 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations_runnable.py:233-247 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var.py:256-270 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var_runnable.py:209-223 — before extracting anything, compare `tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py` and `tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 392 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (13–15 lines × 2) scripts/github_utils.py:725— scripts/github_utils.py:725-739 | scripts/github_utils.py:834-846 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `scripts/github_utils.py:725` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (14 lines × 5) tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:500— tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:500-513 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations.py:500-513 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations_runnable.py:440-453 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var.py:481-494 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var_runnable.py:417-430 — before extracting anything, compare `tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py` and `tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 392 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (18–22 lines × 3) tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:470— tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:470-487 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations.py:473-494 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var.py:482-503 — before extracting anything, compare `tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py` and `tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations.py` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 247 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 `tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:470` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (8–13 lines × 2) tensor-shapes/pyrefly-torch-stubs/examples/drq.py:400— tensor-shapes/pyrefly-torch-stubs/examples/drq.py:400-407 | tensor-shapes/pyrefly-torch-stubs/examples/drq.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.
Duplicated block (9–10 lines × 3) scripts/github_utils.py:444— scripts/github_utils.py:444-453 | scripts/github_utils.py:465-474 | scripts/github_utils.py:486-494 — 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 (42 lines × 3) tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:411— tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:411-452 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations.py:414-455 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var.py:428-469 — before extracting anything, compare `tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py` and `tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations.py` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 247 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 `tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:411` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (7 lines × 6) tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:96— tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:96-102 | tensor-shapes/pyrefly-torch-stubs/examples/mixtral_moe.py:182-188 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations.py:99-105 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations_runnable.py:103-109 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var.py:117-123 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var_runnable.py:107-113 — before extracting anything, compare `tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py` and `tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations.py` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 247 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (7 lines × 5) tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:285— tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:285-291 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations.py:288-294 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations_runnable.py:285-291 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var.py:306-312 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var_runnable.py:289-295 — before extracting anything, compare `tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py` and `tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations.py` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 247 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:292` calls `assert_type` and `tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations_runnable.py:293` 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 (4–5 lines × 25) tensor-shapes/pyrefly-torch-stubs/examples/openpose.py:60— tensor-shapes/pyrefly-torch-stubs/examples/openpose.py:60-63 | tensor-shapes/pyrefly-torch-stubs/examples/openpose.py:64-67 | tensor-shapes/pyrefly-torch-stubs/examples/openpose.py:71-75 | tensor-shapes/pyrefly-torch-stubs/examples/openpose.py:80-84 | tensor-shapes/pyrefly-torch-stubs/examples/openpose.py:92-96 | tensor-shapes/pyrefly-torch-stubs/examples/openpose.py:105-109 | tensor-shapes/pyrefly-torch-stubs/examples/openpose.py:118-122 | tensor-shapes/pyrefly-torch-stubs/examples/openpose.py:133-137 | tensor-shapes/pyrefly-torch-stubs/examples/openpose.py:148-152 | tensor-shapes/pyrefly-torch-stubs/examples/openpose.py:163-167 | tensor-shapes/pyrefly-torch-stubs/examples/openpose.py:178-182 | tensor-shapes/pyrefly-torch-stubs/examples/openpose.py:195-199 | tensor-shapes/pyrefly-torch-stubs/examples/openpose.py:210-214 | tensor-shapes/pyrefly-torch-stubs/examples/openpose.py:225-229 | tensor-shapes/pyrefly-torch-stubs/examples/openpose.py:240-244 | tensor-shapes/pyrefly-torch-stubs/examples/openpose.py:257-261 | tensor-shapes/pyrefly-torch-stubs/examples/openpose.py:327-330 | tensor-shapes/pyrefly-torch-stubs/examples/openpose.py:331-334 | tensor-shapes/pyrefly-torch-stubs/examples/openpose.py:338-342 | tensor-shapes/pyrefly-torch-stubs/examples/openpose.py:347-351 | tensor-shapes/pyrefly-torch-stubs/examples/openpose.py:372-376 | tensor-shapes/pyrefly-torch-stubs/examples/openpose.py:387-391 | tensor-shapes/pyrefly-torch-stubs/examples/openpose.py:402-406 | tensor-shapes/pyrefly-torch-stubs/examples/openpose.py:417-421 | tensor-shapes/pyrefly-torch-stubs/examples/openpose.py:432-436 — all 25 copies are in the same file, so extract the block into one function there and call 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, `tensor-shapes/pyrefly-torch-stubs/examples/openpose.py:64` calls `MaxPool2d` and `tensor-shapes/pyrefly-torch-stubs/examples/openpose.py:85` 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 × 16) tensor-shapes/pyrefly-torch-stubs/examples/openpose.py:96— tensor-shapes/pyrefly-torch-stubs/examples/openpose.py:96-100 | tensor-shapes/pyrefly-torch-stubs/examples/openpose.py:109-113 | tensor-shapes/pyrefly-torch-stubs/examples/openpose.py:126-130 | tensor-shapes/pyrefly-torch-stubs/examples/openpose.py:141-145 | tensor-shapes/pyrefly-torch-stubs/examples/openpose.py:156-160 | tensor-shapes/pyrefly-torch-stubs/examples/openpose.py:171-175 | tensor-shapes/pyrefly-torch-stubs/examples/openpose.py:186-190 | tensor-shapes/pyrefly-torch-stubs/examples/openpose.py:203-207 | tensor-shapes/pyrefly-torch-stubs/examples/openpose.py:218-222 | tensor-shapes/pyrefly-torch-stubs/examples/openpose.py:233-237 | tensor-shapes/pyrefly-torch-stubs/examples/openpose.py:248-252 | tensor-shapes/pyrefly-torch-stubs/examples/openpose.py:380-384 | tensor-shapes/pyrefly-torch-stubs/examples/openpose.py:395-399 | tensor-shapes/pyrefly-torch-stubs/examples/openpose.py:410-414 | tensor-shapes/pyrefly-torch-stubs/examples/openpose.py:425-429 | tensor-shapes/pyrefly-torch-stubs/examples/openpose.py:440-444 — 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 `tensor-shapes/pyrefly-torch-stubs/examples/openpose.py:96` it begins part-way through the construct above it, so those exact lines 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 × 5) tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:334— tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:334-339 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations.py:334-339 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations_runnable.py:286-291 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var.py:315-320 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var_runnable.py:263-268 — before extracting anything, compare `tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py` and `tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 392 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (5 lines × 6) tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:398— tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:398-402 | tensor-shapes/pyrefly-torch-stubs/examples/mixtral_moe.py:267-271 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations.py:401-405 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations_runnable.py:388-392 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var.py:415-419 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var_runnable.py:388-392 — before extracting anything, compare `tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py` and `tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations.py` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 247 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (10 lines × 5) tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:322— tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:322-331 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations.py:322-331 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations_runnable.py:274-283 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var.py:302-311 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var_runnable.py:250-259 — before extracting anything, compare `tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py` and `tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations.py` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 392 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (5 lines × 7) tensor-shapes/pyrefly-torch-stubs/examples/demucs.py:397— tensor-shapes/pyrefly-torch-stubs/examples/demucs.py:397-404 | tensor-shapes/pyrefly-torch-stubs/examples/demucs.py:408-415 | tensor-shapes/pyrefly-torch-stubs/examples/demucs.py:419-426 | tensor-shapes/pyrefly-torch-stubs/examples/demucs.py:430-437 | tensor-shapes/pyrefly-torch-stubs/examples/demucs.py:441-448 | tensor-shapes/pyrefly-torch-stubs/examples/demucs.py:452-459 | tensor-shapes/pyrefly-torch-stubs/examples/sam.py:1311-1315 — there are 7 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 7 sites; resolving a subset leaves the remainder to drift apart.
Duplicated block (5 lines × 4) tensor-shapes/pyrefly-torch-stubs/examples/drq.py:524— tensor-shapes/pyrefly-torch-stubs/examples/drq.py:524-528 | tensor-shapes/pyrefly-torch-stubs/examples/drq.py:532-536 | tensor-shapes/pyrefly-torch-stubs/examples/soft_actor_critic.py:525-529 | tensor-shapes/pyrefly-torch-stubs/examples/soft_actor_critic.py:533-537 — there are 4 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart.
R10 · Code Duplication· Duplicated block with local edits (19 matched lines × 2 locations) · ×1
Duplicated block with local edits (19 matched lines × 2 locations) lsp/src/extension.ts:148— lsp/src/extension.ts:148 · lsp/src/extension.ts:443 — the two spans are one implementation copied and then locally edited — 91 tokens are still identical, in the same order in both spans, with only local edits between them. The copies have already begun to drift, which is this row's finding: an edit made to one and not the other changes behaviour silently. Diff the two spans first to learn what genuinely differs, then extract the shared core into one module both sites use, passing the differences in as parameters — or, if one copy exists only because the other could not be imported from its context, make one of them the single source the other is generated or re-exported from. If one copy is no longer reachable, delete it rather than letting it shadow the live one.
R10 · Code Duplication· Duplicated block with local edits (16 matched lines × 2 locations) · ×1
Duplicated block with local edits (16 matched lines × 2 locations) lsp/src/code-lens.ts:219— lsp/src/code-lens.ts:219 · lsp/src/code-lens.ts:246 — the two spans are one implementation copied and then locally edited — 62 tokens are still identical, in the same order in both spans, with only local edits between them. The copies have already begun to drift, which is this row's finding: an edit made to one and not the other changes behaviour silently. Diff the two spans first to learn what genuinely differs, then extract the shared core into one module both sites use, passing the differences in as parameters — or, if one copy exists only because the other could not be imported from its context, make one of them the single source the other is generated or re-exported from. If one copy is no longer reachable, delete it rather than letting it shadow the live one.
Duplicated block (10 lines × 2 locations) lsp/src/code-lens.ts:53— lsp/src/code-lens.ts:53 · lsp/src/code-lens.ts:64 — all 2 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported.
Complex function provideCodeLenses (cyclomatic 22, cognitive 26) lsp/src/overrideCodeLens.ts:144— provideCodeLenses has cyclomatic complexity 22 and cognitive complexity 26; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function runTestAtLocation (cyclomatic 14, cognitive 17) lsp/src/code-lens.ts:245— runTestAtLocation has cyclomatic complexity 14 and cognitive complexity 17; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function updateStatusBar (cyclomatic 13, cognitive 13) lsp/src/status-bar.ts:57— updateStatusBar has cyclomatic complexity 13 and cognitive complexity 13; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function selectBinary (cyclomatic 11, cognitive 11) lsp/src/lsp-path.ts:120— selectBinary has cyclomatic complexity 11 and cognitive complexity 11; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
lsp/src/extension.ts: 631 lines of code lsp/src/extension.ts:1— lsp/src/extension.ts has 631 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
Unused dependency '@vscode/test-electron' — Declared in lsp/package.json but never imported anywhere in that package or its workspace members — no static import reaches it. Usually that is dead weight and attack surface, but two shapes are indistinguishable from source and are NOT dead: an optional or native peer that another dependency loads dynamically at runtime, and a package a build, docs or test step installs and invokes separately. Confirm which of the three this is before removing it.
Unused dependency 'serialize-javascript' — Declared in lsp/package.json but never imported anywhere in that package or its workspace members — no static import reaches it. Usually that is dead weight and attack surface, but two shapes are indistinguishable from source and are NOT dead: an optional or native peer that another dependency loads dynamically at runtime, and a package a build, docs or test step installs and invokes separately. Confirm which of the three this is before removing it.
Unused dependency 'underscore' — Declared in lsp/package.json but never imported anywhere in that package or its workspace members — no static import reaches it. Usually that is dead weight and attack surface, but two shapes are indistinguishable from source and are NOT dead: an optional or native peer that another dependency loads dynamically at runtime, and a package a build, docs or test step installs and invokes separately. Confirm which of the three this is before removing it.
X2 · Cancellation propagation· Async function without AbortSignal · ×1
Async function without AbortSignal: compile pyrefly_wasm/pyrefly_wasm.js:344— `compile` awaits `fetch(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `fetch(url, { signal })`.
Interpolated log message defeats structured logging REDACTED:57— `info` at line 57 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog.
Interpolated log message defeats structured logging REDACTED:90— `info` at line 90 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog.
Interpolated log message defeats structured logging conformance/conformance_output.py:318— `error` at line 318 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.error("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.error("order moved", order_id=order_id, status=status)` with structlog.
Interpolated log message defeats structured logging conformance/conformance_output.py:333— `error` at line 333 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.error("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.error("order moved", order_id=order_id, status=status)` with structlog.
Interpolated log message defeats structured logging pyrefly/lib/tsp/server.rs:193— `warn!` at line 193 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
Interpolated log message defeats structured logging pyrefly/lib/tsp/server.rs:226— `warn!` at line 226 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
Interpolated log message defeats structured logging pyrefly/lib/tsp/server.rs:734— `info!` at line 734 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `info!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
Interpolated log message defeats structured logging pyrefly/lib/state/state.rs:1729— `debug!` at line 1729 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
Interpolated log message defeats structured logging pyrefly/lib/state/state.rs:2326— `debug!` at line 2326 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
Interpolated log message defeats structured logging pyrefly/lib/state/state.rs:2769— `info!` at line 2769 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `info!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
Interpolated log message defeats structured logging pyrefly/lib/state/state.rs:3440— `debug!` at line 3440 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
Interpolated log message defeats structured logging pyrefly/lib/report/pysa.rs:232— `debug!` at line 232 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
Interpolated log message defeats structured logging pyrefly/lib/report/scip.rs:191— `error!` at line 191 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `error!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
Interpolated log message defeats structured logging pyrefly/lib/report/pysa/step_logger.rs:17— `debug!` at line 17 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
Interpolated log message defeats structured logging pyrefly/lib/report/pysa/step_logger.rs:25— `debug!` at line 25 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
Interpolated log message defeats structured logging pyrefly/lib/module/typeshed.rs:271— `debug!` at line 271 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
Interpolated log message defeats structured logging pyrefly/lib/module/typeshed.rs:274— `debug!` at line 274 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
Interpolated log message defeats structured logging pyrefly/lib/module/typeshed.rs:294— `warn!` at line 294 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
Interpolated log message defeats structured logging pyrefly/lib/lsp/module_helpers.rs:44— `warn!` at line 44 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
Interpolated log message defeats structured logging pyrefly/lib/lsp/module_helpers.rs:56— `warn!` at line 56 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
Interpolated log message defeats structured logging pyrefly/lib/lsp/module_helpers.rs:68— `warn!` at line 68 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
Interpolated log message defeats structured logging pyrefly/lib/lsp/non_wasm/call_hierarchy.rs:260— `debug!` at line 260 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
Interpolated log message defeats structured logging pyrefly/lib/lsp/non_wasm/call_hierarchy.rs:264— `debug!` at line 264 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
Interpolated log message defeats structured logging pyrefly/lib/lsp/non_wasm/initial_configuration.rs:109— `warn!` at line 109 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
Interpolated log message defeats structured logging pyrefly/lib/lsp/non_wasm/initial_configuration.rs:145— `info!` at line 145 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `info!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
Duplicated predicate tensor-shapes/jax-pyrefly-stubs/jax-stubs/_shapes.pyi:186— `axis < 0 - len(shape) or axis >= len(shape)` appears character-identically in 2 files — tensor-shapes/jax-pyrefly-stubs/jax-stubs/_shapes.pyi, tensor-shapes/pyrefly-numpy-stubs/numpy-stubs/_shapes.pyi. 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 tensor-shapes/jax-pyrefly-stubs/jax-stubs/_shapes.pyi:1437— `axis1 < 0 - rank or axis1 >= rank or axis2 < 0 - rank or axis2 >= rank` appears character-identically in 2 files — tensor-shapes/jax-pyrefly-stubs/jax-stubs/_shapes.pyi, tensor-shapes/pyrefly-numpy-stubs/numpy-stubs/_shapes.pyi. 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 tensor-shapes/jax-pyrefly-stubs/jax-stubs/_shapes.pyi:1469— `destination < 0 - rank or destination >= rank` appears character-identically in 2 files — tensor-shapes/jax-pyrefly-stubs/jax-stubs/_shapes.pyi, tensor-shapes/pyrefly-torch-stubs/torch-stubs/_shapes.pyi. 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 tensor-shapes/jax-pyrefly-stubs/jax-stubs/_shapes.pyi:20— `dsl.is_concrete_int(a) and dsl.is_concrete_int(b)` appears character-identically in 2 files — tensor-shapes/jax-pyrefly-stubs/jax-stubs/_shapes.pyi, tensor-shapes/pyrefly-numpy-stubs/numpy-stubs/_shapes.pyi. 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 tensor-shapes/pyrefly-numpy-stubs/numpy-stubs/_shapes.pyi:413— `dsl.is_concrete_int(dimension) and dimension < -1` appears character-identically in 2 files — tensor-shapes/pyrefly-numpy-stubs/numpy-stubs/_shapes.pyi, tensor-shapes/pyrefly-torch-stubs/torch-stubs/_shapes.pyi. 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 tensor-shapes/pyrefly-numpy-stubs/numpy-stubs/_shapes.pyi:408— `dsl.is_concrete_int(dimension) and dimension == -1` appears character-identically in 2 files — tensor-shapes/pyrefly-numpy-stubs/numpy-stubs/_shapes.pyi, tensor-shapes/pyrefly-torch-stubs/torch-stubs/_shapes.pyi. 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 tensor-shapes/jax-pyrefly-stubs/jax-stubs/_shapes.pyi:2368— `dsl.is_concrete_int(extent) and extent % 2 != 0` appears character-identically in 2 files — tensor-shapes/jax-pyrefly-stubs/jax-stubs/_shapes.pyi, tensor-shapes/pyrefly-torch-stubs/torch-stubs/_shapes.pyi. 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 tensor-shapes/jax-pyrefly-stubs/jax-stubs/_shapes.pyi:452— `dsl.is_concrete_int(repeats) and repeats < 0` appears character-identically in 2 files — tensor-shapes/jax-pyrefly-stubs/jax-stubs/_shapes.pyi, tensor-shapes/pyrefly-numpy-stubs/numpy-stubs/_shapes.pyi. 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 tensor-shapes/jax-pyrefly-stubs/jax-stubs/_shapes.pyi:397— `dsl.is_concrete_int(total) and dsl.is_concrete_int(known) and total != known` appears character-identically in 3 files — tensor-shapes/jax-pyrefly-stubs/jax-stubs/_shapes.pyi, tensor-shapes/pyrefly-numpy-stubs/numpy-stubs/_shapes.pyi, tensor-shapes/pyrefly-torch-stubs/torch-stubs/_shapes.pyi. 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 tensor-shapes/jax-pyrefly-stubs/jax-stubs/_shapes.pyi:403— `dsl.is_concrete_int(total) and total % known != 0` appears character-identically in 3 files — tensor-shapes/jax-pyrefly-stubs/jax-stubs/_shapes.pyi, tensor-shapes/pyrefly-numpy-stubs/numpy-stubs/_shapes.pyi, tensor-shapes/pyrefly-torch-stubs/torch-stubs/_shapes.pyi. 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 tensor-shapes/jax-pyrefly-stubs/jax-stubs/_shapes.pyi:425— `dsl.is_concrete_int(value) and value < 0` appears character-identically in 2 files — tensor-shapes/jax-pyrefly-stubs/jax-stubs/_shapes.pyi, tensor-shapes/pyrefly-numpy-stubs/numpy-stubs/_shapes.pyi. 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 tensor-shapes/jax-pyrefly-stubs/jax-stubs/_shapes.pyi:247— `item < 0 - len(shape) or item >= len(shape)` appears character-identically in 3 files — tensor-shapes/jax-pyrefly-stubs/jax-stubs/_shapes.pyi, tensor-shapes/pyrefly-numpy-stubs/numpy-stubs/_shapes.pyi, tensor-shapes/pyrefly-torch-stubs/torch-stubs/_shapes.pyi. 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 pyrefly/lib/state/lsp/quick_fixes/inline_method.rs:75— `!function_def.parameters.posonlyargs.is_empty() || !function_def.parameters.kwonlyargs.is_empty() || function_def.parameters.vararg.is_some(…` appears character-identically in 2 files — pyrefly/lib/state/lsp/quick_fixes/inline_method.rs, pyrefly/lib/state/lsp/quick_fixes/inline_parameter.rs. 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 pyrefly/lib/alt/map_int_tuples.rs:332— `!prefix.is_empty() || !suffix.is_empty()` appears character-identically in 2 files — pyrefly/lib/alt/map_int_tuples.rs, pyrefly/lib/solver/subset.rs. 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 crates/pyrefly_config/src/error_kind.rs:768— `!self.is_directive() && !self.is_unused_ignore()` appears character-identically in 2 files — crates/pyrefly_config/src/error_kind.rs, pyrefly/lib/error/suppress.rs. 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 pyrefly/lib/alt/expr.rs:2772— `!self.is_subclassable(cls) && self.class_instances_always_truthy(cls)` appears character-identically in 2 files — pyrefly/lib/alt/expr.rs, pyrefly/lib/alt/solve.rs. 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 pyrefly/lib/alt/nn_module_specials.rs:106— `base.is(KnownClass::TorchModule) || base.is(KnownClass::TorchModulesModule)` appears character-identically in 2 files — pyrefly/lib/alt/nn_module_specials.rs, pyrefly/lib/state/lsp.rs. 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 crates/pyrefly_types/src/type_level_dsl.rs:2850— `call.arguments.args.len() != 1 || !call.arguments.keywords.is_empty() || matches!(call.arguments.args.first(), Some(Expr::Starred(_)))` appears character-identically in 2 files — crates/pyrefly_types/src/type_level_dsl.rs, pyrefly/lib/alt/expr.rs. 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 pyrefly/lib/alt/call.rs:3246— `cls.is(KnownClass::NotImplementedType) || cls.is(KnownClass::TypesNotImplementedType)` appears character-identically in 3 files — pyrefly/lib/alt/call.rs, pyrefly/lib/alt/operators.rs, pyrefly/lib/alt/solve.rs. 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 pyrefly/lib/state/lsp/quick_fixes/change_signature.rs:374— `def.module.path() == module_info.path() && def .definition_range .contains_range(function_ctx.function_def.name.range)` appears character-identically in 2 files — pyrefly/lib/state/lsp/quick_fixes/change_signature.rs, pyrefly/lib/state/lsp/quick_fixes/introduce_parameter.rs. 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 pyrefly/lib/state/lsp/quick_fixes/extract_field.rs:180— `expr && matches!(name.ctx, ExprContext::Load)` appears character-identically in 2 files — pyrefly/lib/state/lsp/quick_fixes/extract_field.rs, pyrefly/lib/state/lsp/quick_fixes/introduce_parameter.rs. 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 pyrefly/lib/alt/class/attrs.rs:186— `id.qname.module_name() == ModuleName::attr() || id.qname.module_name() == ModuleName::attrs()` appears character-identically in 2 files — pyrefly/lib/alt/class/attrs.rs, pyrefly/lib/alt/class/class_field.rs. 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 pyrefly/lib/binding/scope.rs:3835— `method.recognized_attribute_defining_method && matches!(method.instance_or_class, MethodSelfKind::Instance)` appears character-identically in 2 files — pyrefly/lib/binding/scope.rs, pyrefly/lib/binding/target.rs. 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 crates/pyrefly_types/src/display.rs:472— `prefix.is_empty() && suffix.is_empty() && is_tuple_carrier_shape_middle(middle)` appears character-identically in 3 files — crates/pyrefly_types/src/display.rs, crates/pyrefly_types/src/shaped_array.rs, pyrefly/lib/solver/subset.rs. 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 pyrefly/lib/lsp/wasm/inlay_hints.rs:569— `x && call.func.range().contains_inclusive(find)` appears character-identically in 2 files — pyrefly/lib/lsp/wasm/inlay_hints.rs, pyrefly/lib/state/lsp.rs. 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.
redundant comment REDACTED:54— "Initialize sandbox files with main.py" repeats the code it sits on: 4 of its 5 words (sandbox, files, main, py) are already in `pyreService.updateSandboxFiles(`. Delete it, or replace it with what the code cannot say (why it is done here, a constraint, or a consequence).
redundant comment REDACTED:79— "Find the reveal_type error" repeats the code it sits on: 4 of its 4 words (find, reveal, type, error) are already in `const revealTypeError = findError(errors, 'revealed type:');`. Delete it, or replace it with what the code cannot say (why it is done here, a constraint, or a consequence).
redundant comment REDACTED:213— "Set active file to main.py" repeats the code it sits on: 5 of its 5 words (set, active, file, main, py) are already in `pyreService.setActiveFile('main.py');`. Delete it, or replace it with what the code cannot say (why it is done here, a constraint, or a consequence).
redundant comment website/static/js/dark-mode-favicon.js:15— "Get the baseUrl from Docusaurus" repeats the code it sits on: 4 of its 4 words (get, base, url, docusaurus) are already in `const baseUrl =`. Delete it, or replace it with what the code cannot say (why it is done here, a constraint, or a consequence).
Silent fallback default on Err pyrefly/lib/binding/narrow.rs:751— `rebase_facet_subject` (in `rebase_onto_subject`) turns every `Err` into `Some(None)` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or propagate it with `?`. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the arm or in the doc comment, and the row stops firing.
Silent fallback default on Err pyrefly/lib/test/lsp/call_hierarchy.rs:56— `get_callers_report` turns every `Err` into `"Callers Result: Cancelled".to_owned()` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or propagate it with `?`. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the arm or in the doc comment, and the row stops firing.
Silent fallback default on Err pyrefly/lib/test/lsp/call_hierarchy.rs:84— `get_callees_report` turns every `Err` into `"Callees Result: Cancelled".to_owned()` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or propagate it with `?`. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the arm or in the doc comment, and the row stops firing.
Silent fallback default on Err pyrefly/lib/test/lsp/implementation.rs:44— `get_implementations_report` turns every `Err` into `"Implementation Result: Cancelled".to_owned()` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or propagate it with `?`. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the arm or in the doc comment, and the row stops firing.
Off-boarding risk: anonymized user #1 — If anonymized user #1 becomes unavailable, 15 significant file(s) lose their only recent owner: crates/pyrefly_types/src/type_level_dsl.rs, pyrefly/lib/alt/type_level_dsl.rs, crates/pyrefly_types/src/einops.rs, crates/pyrefly_types/src/einsum.rs, tensor-shapes/pyrefly-shape-extensions/shape_extensions/__init__.py, tensor-shapes/stub_coverage.py, pyrefly/lib/alt/shape_flag.rs, pyrefly/lib/report/cinderx.rs (+7 more). Pair on, review, or document these before any departure.
Off-boarding risk: anonymized user #2 — If anonymized user #2 becomes unavailable, 9 significant file(s) lose their only recent owner: pyrefly/lib/lsp/non_wasm/connection.rs, pyrefly/lib/export/symbols.rs, pyrefly/lib/lsp/non_wasm/initial_configuration.rs, crates/pyrefly_config/src/environment/interpreter_query.rs, crates/pyrefly_bench_harness/src/lib.rs, lsp/src/python-environment.ts, pyrefly/lib/memory_project.rs, crates/pyrefly_util/src/timer.rs (+1 more). Pair on, review, or document these before any departure.
Off-boarding risk: anonymized user #3 — If anonymized user #3 becomes unavailable, 5 significant file(s) lose their only recent owner: crates/pyrefly_util/src/visit.rs, crates/pyrefly_util/src/watcher.rs, crates/pyrefly_derive/src/visit.rs, crates/pyrefly_derive/src/type_eq.rs, crates/pyrefly_graph/src/index.rs. Pair on, review, or document these before any departure.
Orphaned file crates/pyrefly_config/src/migration/mypy/regex_converter.rs:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file crates/pyrefly_python/src/comment_section.rs:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
D16 · Bus Factor· Further sole-owners (lower concentration) · ×1
Further sole-owners (lower concentration) — 8 other contributor(s) are each the sole owner of a small amount of code below the off-boarding threshold — folded into the bus-factor score and metrics (42 single-owned of 418 analysed files in total, counted over production source files of roughly 2,400 bytes or more, excluding vendored, generated, example/demo and scaffolding-template trees and test files identified by path convention, largest first; 418 of the 577 production source files in this repository met that bar). They are anonymized user #4 (2 file(s)), anonymized user #5 (2 file(s)), anonymized user #6 (2 file(s)), anonymized user #7 (2 file(s)), anonymized user #8 (2 file(s)), anonymized user #9 (1 file(s)) (+2 more) — spread or document their files in the same way, at lower priority than the named off-boarding risks above. The files folded here: pyrefly/lib/report/pysa/capnp_writer.rs, pyrefly/lib/report/pysa/module.rs, crates/pyrefly_types/src/polars_dtype.rs, pyrefly/lib/binding/polars.rs, pyrefly/lib/lsp/non_wasm/protocol.rs, pyrefly/lib/state/step_slot.rs, pyrefly/lib/state/lsp/extra_extensions.rs, lsp/src/lsp-path.ts (+5 more).
Documentation: no build, run or usage example lsp/README.md:1— `lsp` is a published package (`package.json` without `"private": true`) and neither `lsp/README.md` nor the documents it links hold a code block or a command. Show the command that builds or runs it, or a usage snippet.
No ADRs found pyrefly/Cargo.toml:15— No ADRs found. No recognised ADR directory (`docs/adr/`, `docs/decisions/`, `adr/`, `docs/rfcs/`, an `ADR0001/` folder, or their siblings) exists anywhere in this tree. What was searched, so you can tell an empty log from a search that missed one: every directory under the tree (build output, dependencies and VCS metadata excepted), for a document that is either any non-index page inside a recognised ADR directory, whatever its name and however deeply nested (`docs/adr/use-postgres.md`, `docs/adr/2024/0001-x.md`); or a file anywhere whose name is ADR-shaped (`0001-use-postgres.md`, `adr-012-caching.md`); or, when neither turned anything up, a document carrying the decision-record signature (an "Architecture Decision Record" heading, or Status / Context / Decision / Consequences as section headings). A decision log that clears none of these — unnumbered files outside any recognised directory, without those headings — is not seen by this check and this row is then wrong. If that is your case, say so rather than renaming anything; otherwise, consider recording architectural decisions in `docs/adr/`. ADRs are expected here because `pyrefly/Cargo.toml` makes this repository a deployable product (line 15).
D26 · Project Cohesion· Projects may be oversized for their cohesion · ×1
Projects may be oversized for their cohesion — 3 of 11 project(s) overshoot their size bounds, lowering Project Cohesion to 4.5/10. The most over is `pyrefly` (225107 LoC, 933 module-visible types across 48 directories). Review these for cohesion — draw the boundary inside the module first (group each responsibility into its own package or directory and keep the cross-boundary members non-public), since splitting a published package moves types between packages and breaks consumers.
D34 · Knowledge Freshness· Orphaned files with no living knowledge · ×1
Orphaned files with no living knowledge — 2 of 418 analysed file(s) have no living knowledge left — their last meaningful change has decayed away, so if one breaks, no one currently understands it (counted over production source files of roughly 2,400 bytes or more, excluding vendored, generated, example/demo and scaffolding-template trees and test files identified by path convention, largest first; 418 of the 577 production source files in this repository met that bar). None is large enough to earn a read-through of its own, so this row stands in for the per-file rows rather than raising one each — most significant first: crates/pyrefly_config/src/migration/mypy/regex_converter.rs, crates/pyrefly_python/src/comment_section.rs. Attach the read to the next change that touches one of them: have a second person review that change, and leave behind a short comment or test recording what the file is for, so the knowledge comes back at the cost of a change you were making anyway.
No ADRs — No Architecture Decision Records found — no conventional ADR directory, no numbered `NNNN-title` documents in any markup this check reads, and nothing ADR-shaped by content. Design rationale recorded elsewhere (a design-notes tree, a mailing list, pull-request discussion) is not visible to this check and is not re-findable per decision, so a future maintainer cannot ask why one choice was made and get an answer.
Logging is not universal — Only 5/11 runnable modules use logging (modules with no entry point or server are excluded — they are libraries a runnable module hosts). Silent: `pyrefly`, `tensor-shapes/jax-pyrefly-stubs`, `tensor-shapes/pyrefly-einops-stubs`, `tensor-shapes/pyrefly-numpy-stubs`, `tensor-shapes/pyrefly-shape-extensions` and 1 more.
No dependency-update automation lsp/package.json:440— `lsp/package.json` declares packages, and nothing in the repository keeps them current: no Dependabot or Renovate configuration that schedules updates, and no dependency-review gate on pull requests. A pinned dependency stays at the version it was added at until someone notices — including after an advisory is published against it. Add a `.github/dependabot.yml` with one `package-ecosystem` entry per ecosystem the tree uses (or an enabled `renovate.json`), and gate pull requests with `actions/dependency-review-action`.
R7 · Dead Code· Unused export 'requireSetting' · ×1
Unused export 'requireSetting' lsp/src/lsp-path.ts:33— Nothing imports this binding — it is safe to review for removal.
X2 · Cancellation propagation· Not all async functions that make a request accept an AbortSignal · ×1
Not all async functions that make a request accept an AbortSignal — Only 0/1 async functions that make a cancellable request (fetch, axios, ky, ofetch, got, undici, node:http) accept an AbortSignal or pass one on, so a request keeps running after whatever wanted it has given up — a page navigated away from, an unmounted component, a timed-out job. Take a `signal` (or an options object that carries one) and hand it to the request; where nothing could ever cancel the call, omitting it is a deliberate choice — judge against how the function is used.
Silent fallback default on parse failure scripts/generate_release_notes.py:84— `_dev_disclaimer_for` returns `''` when `ValueError` is raised, with no log or raise — a malformed value silently becomes that default. Log the input or fail validation. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
Outdated: arc-swap — `arc-swap` is locked at 1.9.4 but 1.9.5 is the current stable release on crates.io, and it already satisfies the `"1.9.4"` requirement declared in pyrefly/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p arc-swap` and commit the updated REDACTED.
Outdated: syn — `syn` is locked at 3.0.9 but 3.0.10 is the current stable release on crates.io, and it already satisfies the `"3.0.9"` requirement declared in crates/pyrefly_derive/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p syn` and commit the updated REDACTED.
Outdated: uuid — `uuid` is locked at 1.29.1 but 1.29.2 is the current stable release on crates.io, and it already satisfies the `"1.29.1"` requirement declared in pyrefly/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p uuid` and commit the updated REDACTED.
doc comments repeat the names website/src/__tests__/__mocks__/configuredMonacoMock.ts:74— 5 of 25 documented parameters and 6 of 57 summaries in `new-website` only repeat the member or parameter name (e.g. "The auto-complete function" for `_autoCompleteFunction`). Delete the restating tags, or add what the name does not say.
Appendix B — Reproduction & audit trail
Every external tool invocation behind a deep-scan dimension — the tool, its captured version, the exact command, how many findings it yielded, and a link to the retained raw output. To reproduce any finding: check out the same commit and run the command shown (repo-relative — never an absolute scratch path). The complete raw scanner output is retained verbatim under artifacts/raw/ (indexed in artifacts/raw/index.json); per-invocation exit codes and wall-clock durations are in sidecar.json — kept out of this table so the rendered report stays byte-identical across runs of the same commit.
trivy: not applicable — No Infrastructure-as-Code or container manifests found (Dockerfile, Docker Compose, Terraform, Kubernetes/Helm, CloudFormation, ARM, Bicep, Ansible); nothing to scan.
semgrep: not applicable — No personal data was found crossing a boundary the PII/GDPR ruleset checks — nothing written to a log or console sink, placed in a URL or query string, or persisted to browser storage. That is a clean result for the LEAK surface only: this ruleset detects personal data escaping, it does not inventory the personal data a repository holds, so it is not evidence that this repository has no personal-data surface. The personal-data map (Appendix C) and the C1-C5 compliance cards are what speak to that. semgrep could not parse 56 file(s) — `conformance/third_party/aliases_type_statement.py`, `conformance/third_party/aliases_typealiastype.py`, `conformance/third_party/annotations_forward_refs.py`, `conformance/third_party/callables_annotation.py`, `conformance/third_party/callables_protocol.py`, … (+51 more) — so the PII/GDPR sweep did not cover the unparsed regions of them; rows reported elsewhere in those files are real.
disclosure: not applicable — No vulnerability-disclosure policy file found (SECURITY.md/.markdown/.rst/.txt at root or under .github/.forgejo/.gitea/docs, .well-known/security.txt). A coordinated-disclosure policy may live off-repo, so this is not evidenced rather than failed.
runtime-hardening: not applicable — No Kubernetes/orchestration workloads found in the repository manifests; network egress policy is a cluster-native control that may live at the platform/firewall layer, so there is nothing to assess here.
runtime-hardening: not applicable — No Kubernetes/orchestration workloads found in the repository manifests; seccomp/AppArmor/SELinux confinement is a workload-level control, so there is nothing to assess here.
runtime-hardening: not applicable — No Kubernetes/orchestration workloads found in the repository manifests; runtime threat-detection and admission-control policy are cluster-level controls, so there is nothing to assess here.
Run 01a1db2d-cc0a-7bc5-986f-23449767e750 · every finding is also locatable in findings.md, and the complete scoring record (with exit codes + durations) in sidecar.json.
Issues: 140 · Warnings: 1955 · Recommendations: 93 · Info: 4 — Appendix A · all findings · full markdown report.
Generated by the Canine Code Analyzer: deterministic code-health analysis. 14-11-2026 @ 17:49 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.