Public report of facebook/pyrefly, published 27 October 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.10.5). 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, 27 October 2026, 16:49 UTC · Survey ID cd_3a2742d3328b4b95b779624063feaaf6
facebook/pyrefly
Measured 27 October 2026, 16:30 UTC, at code version 413a7ef
Regression: 1 dimension fell since the last survey
A regression is a drop of 0.5 points or more in the score, or of 2.5 or more out of 10 in a dimension, since the last survey.
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: 327,380 lines of product code in 10 projects, tests not counted · Estimated rebuild effort: about 4.3 person-years · Weakest lens: Code Health, 59
Findings by how serious they are
121 critical1747 serious91 minor
10 dimensions are left out of the score. For each one, Watchdog either couldn't measure it in this code, or found no evidence of the safeguard it looks 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
Watchdog
Producer
Canine Development
Analyzer
Watchdog engine 1.0.0
Measured
27 October 2026, 16:30 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 Watchdog. It is open to any tool that
implements it, and today Watchdog 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. Watchdog works 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 ▸
77of 77 dimensions measured by tools.
1939of 1959 findings point to an exact file and line, so you can open each one in the code. The other 20 concern the repository as a whole, such as missing documentation.
77dimensions across 7 lenses, read from 327,380 lines of product code in 10 projects.
facebook/pyrefly is rated At risk because critical security findings are open, most of them in the build pipeline. It scores 64 out of 100, which the At risk rating leaves unchanged.
Code Health, at 59, is the weakest lens and counts most in the score. The best first step is recording design decisions, worth about 3 points. Writing log messages as searchable templates would lift Code Health itself, also worth about 3. Raising Code Health to 70 would lift the score to about 67.
102 pipeline tools are referenced by a changeable name, so the build pipeline can be tampered with. Six known security holes in the packages the code depends on can be used by attackers. Pinning each tool to an exact version and updating the vulnerable packages would close both risks. Passing outside input through environment variables would fix the five pipeline steps that put outside input straight into a shell command, 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 327,380 lines, about €620,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.
Code Duplication · Members sharing a duplicated core (6 members, 50+ identical tokens) tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py
Code Duplication · Members sharing a duplicated core (5 members, 50+ identical tokens) tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py
Code Duplication · Members sharing a duplicated core (5 members, 50+ identical tokens) tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py
Code Duplication · Members sharing a duplicated core (5 members, 50+ identical tokens) tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py
Code Duplication · Members sharing a duplicated core (5 members, 50+ identical tokens) tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py
Code Duplication · Members sharing a duplicated core (5 members, 50+ identical tokens) tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py
Code Duplication · Members sharing a duplicated core (5 members, 50+ identical tokens) tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py
Code Duplication · Members sharing a duplicated core (5 members, 50+ identical tokens) tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py
Code Duplication · Members sharing a duplicated core (5 members, 50+ identical tokens) tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py
Code Duplication · Members sharing a duplicated core (5 members, 50+ identical tokens) tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py
Test Quality · No assertions: startup requests and diagnostics use the interpreter from the Python extension lsp/src/test/startup-settings/instant/instant.test.ts
Watchdog compares 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: 37 findings
These 37 critical or serious findings were in the previous survey, on 13 October 2026, and are gone from this one.
Dependency Vulnerabilities · High CVE: [GHSA redacted] REDACTED
Dependency Vulnerabilities · Medium vulnerability: [GHSA redacted] REDACTED
Supply-chain Provenance & Signing REDACTED
Supply-chain Provenance & Signing REDACTED
Rebuild cost: about €620,000 · Estimate
Cost to rebuild
€210,000 to €1,000,000, for 3,435 to 10,898 hours of work, about 4.3 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 64. 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: 327,380 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: Watchdog prices the hours a team would need to write this code again, at €60 to €95 an hour. Declarations and boilerplate are priced at a fast rate and logic at a slower one, and the logic is then multiplied by the difficulty of the problem and by the quality factor. The estimate can be about 30% off either way, and it moves most with the hourly rate and the difficulty. For this code, every line is priced as straight logic, which keeps the estimate on the low side.
Top priorities
The three actions that raise the score most for the work they take. The full ranked list is in the Roadmap.
1
Resolve the 1 No ADRs found finding(s) in ADR Quality.
Raises the score by about 3 points · Low effort · ADR Quality
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 €620,000 to build again, about 4.3 person-years of work. Its weakest lens is Code Health, at 59 (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
Resolve the 1 No ADRs found finding(s) in ADR Quality. Of all the actions in this report, it raises the score most for the work it takes: about 3 points for low effort, because it clears the 1 ADR Quality findings. 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.4 out of 10. Code at that level is slower to change than clean code, and Watchdog estimates the extra work at 4% to 9% on every change. The history of the code shows how much it changes: about 288,341 lines over the last 90 days, which is about 1,169,383 lines a year. At that pace, the extra work comes to an estimated 115.6 to 693.6 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 Watchdog's 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.
692 modules, with 1956 dependencies between them. 2 loops run through 178 of the modules, marked above the diagonal.
The table shows the 40 modules with the most connections; 652 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_glean_schema.report.glean.schema.python uses pyrefly_types.equality, so a change to pyrefly_types.equality can break pyrefly_glean_schema.report.glean.schema.python, while a change to pyrefly_glean_schema.report.glean.schema.python can't break pyrefly_types.equality.
Position
Below the diagonal: pyrefly_glean_schema.report.glean.schema.python uses a module listed above it, which is the healthy direction.
pyrefly_glean_schema.report.glean.schema.python uses pyrefly_util.visit, so a change to pyrefly_util.visit can break pyrefly_glean_schema.report.glean.schema.python, while a change to pyrefly_glean_schema.report.glean.schema.python can't break pyrefly_util.visit.
Position
Below the diagonal: pyrefly_glean_schema.report.glean.schema.python uses a module listed above it, which is the healthy direction.
pyrefly_python.module_name uses pyrefly_types.equality, so a change to pyrefly_types.equality can break pyrefly_python.module_name, while a change to pyrefly_python.module_name can't break pyrefly_types.equality.
Position
Below the diagonal: pyrefly_python.module_name uses a module listed above it, which is the healthy direction.
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_name uses pyrefly_glean_schema.report.glean.schema.python, so a change to pyrefly_glean_schema.report.glean.schema.python can break pyrefly_python.module_name, while a change to pyrefly_python.module_name can't break pyrefly_glean_schema.report.glean.schema.python.
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_types.equality, so a change to pyrefly_types.equality can break pyrefly_python.module_path, while a change to pyrefly_python.module_path can't break pyrefly_types.equality.
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_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.qname uses pyrefly_types.equality, so a change to pyrefly_types.equality can break pyrefly_python.qname, while a change to pyrefly_python.qname can't break pyrefly_types.equality.
Position
Below the diagonal: pyrefly_python.qname uses a module listed above it, which is the healthy direction.
pyrefly_python.qname uses pyrefly_glean_schema.report.glean.schema.python, so a change to pyrefly_glean_schema.report.glean.schema.python can break pyrefly_python.qname, while a change to pyrefly_python.qname can't break pyrefly_glean_schema.report.glean.schema.python.
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_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_build.source_db uses pyrefly_python.sys_info, so a change to pyrefly_python.sys_info can break pyrefly_build.source_db, while a change to pyrefly_build.source_db can't break pyrefly_python.sys_info.
Position
Below the diagonal: pyrefly_build.source_db uses a module listed above it, which is the healthy direction.
pyrefly_build.source_db uses pyrefly_python.module_name, so a change to pyrefly_python.module_name can break pyrefly_build.source_db, while a change to pyrefly_build.source_db can't break pyrefly_python.module_name.
Position
Below the diagonal: pyrefly_build.source_db uses a module listed above it, which is the healthy direction.
pyrefly_build.source_db uses pyrefly_python.module_path, so a change to pyrefly_python.module_path can break pyrefly_build.source_db, while a change to pyrefly_build.source_db can't break pyrefly_python.module_path.
Position
Below the diagonal: pyrefly_build.source_db uses a module listed above it, which is the healthy direction.
pyrefly_build.source_db uses pyrefly_build.handle, so a change to pyrefly_build.handle can break pyrefly_build.source_db, while a change to pyrefly_build.source_db can't break pyrefly_build.handle.
Position
Below the diagonal: pyrefly_build.source_db 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_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.
12→19 pyrefly_config.config uses pyrefly_config.error_kindpart of a loop✕
Connections
1 pair of types, where a type in pyrefly_config.config uses a type in pyrefly_config.error_kind.
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
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→21 pyrefly_config.config uses pyrefly.lib.error.errorpart of a loop✕
Connections
1 pair of types, where a type in pyrefly_config.config uses a type in pyrefly.lib.error.error.
pyrefly_config.config uses pyrefly.lib.error.error, so a change to pyrefly.lib.error.error can break pyrefly_config.config, while a change to pyrefly_config.config 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.
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_glean_schema.report.glean.schema.python, so a change to pyrefly_glean_schema.report.glean.schema.python can break pyrefly_types.stdlib, while a change to pyrefly_types.stdlib can't break pyrefly_glean_schema.report.glean.schema.python.
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.
13→20 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.
13→26 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.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_build.source_db, so a change to pyrefly_build.source_db can break pyrefly.lib.state.steps, while a change to pyrefly.lib.state.steps can't break pyrefly_build.source_db.
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.
14→32 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.
14→39 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_config.migration.pyright uses pyrefly_python.sys_info, so a change to pyrefly_python.sys_info can break pyrefly_config.migration.pyright, while a change to pyrefly_config.migration.pyright can't break pyrefly_python.sys_info.
Position
Below the diagonal: pyrefly_config.migration.pyright uses a module listed above it, which is the healthy direction.
pyrefly_config.migration.pyright uses pyrefly_config.config, so a change to pyrefly_config.config can break pyrefly_config.migration.pyright, while a change to pyrefly_config.migration.pyright can't break pyrefly_config.config.
Position
Below the diagonal: pyrefly_config.migration.pyright uses a module listed above it, which is the healthy direction.
15→19 pyrefly_config.migration.pyright uses pyrefly_config.error_kindpart of a loop✕
Connections
3 pairs of types, where a type in pyrefly_config.migration.pyright uses a type in pyrefly_config.error_kind.
pyrefly_config.migration.pyright uses pyrefly_config.error_kind, so a change to pyrefly_config.error_kind can break pyrefly_config.migration.pyright, while a change to pyrefly_config.migration.pyright can't break pyrefly_config.error_kind.
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_types.equality, so a change to pyrefly_types.equality can break pyrefly_types.type_var, while a change to pyrefly_types.type_var can't break pyrefly_types.equality.
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_glean_schema.report.glean.schema.python, so a change to pyrefly_glean_schema.report.glean.schema.python can break pyrefly_types.type_var, while a change to pyrefly_types.type_var can't break pyrefly_glean_schema.report.glean.schema.python.
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.
16→20 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.
16→22 pyrefly_types.type_var uses pyrefly_types.quantifiedpart of a loop✕
Connections
3 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.types uses pyrefly_types.equality, so a change to pyrefly_types.equality can break pyrefly_types.types, while a change to pyrefly_types.types can't break pyrefly_types.equality.
Position
Below the diagonal: pyrefly_types.types uses a module listed above it, which is the healthy direction.
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_glean_schema.report.glean.schema.python, so a change to pyrefly_glean_schema.report.glean.schema.python can break pyrefly_types.types, while a change to pyrefly_types.types can't break pyrefly_glean_schema.report.glean.schema.python.
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.
17→20 pyrefly_types.types uses pyrefly_types.heappart of a loop✕
Connections
2 pairs of types, where a type in pyrefly_types.types uses a type in pyrefly_types.heap.
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
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.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.
17→24 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.
17→25 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.
17→26 pyrefly_types.types uses pyrefly_types.classpart of a loop✕
Connections
1 pair of types, where a type in pyrefly_types.types uses a type in pyrefly_types.class.
pyrefly_types.types uses pyrefly_types.class, so a change to pyrefly_types.class can break pyrefly_types.types, while a change to pyrefly_types.types 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.lib.state.lsp uses pyrefly_graph.index, so a change to pyrefly_graph.index can break pyrefly.lib.state.lsp, while a change to pyrefly.lib.state.lsp can't break pyrefly_graph.index.
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.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_glean_schema.report.glean.schema.python, so a change to pyrefly_glean_schema.report.glean.schema.python can break pyrefly.lib.state.lsp, while a change to pyrefly.lib.state.lsp can't break pyrefly_glean_schema.report.glean.schema.python.
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_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.
pyrefly_config.error_kind uses pyrefly_config.migration.pyright, so a change to pyrefly_config.migration.pyright can break pyrefly_config.error_kind, while a change to pyrefly_config.error_kind can't break pyrefly_config.migration.pyright.
Position
Below the diagonal: pyrefly_config.error_kind uses a module listed above it, which is the healthy direction.
pyrefly_types.heap uses pyrefly_glean_schema.report.glean.schema.python, so a change to pyrefly_glean_schema.report.glean.schema.python can break pyrefly_types.heap, while a change to pyrefly_types.heap can't break pyrefly_glean_schema.report.glean.schema.python.
Position
Below the diagonal: pyrefly_types.heap uses a module listed above it, which is the healthy direction.
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.
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
Below the diagonal: pyrefly_types.heap uses a module listed above it, which is the healthy direction.
20→22 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.
20→24 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.
20→25 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.
20→26 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.
pyrefly.lib.error.error uses pyrefly_glean_schema.report.glean.schema.python, so a change to pyrefly_glean_schema.report.glean.schema.python can break pyrefly.lib.error.error, while a change to pyrefly.lib.error.error can't break pyrefly_glean_schema.report.glean.schema.python.
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_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_types.quantified uses pyrefly_types.equality, so a change to pyrefly_types.equality can break pyrefly_types.quantified, while a change to pyrefly_types.quantified can't break pyrefly_types.equality.
Position
Below the diagonal: pyrefly_types.quantified uses a module listed above it, which is the healthy direction.
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_glean_schema.report.glean.schema.python, so a change to pyrefly_glean_schema.report.glean.schema.python can break pyrefly_types.quantified, while a change to pyrefly_types.quantified can't break pyrefly_glean_schema.report.glean.schema.python.
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_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.
22→26 pyrefly_types.quantified uses pyrefly_types.classpart of a loop✕
Connections
2 pairs of types, where a type in pyrefly_types.quantified uses a type in pyrefly_types.class.
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
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.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_types.callable uses pyrefly_types.equality, so a change to pyrefly_types.equality can break pyrefly_types.callable, while a change to pyrefly_types.callable can't break pyrefly_types.equality.
Position
Below the diagonal: pyrefly_types.callable 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_glean_schema.report.glean.schema.python, so a change to pyrefly_glean_schema.report.glean.schema.python can break pyrefly_types.callable, while a change to pyrefly_types.callable can't break pyrefly_glean_schema.report.glean.schema.python.
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_types.function uses pyrefly_types.equality, so a change to pyrefly_types.equality can break pyrefly_types.function, while a change to pyrefly_types.function can't break pyrefly_types.equality.
Position
Below the diagonal: pyrefly_types.function uses a module listed above it, which is the healthy direction.
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_glean_schema.report.glean.schema.python, so a change to pyrefly_glean_schema.report.glean.schema.python can break pyrefly_types.function, while a change to pyrefly_types.function can't break pyrefly_glean_schema.report.glean.schema.python.
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.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.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
Below the diagonal: pyrefly_types.function uses a module listed above it, which is the healthy direction.
25→26 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.
pyrefly_types.class uses pyrefly_types.equality, so a change to pyrefly_types.equality can break pyrefly_types.class, while a change to pyrefly_types.class can't break pyrefly_types.equality.
Position
Below the diagonal: pyrefly_types.class uses a module listed above it, which is the healthy direction.
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_glean_schema.report.glean.schema.python, so a change to pyrefly_glean_schema.report.glean.schema.python can break pyrefly_types.class, while a change to pyrefly_types.class can't break pyrefly_glean_schema.report.glean.schema.python.
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.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_graph.index, so a change to pyrefly_graph.index can break pyrefly.lib.binding.scope, while a change to pyrefly.lib.binding.scope can't break pyrefly_graph.index.
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.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_glean_schema.report.glean.schema.python, so a change to pyrefly_glean_schema.report.glean.schema.python can break pyrefly.lib.binding.scope, while a change to pyrefly.lib.binding.scope can't break pyrefly_glean_schema.report.glean.schema.python.
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.
27→29 pyrefly.lib.binding.scope uses pyrefly.lib.binding.bindingspart of a loop✕
Connections
4 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.
27→30 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.lib.solver.solver uses pyrefly_glean_schema.report.glean.schema.python, so a change to pyrefly_glean_schema.report.glean.schema.python can break pyrefly.lib.solver.solver, while a change to pyrefly.lib.solver.solver can't break pyrefly_glean_schema.report.glean.schema.python.
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.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_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.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.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.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.
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_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.
28→31 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_graph.index, so a change to pyrefly_graph.index can break pyrefly.lib.binding.bindings, while a change to pyrefly.lib.binding.bindings can't break pyrefly_graph.index.
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_glean_schema.report.glean.schema.python, so a change to pyrefly_glean_schema.report.glean.schema.python can break pyrefly.lib.binding.bindings, while a change to pyrefly.lib.binding.bindings can't break pyrefly_glean_schema.report.glean.schema.python.
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_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_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_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.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.
29→30 pyrefly.lib.binding.bindings uses pyrefly.lib.binding.bindingpart of a loop✕
Connections
21 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.
53 pairs of types, where a type in pyrefly.lib.binding.binding uses a type in pyrefly_graph.index. Showing 25 of them; the rest are in namespace-graph.json in this report's bundle.
pyrefly.lib.binding.binding uses pyrefly_graph.index, so a change to pyrefly_graph.index can break pyrefly.lib.binding.binding, while a change to pyrefly.lib.binding.binding can't break pyrefly_graph.index.
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.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_glean_schema.report.glean.schema.python, so a change to pyrefly_glean_schema.report.glean.schema.python can break pyrefly.lib.binding.binding, while a change to pyrefly.lib.binding.binding can't break pyrefly_glean_schema.report.glean.schema.python.
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.
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.
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.
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.
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.
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.
30→31 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_graph.index, so a change to pyrefly_graph.index can break pyrefly.lib.alt.answers_solver, while a change to pyrefly.lib.alt.answers_solver can't break pyrefly_graph.index.
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_glean_schema.report.glean.schema.python, so a change to pyrefly_glean_schema.report.glean.schema.python can break pyrefly.lib.alt.answers_solver, while a change to pyrefly.lib.alt.answers_solver can't break pyrefly_glean_schema.report.glean.schema.python.
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.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_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_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.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.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_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_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.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.
49 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.
31→39 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.state.state uses pyrefly_graph.index, so a change to pyrefly_graph.index can break pyrefly.lib.state.state, while a change to pyrefly.lib.state.state can't break pyrefly_graph.index.
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.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_glean_schema.report.glean.schema.python, so a change to pyrefly_glean_schema.report.glean.schema.python can break pyrefly.lib.state.state, while a change to pyrefly.lib.state.state can't break pyrefly_glean_schema.report.glean.schema.python.
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_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.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_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_config.error_kind, so a change to pyrefly_config.error_kind can break pyrefly.lib.state.state, while a change to pyrefly.lib.state.state can't break pyrefly_config.error_kind.
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_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.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
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.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
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.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
Below the diagonal: pyrefly.lib.state.state uses a module listed above it, which is the healthy direction.
32→38 pyrefly.lib.state.state uses pyrefly.lib.report.pysapart of a loop✕
Connections
3 pairs of types, where a type in pyrefly.lib.state.state uses a type in pyrefly.lib.report.pysa.
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
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.
32→39 pyrefly.lib.state.state uses pyrefly.lib.alt.answerspart of a loop✕
Connections
8 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.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_glean_schema.report.glean.schema.python, so a change to pyrefly_glean_schema.report.glean.schema.python can break pyrefly.lib.lsp.non_wasm.server, while a change to pyrefly.lib.lsp.non_wasm.server can't break pyrefly_glean_schema.report.glean.schema.python.
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.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.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_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_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.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.report.pysa.context uses pyrefly_graph.index, so a change to pyrefly_graph.index can break pyrefly.lib.report.pysa.context, while a change to pyrefly.lib.report.pysa.context can't break pyrefly_graph.index.
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_glean_schema.report.glean.schema.python, so a change to pyrefly_glean_schema.report.glean.schema.python can break pyrefly.lib.report.pysa.context, while a change to pyrefly.lib.report.pysa.context can't break pyrefly_glean_schema.report.glean.schema.python.
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_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.
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
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.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
Below the diagonal: pyrefly.lib.report.pysa.context uses a module listed above it, which is the healthy direction.
34→38 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.
34→39 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.lib.report.pysa.call_graph uses pyrefly_glean_schema.report.glean.schema.python, so a change to pyrefly_glean_schema.report.glean.schema.python can break pyrefly.lib.report.pysa.call_graph, while a change to pyrefly.lib.report.pysa.call_graph can't break pyrefly_glean_schema.report.glean.schema.python.
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_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_build.source_db, so a change to pyrefly_build.source_db can break pyrefly.lib.report.pysa.call_graph, while a change to pyrefly.lib.report.pysa.call_graph can't break pyrefly_build.source_db.
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.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
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.
pyrefly.lib.report.pysa.call_graph uses pyrefly_types.function, so a change to pyrefly_types.function can break pyrefly.lib.report.pysa.call_graph, while a change to pyrefly.lib.report.pysa.call_graph can't break pyrefly_types.function.
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.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.
35→36 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.
pyrefly.lib.report.pysa.function uses pyrefly_graph.index, so a change to pyrefly_graph.index can break pyrefly.lib.report.pysa.function, while a change to pyrefly.lib.report.pysa.function can't break pyrefly_graph.index.
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_glean_schema.report.glean.schema.python, so a change to pyrefly_glean_schema.report.glean.schema.python can break pyrefly.lib.report.pysa.function, while a change to pyrefly.lib.report.pysa.function can't break pyrefly_glean_schema.report.glean.schema.python.
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_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.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_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_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.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
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.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.
pyrefly.lib.report.pysa.pysa_report_capnp.source_path uses pyrefly_glean_schema.report.glean.schema.python, so a change to pyrefly_glean_schema.report.glean.schema.python can break pyrefly.lib.report.pysa.pysa_report_capnp.source_path, while a change to pyrefly.lib.report.pysa.pysa_report_capnp.source_path can't break pyrefly_glean_schema.report.glean.schema.python.
Position
Below the diagonal: pyrefly.lib.report.pysa.pysa_report_capnp.source_path uses a module listed above it, which is the healthy direction.
pyrefly.lib.report.pysa.pysa_report_capnp.source_path uses pyrefly.lib.report.pysa.call_graph, so a change to pyrefly.lib.report.pysa.call_graph can break pyrefly.lib.report.pysa.pysa_report_capnp.source_path, while a change to pyrefly.lib.report.pysa.pysa_report_capnp.source_path can't break pyrefly.lib.report.pysa.call_graph.
Position
Below the diagonal: pyrefly.lib.report.pysa.pysa_report_capnp.source_path 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_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.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
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.
pyrefly.lib.alt.answers uses pyrefly_graph.index, so a change to pyrefly_graph.index can break pyrefly.lib.alt.answers, while a change to pyrefly.lib.alt.answers can't break pyrefly_graph.index.
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.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_glean_schema.report.glean.schema.python, so a change to pyrefly_glean_schema.report.glean.schema.python can break pyrefly.lib.alt.answers, while a change to pyrefly.lib.alt.answers can't break pyrefly_glean_schema.report.glean.schema.python.
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_build.source_db, so a change to pyrefly_build.source_db can break pyrefly.lib.alt.answers, while a change to pyrefly.lib.alt.answers can't break pyrefly_build.source_db.
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.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_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.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_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_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.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.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.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.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.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_glean_schema.report.glean.schema.python, so a change to pyrefly_glean_schema.report.glean.schema.python can break pyrefly.lib.query, while a change to pyrefly.lib.query can't break pyrefly_glean_schema.report.glean.schema.python.
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.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 · 59% · 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
114
High / Critical
A03:2025 — Software Supply Chain Failures
41
High / Critical
A07:2025 — Authentication Failures
2
High / Critical
Roadmap
Begin by addressing the absence of Architecture Decision Records to properly document significant design choices and their consequences. Simultaneously, resolve the static analysis findings related to shell injection risks and fix the interpolated log messages that currently defeat structured logging. Finally, reduce the cognitive complexity of the thirteen most complex code bodies to improve maintainability and overall code quality.
Ranked by impact ÷ effort. "Helps" is the estimated gain on the 0–100 health score.
Do this
Helps
Effort
Dimension
Resolve the 1 No ADRs found finding(s) in ADR Quality.
Record 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.
Resolve the 1 REDACTED finding(s) charged to Static Analysis (SAST) — the other 97 are reported here at file:line but scored by D36 (supply-chain provenance), which charges them once.
God Classes: FunctionTooLong: pyrefly::lib::query::type_table::type_to_indexed_shape
REDACTED
5.8
Mixed
Static Analysis (SAST): High: REDACTED
REDACTED
5.8
Mixed
Static Analysis (SAST): High: REDACTED
REDACTED
5.8
Mixed
Static Analysis (SAST): High: REDACTED
How the grades work
Every finding carries one of four grades. Three say how serious it is. The fourth says this
survey could not settle it — and it is a grade, not a gap.
Critical — 121
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 — 1747
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 — 91
Recorded, with no effect on how the codebase functions.
Present so the survey is complete, not because it needs doing.
Could not be resolved — 10
Something this survey could not settle
from the outside, and which could be critical or serious. Either a control was required and no
positive evidence of it exists in the repository — a backup job that nothing shows was ever restored from proves
nothing about restores — or our own analysis could not run over that part of the tree. This is not a clean
result. These are excluded from the score rather than awarded a pass, so the number on the cover neither
rewards nor penalises them: if you act on this survey without resolving them, you carry that risk yourself. Each
one is named under Limitations.
Methodology & how to trust this report
Watchdog is a deep, periodic assessment — run each sprint, monthly, or quarterly, taking the time to go wider and deeper than a quick check and surfacing in one coherent report what you'd otherwise piece together from a dozen separate tools. It scores deterministically: the same commit yields the same score, every run. 77 of 77 evaluated dimensions are computed purely by tools and static analysis (confidence 1.0); none rely on LLM judgement. Overall confidence is 0.9 — the weighted average across measured dimensions; it falls as more of the score leans on LLM-assisted judgement and rises when it's fully tool-backed.
Every figure here is one of three kinds, and we label which: ✓ Measured — a deterministic fact (LoC, complexity, coverage); ~ Modeled — an estimate from a stated model (cost, effort, value-at-risk), always a range with its assumptions, never a precise fact; ◐ Advisory — an LLM prose judgement. We never present a modelled estimate as if it were measured. Perfect or absent scores carry their provenance too (ADR-0011): ✓ Tool-verified means the property itself was measured across the surface; ○ Nothing flagged means the probes came back clean — a claim bounded by what a repository can show; ⊘ Not evidenced means a working control (a tested restore, an automated rollback) showed no positive evidence — absence of evidence is not evidence of a control, so it's excluded from the score rather than awarded a spurious 10; ◐ Sampled · advisory marks an LLM verdict over a bounded sample — advisory, never a deterministic measurement.
What we checked — 77 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, 1939 of 1959 do; the remainder are repo-wide signals — a dimension-level measurement, not a single line. (Every path in this report is repo-relative by construction: paths are normalized at the producer and the report is rejected if any rooted path leaks through.)
Is there a tool behind the number? Every score below names the method that produced it — Roslyn, git, a scanner, or (for a handful of documentation/naming dimensions) an LLM labelled sampled · advisory — not a narrative.
Does re-running give the same result? Run it again on the same commit and the score — and this report, byte for byte — is identical. A report whose numbers move between runs is describing the run, not the code.
This report answers yes to all three. That's the bar to hold any assessment to.
Tools & methods
The actual versions used this run (captured at analysis time) — re-run on the same commit for the identical score.
Method
Backs
Version
Evaluator
Roslyn static analysis
Complexity, cohesion, coupling, dead code, API surface, layering
What ran differently this time — a tool absent, degraded, or that fell back to an estimate. Named openly, not folded silently into the scores. A degraded run also records its exact cause in diagnostics.md.
D8 Code Coverage — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. 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. In the meantime, commit (or publish into the working tree) the lcov/Cobertura report your CI produces and the real number is read on the next scan. You can widen what we reach: optional: commit the lcov/Cobertura report your CI produces, and the real number is read on the next scan.
D10 Test Quality — measured, with a gap in what it reached — Watchdog measured this, but not all of it. What it 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 97 test(s) behind this row are the ones the JavaScript/TypeScript census could read, and this repository also carries at least 785 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 — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. 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 — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. 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 — Watchdog measured this, but not all of it. What it 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 — Watchdog measured this, but not all of it. What it 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 — Watchdog measured this, but not all of it. What it 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 — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. D21's deterministic naming 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. Until then its declarations carry no naming verdict this run — this says nothing about whether its names are consistent.
D22 Internal API Consistency — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. D22's deterministic call-shape rules are gated on C# first (docs/plans/deterministic-engine.md, P5): each other language is switched on only after its own concept suite and A/B gate pass. This says nothing about whether that surface is consistent.
D24 Comment Value — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check's reader does not cover the language this repository's product is written in, so it had nothing of the product to read. That is a gap in this analyzer's language reach — not a finding about this repository.
D27 Navigability — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. 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 — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. `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`, … (+50 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.
AXR1 Runtime accessibility — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. Render strategy: boot via DevServer (start). the dev server did not expose a crawlable HTTP endpoint in time — no runtime evidence.
GD1 Unfinished & placeholder code — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check 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 — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check reads C# syntax, 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 — Watchdog measured this, but not all of it. What it 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). 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.
X4 Structured logging — measured, with a gap in what it reached — Watchdog measured this, but not all of it. What it 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. 123 further occurrence(s) are not listed individually; the score already reflects all 163.
Repo exclusion declarations (.gitattributes linguist-generated/vendored, .editorconfig generated_code): none declared — every source file was scored.
Limitations & what we did not check
Watchdog assesses the repository exactly as committed, and only the repository. By design it does not reach outside the source tree: the live cloud account, the running CI/CD pipeline, the host's branch-protection and approval rules, the production configuration, or a restore actually exercised against a backup are all out of scope. That boundary is a feature, not a gap — a repo-relative, deterministic scan re-runs identically on any commit and every finding opens at a real file and line, where a live audit can neither be reproduced nor traced. The visible consequence is that controls which leave no in-repo evidence are reported as "not evidenced" and excluded from the score rather than awarded a number a static scan cannot justify.
Per-dimension blind spots
For each dimension that was measured, what a static, repo-only scan structurally cannot see — the honest edge of the measurement, not a failure of it.
D1 Cyclomatic Complexity: Cyclomatic complexity counts branches statically — it cannot tell an essential decision tree from accidental tangle, nor see complexity that lives in data or configuration (large switch-case token tables, DSL lexers/parsers, data-as-code rule tables) rather than control flow: a tokenizer's many single-character cases read as high complexity though each branch is trivial.
D2 Cognitive Complexity: Cognitive-complexity heuristics approximate how hard code is to follow; genuine domain difficulty and well-named intent that eases reading are not captured.
D3 God Classes: "God class" is sized by members and responsibilities visible in the type — a deliberately broad facade over a coherent subsystem can read the same as an accidental grab-bag. For front-end JS the file-length check is cohesion-aware (a single-responsibility module — one class/IIFE — earns a 3× threshold), but cohesion is approximated from top-level declarations, not true dependency structure.
D4 Code Duplication: Duplication is token-similarity — an in-process token-stream comparison over sliding windows, with type-aware normalization — so it finds copy-paste, not semantic duplication expressed differently. Committed machine-written code (scaffolded migrations, designer/codegen output, protobuf/OpenAPI stubs, model snapshots) is EXCLUDED — its repetition is the tool's, not the team's — so the score reflects hand-written duplication only.
D5 Coupling: Coupling is measured between projects/assemblies — runtime coupling through DI, reflection, messaging or shared databases is invisible to a static reference graph.
D6 Cohesion (LCOM4): LCOM4 cohesion is syntactic — it infers connectivity from which methods touch which fields/methods by name, not from real runtime behaviour or intent.
D9 Test Distribution: The test-pyramid shape is inferred from project/folder naming and references, with a single test host bucketed per-file by its path tier and content signals — a suite that names tiers unconventionally and gives no per-file signal can still be mis-bucketed.
D10 Test Quality: Assertion density is structural — it cannot tell a meaningful behavioural assertion from a trivial one, only that an assertion is present.
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 REDACTED Scanning: REDACTED 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 is an LLM read of the decision records present — it cannot know about decisions made and never recorded, and its verdict is sampled and advisory.
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: Onboarding quality is an LLM read of the docs/setup present — it cannot run the onboarding or measure how long a real new joiner takes; the verdict is sampled and advisory.
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.
262 method(s) exceeded the cyclomatic complexity threshold of 15; the worst was StructurallyValidatedTypeShapeDslFunction::evaluate_expression at 279. A further 41 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 SpecialExport::new at 81 — 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: pyrefly/lib/export/special.rs (SpecialExport::new at 81), crates/pyrefly_config/src/error_kind.rs (ErrorKind::default_severity at 80), crates/pyrefly_types/src/types.rs (Type::recurse at 54), pyrefly/lib/query/type_table.rs (pyrefly::lib::query::type_table::type_to_indexed_shape at 52), crates/pyrefly_types/src/function.rs (FunctionKind::module_name at 36), 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.
+ 55 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Bring the 7 bodies over 120 down to 120 or less in Cyclomatic Complexity — start with StructurallyValidatedTypeShapeDslFunction::evaluate_expression (cyclomatic 279), Subset::is_subset_eq_no_recursive_check (cyclomatic 249), BindingsBuilder::stmt_impl (cyclomatic 164). — 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 7 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.
Enforce Cyclomatic Complexity in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.
Detailed fixes: d1_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: How hard the code is for a person to follow, beyond raw branching.
Method: Cognitive complexity per method (Sonar-style nesting-penalized score), computed exhaustively over production code, excluding test projects. Deterministic.
+ 94 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Bring the 13 bodies over 120 down to 120 or less in Cognitive Complexity — start with AnswersSolver::callable_infer_params (cognitive 390), BindingsBuilder::stmt_impl (cognitive 339), StructurallyValidatedTypeShapeDslFunction::evaluate_expression (cognitive 285). — 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 13 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.
Enforce Cognitive Complexity in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.
Detailed fixes: d2_recommendation.md · top locations in Appendix A, every location in findings.md.
Do you agree with this assessment?
D3 · God Classes8.3 / 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.
ClassTooLong: Server · ×19pyrefly/lib/lsp/non_wasm/server.rs:1151
+ 2 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Resolve the 118 MethodTooLong finding(s) in God Classes — start with type_level_dsl.rs (12), expr.rs (11), solve.rs (7). — One of this dimension's main actionable groups (118 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 24 FunctionTooLong finding(s) in God Classes — start with meta_shape_dsl.rs (4), hover.rs (2), einops.rs (2). — One of this dimension's main actionable groups (24 warning-level).
Enforce God Classes in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.
Detailed fixes: d3_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Copy-pasted code that should be shared instead.
Method: Code duplication via token-stream sliding windows with type-aware normalization (locals masked, type names preserved), density-scored per KLoC of production code. Deterministic.
333 duplicated block group(s) detected. A further 20 rows report members as variants of one another; they aggregate block groups already counted above and are not themselves counted. 104 of the 353 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.
+ 98 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Resolve the 32 Duplicated block (5 lines × 2) finding(s) in Code Duplication — start with type_level_dsl.rs (4), meta_shape_dsl.rs (3), nanogpt_future_annotations_runnable.py (3). — One of this dimension's main actionable groups (32 warning-level).
Resolve the 28 Duplicated block (7 lines × 2) finding(s) in Code Duplication — start with type_level_dsl.rs (3), server.rs (3), capnp_writer.rs (2). — One of this dimension's main actionable groups (28 warning-level).
Resolve the 22 Duplicated block (8 lines × 2) finding(s) in Code Duplication — start with narrow.rs (3), server.rs (3), unwrap.rs (2). — One of this dimension's main actionable groups (22 warning-level).
Enforce Code Duplication in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Verified — provenance only; does not change the score.
Detailed fixes: d4_recommendation.md · top locations in Appendix A, every location in findings.md.
Do you agree with this assessment?
D5 · 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.
7 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.
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).
Enforce Cohesion (LCOM4) in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Verified — provenance only; does not change the score.
Detailed fixes: d6_recommendation.md · top locations in Appendix A, every location in findings.md.
Do you agree with this assessment?
D9 · Test Distribution10.0 / 10Exemplary✓ Tool-verified
What it measures: Whether the test suite has a healthy mix of unit / integration / end-to-end tests.
Method: Test projects classified (Unit/Integration/BDD/E2E) from compiled metadata; test methods counted exhaustively across projects with placement-agnostic disk fallback. Deterministic.
4962 test methods: 4906 unit, 56 integration, 0 BDD, 0 e2e. The JavaScript/TypeScript suite contributes 97 `it`/`test` case(s) across 18 test file(s) declaring at least one; its tier split is read from package names and paths only. The Rust suite contributes 3657 `#[test]` function(s) across 292 file(s) declaring at least one; its unit/integration split is Cargo's own — 2 of those file(s) are integration-test targets under a crate's tests/ directory, and the rest are #[test] functions compiled into the crate they test. The Python suite contributes 1208 test function(s) across 159 file(s) declaring at least one — every `def test…` in a file pytest or unittest would collect, which is those frameworks' own definition of a case; a parametrize table counts once, so this is a floor. Its tier split is read from file names and paths only.
✓ On the Gold path — maintain.
Detailed fixes: d9_recommendation.md.
Do you agree with this assessment?
D10 · Test Quality9.8 / 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 97 tests. Measured on the JavaScript/TypeScript suite only — at least 785 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).
Enforce Test Quality in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.
Detailed fixes: d10_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether dependencies are current, secure, and not bloated.
Method: Manifest scan via dotnet list package across all projects; worst-signal-per-package deduction (saturating for vulnerabilities, capped-linear for deprecation/outdated) per KLoC. Exhaustive, deterministic.
3 outdated, 0 yanked direct Cargo dependencies. 89 of 93 direct crates were graded against crates.io (0 not published there, 4 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: similar · ×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 416 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 86 Hotspot finding(s) in Churn × Complexity Hotspots — start with function.rs (3), type_level_dsl.rs (2), expr.rs (2). — One of this dimension's main actionable groups (86 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 Factor8.8 / 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.
48 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 391 of the 504 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.
288 deducted task-comment markers across 327380 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 281 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 (281 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 2 FixmeComment finding(s) in Explicit Debt — start with attr.rs, function.rs. — One of this dimension's main actionable groups (2 warning-level).
Enforce Explicit Debt in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.
Detailed fixes: d17_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether the project's documentation is clear, complete, and useful.
Method: 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 1 documentation facets pass in full. 76 document(s) read across 1 unit(s).
✓ On the Gold path — maintain.
Detailed fixes: d19_recommendation.md.
Do you agree with this assessment?
D20 · ADR Quality0.0 / 10Critical✓ Tool-verified
What it measures: Whether architecture decisions are recorded well (context, decision, consequences).
Method: Per-ADR judgment by language model at low temperature with two-pass stability; confidence is share of ADRs evaluated; enforcement-field presence detected deterministically. Advisory.
3 of 10 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: REDACTED 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.
1 finding(s): 0 critical, 1 high, 0 medium, 0 low. Remediation for historically-committed secrets is credential rotation — they remain in history regardless of later deletion.
REDACTED
REDACTED
What to do
Resolve the 1 REDACTED finding(s) in Secrets (history) — start with REDACTED. — One of this dimension's main actionable groups (1 issue-level).
Resolve the 1 Rotate the exposed credentials finding(s) in Secrets (history). — One of this dimension's main actionable groups (1 recommendation-level).
Detailed fixes: d28_recommendation.md · top locations in Appendix A, every location in findings.md.
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).
114 finding(s): 0 critical, 112 high, 1 medium, 1 low. 97 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 98 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), … (+93 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
+ 2 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Resolve the 5 REDACTED finding(s) in Static Analysis (SAST) — start with REDACTED (5). — One of this dimension's main actionable groups (5 issue-level).
Resolve the 4 REDACTED finding(s) in Static Analysis (SAST) — start with REDACTED (3), 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 97 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 (98 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.
+ 3 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.
3 of 391 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 391 of the 504 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 4 Change coupling finding(s) in Change Coupling — start with buck_check.rs, call_graph.rs, type_table.rs. — One of this dimension's main actionable groups (4 warning-level).
Resolve the 2 Change-coupling hub finding(s) in Change Coupling — start with binding_memory.rs, query_source_db.rs. — One of this dimension's main actionable groups (2 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. Scored 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. SCORED, not informational.
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 6 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.
What to do
The domain core is a small share of production code, but most of the rest matched no layer vocabulary at all — so this is not yet an anemic-domain finding. The namespace/path convention could not place that code, which makes the composition above a statement about the naming, not about the design. Name the layers (or check that the repository's conventions differ from the ones this check knows) before reading a thin domain into it.
Other · Architecture — Whether the project-reference graph is acyclic (cycles block independent build/deploy and signal eroding boundaries).
Method: Project reference cycles via elementary-DFS over real .csproj references, using the engine shared with D5/D7; cyclic versus acyclic. Exhaustive, deterministic.
Other · Architecture — Whether dependencies point inward (Domain ← Application ← Infrastructure/Web) — the clean-architecture dependency rule, checked across the project graph.
Method: Layer violations by name-segment inference (Domain/Core to Application to Infrastructure/Web) over the project-reference graph. Exhaustive over all projects, deterministic.
Other · Architecture — Whether interfaces stay focused rather than fat — the Interface-Segregation principle (SOLID 'I').
Method: Roslyn scan: public interface declared-member counts (accessors fold into their property/event); fat-interface threshold (over 15 declared members) flagged per type. Each finding also reports the distinct-OPERATION count — members counted by name, so an overload group counts once — which decides whether it states the caller-side ISP harm or the implementer-side burden of an overload set. TypeScript: exported interfaces that declare behaviour, counted over their REQUIRED operations (method signatures and function-typed properties with no `?`, once per signature) — data-shape interfaces and ambient .d.ts declarations are outside the population; JavaScript declares no interfaces and is not applicable. Deterministic, type-level.
Do you agree with this assessment?
AX8 · Test isolation10.0 / 10Exemplary✓ Tool-verified
Other · Architecture — Whether production projects stay free of references to test projects — tests may depend on production, never the reverse.
Method: Csproj graph: each production project checked for references to test projects (identified by test-framework presence, not name). Zero violations is clean. Deterministic.
Other · Architecture — Whether read (query) handlers stay side-effect-free — a query that writes persistent state or raises events breaks CQS and makes reads unsafe to retry, cache, or route to a read replica.
Method: Roslyn scan: CQRS handlers classified query-vs-command by interface (IQueryHandler/ICommandHandler/IRequestHandler<TQuery,TResult>) and name convention (*Query/Get*/Find* vs *Command); each query handler's body checked for persistent-state writes (SaveChanges/repository Add-Update) or event publishes by resolved invocation. Deterministic, type-level, exhaustive over the detected handlers.
Coverage: Population: CQRS handlers identified by IQueryHandler/ICommandHandler/IRequestHandler interface + *Query/Get*/Find*/*Command NAME convention; query purity then checked exhaustively within that set — a query handler using neither convention is invisible, and mutation is a resolved persistence/publish CALL, not full dataflow.
`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:1464
`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:1527
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 repo and its projects have a README, and whether it's substantive and current.
Method: Filesystem scan: README presence, word count, and headings for depth; git history for staleness. Exhaustive across root and project dirs, deterministic.
What to do
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.
Add an 'Architecture' / 'How it works' section to the root README — the high-level shape.
Add a README to the 11 of 21 project(s) that lack one — worth up to 1 pts.
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 README actually describes the code that exists (LLM-judged, advisory).
Method: Judged by language model at low temperature: README accuracy versus actual projects, within a disclosed tolerance. Advisory, not a measured number.
Readiness · Readiness — Whether an automated pipeline builds and tests every change.
Method: Filesystem scan: CI workflow files (.github/workflows, .gitlab-ci.yml, etc.) for build and test stages. Exhaustive, deterministic.
Do you agree with this assessment?
P10 · Library API & versioning10.0 / 10Exemplary○ Nothing flagged
Readiness · Readiness — For a library: a deliberate (small) public API surface and explicit semantic versioning so consumers can depend on it safely.
Method: Roslyn scan: public API surface area and semantic-versioning markers (SemVer attributes, changelog entries) for libraries; off .NET, a library is the ecosystem's publication act (an npm package that is not private and names an entry point, a PyPI distribution with a build system, a Rust library crate, a Maven/Gradle module that publishes, a Go module with no package main, a gemspec, a Composer library, a SwiftPM library product, a pub.dev or Hex package), its surface is the share of types the language model records as public (Rust, Swift, Java, Kotlin, Go, Dart; not measured where the model records no type visibility or, as in TypeScript, only module-level export), and its version is read from the manifest, a semver CHANGELOG, release tooling or semver git tags. Exhaustive, deterministic.
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.
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 the language 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.
Do you agree with this assessment?
R1 · Type Safety8.1 / 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.
What to do
Migrate the remaining .js/.jsx files to TypeScript.
React / JS · Code Health — Near-exact copy-pasted blocks of substantial extent across the frontend (the D4 clone algorithm over JS/TS tokens, D-386): 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. Deterministic.
lsp/src/extension.ts:141 · lsp/src/extension.ts:409 — 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:141
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.
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
What to do
Break down the listed branch-heavy functions; aim P95 cyclomatic ≤ 5.
Do you agree with this assessment?
R3 · Large Files6.0 / 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 534 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 Coverage8.0 / 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. (×2) — 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 any branch is dead by construction — a switch arm whose label can never equal a case-normalised subject, or an `else if` whose predicate the arm above has already swallowed.
Method: Roslyn syntax + semantics: switch labels compared against the subject's own case normaliser, and if/else-if chains checked for a literal an earlier arm's containment test already swallows. Deterministic, provable per finding. Advisory.
Do you agree with this assessment?
X13 · Undrained process stream10.0 / 10Exemplary○ Nothing flagged
Other · Code Health — Whether a child process that has BOTH standard streams redirected drains both — reading one to the end while the other is never read deadlocks once the child fills the unread pipe.
Method: Roslyn syntax + semantics: ProcessStartInfo launches with both streams redirected, checked for a drain of each stream across the enclosing type. 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 `spawn` imported from `child_process` whose stdout and stderr are both pipes (no options, no `stdio`, or `stdio` of `'pipe'`), bound to a local that never leaves its scope, where exactly one of the two streams is read, the other never, and the child’s `close`/`exit` (or the read stream’s end) is awaited; a shell redirect in the call’s arguments or a `kill` of the child suppresses it. The same rule reads Python’s `subprocess.Popen`, Dart’s `Process.start`, Ruby’s `Open3.popen3`, and Scala’s JDK process starts (`new ProcessBuilder(…).start()` with no `redirectErrorStream`/`redirectError`/`redirectOutput`/`inheritIO`, `Runtime.getRuntime.exec`) where one of `getInputStream`/`getErrorStream` is read and the other never while `waitFor()` is called or the read stream is read to its end. Deterministic, provable per finding. Advisory.
Other · Security — Whether a hand-rolled public/private IP check can be walked past — a method that unwraps IPv4-mapped IPv6 but returns the opposite verdict for the same host written as IPv4-compatible, 6to4 or NAT64.
Method: Roslyn syntax + semantics: methods that unwrap IPv4-mapped IPv6 and hand-roll IPv4 range carve-outs, checked for whether the IPv6 branch also accounts for the IPv4-compatible, 6to4 and NAT64 embeddings. Deterministic, provable per finding. Advisory.
Do you agree with this assessment?
X15 · Unvalidated length from an untrusted reader10.0 / 10Exemplary○ Nothing flagged
Other · Security — Whether a length read out of the stream being parsed is bounded before it is allocated or read — an unchecked count taken from the input lets the input choose the allocation.
Method: Roslyn syntax + semantics: integer lengths read from a BinaryReader and spent on a bulk read or an array allocation, checked for any comparison or bounding call on the value anywhere in the method. Deterministic, provable per finding. Advisory.
Other · Code Health — Whether a loop that shortens a string until it fits a length budget has a floor — one with none grinds the value down to the empty string, or past it into a negative-length `Substring`.
Method: Roslyn syntax + semantics: while/do loops whose body's only effect on a string is to drop its last character, checked for whether anything — a direct comparison on the length, a body guard, a break — bounds that length below. 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 `while`/`do` loop whose body’s one assignment to a value is `x = x.slice(0, -1)` or `x = x.slice|substring|substr(0, x.length - 1)`, driven by a condition that reads `x.length` only as a term of a larger expression — never compared directly, never tested for truthiness, and with no other read of `x` — and whose body has no `break`, `return`, `throw` or `if` naming `x`. Deterministic, provable per finding. Advisory.
Do you agree with this assessment?
X17 · Uncapped recursion over a caller-supplied document2.7 / 10Weak✓ Tool-verified
Other · Security — Whether a walk that recurses through a JSON/XML tree handed in by its caller bounds how deep it will go — an uncapped walk lets the document's nesting choose the stack depth, and the resulting StackOverflowException cannot be caught.
Method: Roslyn syntax + semantics: methods that take a JSON/XML document node and call themselves with a child of it, reachable from an externally-callable member of the same type that accepts a document, checked for any depth parameter, descent counter or threaded arithmetic anywhere in the walk. On a repository with no .NET source it reads TypeScript off the engine’s own token stream (test, vendored, generated and minified paths and `.d.ts` not) with the same rule: a function or method with a parameter typed as a document value — `unknown`, `any`, `object`, `Record<string, unknown|any>`, a JSON alias (`JsonValue`, `JSONObject`, …) or a DOM node global the file does not rebind — that calls itself (bare, or through `this` for a method, or hands itself to a call over the value as in `value.map(walk)`) with something it took out of that value and never through an ancestor accessor such as `closest()` or `parentElement`, that is exported or reached from an exported function (a public method of the same exported class) taking such a value, and that names no depth, level, nesting, recursion, remaining or budget anywhere and threads no `+`/`-` arithmetic through a self-call. Plain JavaScript is not read: with no annotation nothing tells a parsed document from a tree the code built itself. Deterministic, provable per finding. Advisory.
`format_type` is public and takes `ty: dict[str, Any]` from its caller, and it calls itself at line 97 (`format_type`) with a piece of `ty` (and at line 103, line 112, line 117, line 118, line 125, line 126, line 133) — and nowhere in `format_type` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `format_type` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack. — pyrefly/lib/report/cinderx/view_types.py:97
`convert_type_reference` is public and takes `type_def: Dict[str, Any]` from its caller, and it calls itself at line 321 (`convert_type_reference`) with a piece of `type_def` (and at line 324, line 327, line 334, line 349) — and nowhere in `convert_type_reference` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `convert_type_reference` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack. — crates/tsp_types/protocol_generator/generate_protocol.py:321
What to do
Each finding names the externally-callable member that accepts the document and the self-call that descends, and states that no depth parameter or counter exists anywhere in the walk. Confirm from the two, then thread a depth argument through the walk and reject documents past a fixed maximum, or rewrite it with an explicit stack.
Other · Code Health — Whether a type's disposal matches what it OWNS — releasing what it created, leaving alone what it was handed, and not declaring a finalizer for state that has nothing unmanaged to finalize.
Method: Roslyn syntax + semantics: every assignment to a disposable field is read to decide whether the type CREATED the value or was handed it, and the type's disposal is checked against that answer — an injected interface it disposes, a value it constructed and never releases, a finalizer on a type holding nothing unmanaged, and a disposable local whose every reference is a plain member read. A value handed to a container that disposes its contents (a parent control's `Controls` collection, a component `IContainer`) is released by that container and is not reported; generated code is out of population. On a repository with no .NET source the same ownership questions are read in JavaScript/TypeScript off the engine’s own token stream (test, vendored, generated and minified paths not): a class declaring `dispose()`, `[Symbol.dispose]()` or `[Symbol.asyncDispose]()` that disposes a field it was handed through a constructor parameter typed as a repository interface or resolved by a dependency-injection container; that assigns a field only ever from `new X(…)` of a disposable class and neither releases it anywhere in the class nor names it in its disposal member or a method that member calls, nor hands it to anything else; and a `const`/`let` local built from literals only whose every reference opens a statement operating on a non-release member of it. A class is disposable when every repository declaration of its name declares or inherits a disposal member, or when it is a documented library disposable (`vscode` EventEmitter, CancellationTokenSource and Disposable; three.js geometries, materials, textures, render targets, renderers, controls and composers). The finalizer arm has no JavaScript counterpart: a class cannot declare one. Dart is read for the owned-and-never-released arm: a Flutter `State` (or a class declaring `dispose()`/`close()`) whose library-private field is written only with direct creations of a framework controller, `FocusNode`, `StreamController` or periodic `Timer` (or a `.listen(…)` into a field declared `StreamSubscription`), which nothing in the class or its library releases (`dispose`/`close`/`cancel`) and which is never handed on except as a named argument. Ruby is read for the owned-and-never-released arm and the abandoned-local arm: a class declaring an instance `close`, `dispose`, `shutdown`, `stop`, `disconnect` or `terminate` whose instance variable is written only with a blockless core descriptor creation (`File.open`/`new`, `Tempfile`, `Dir.open`, `IO.popen`, the `socket` and `openssl` socket classes) that no method of the class closes and that is never handed on (passed, returned, stored, exposed by `attr_reader`, delegated) — a class whose superclass or mixin lies outside the repository is not judged — and a blockless creation read through and dropped (`File.open(path).read`) or held in a local that is never closed, returned, passed or stored (a `&:read` block-pass, an `autoclose: false` borrow and a `fileno` hand-over are not abandonment). PHP is read for the same two arms: a class (not a trait, and not one using a trait) declaring an instance `close`, `dispose`, `shutdown`, `stop`, `disconnect` or `terminate` whose `private` property (or a `final` class's `protected` one) is written only with a direct core `fopen`, `tmpfile`, `popen`, `proc_open`, `fsockopen`, `stream_socket_client`/`server` or `opendir` that nothing in the class closes (`fclose`, `pclose`, `closedir`, `unset`, a reset to `null`) and that is never handed on, and a handle held in a function's local, or read through as the argument of a reader, that is never closed, returned, passed, captured or stored; a `php://` stream, `curl_init`, `SplFileObject`, `PDO` and a function the repository declares under the core name are not read. Deterministic, provable per finding. Advisory.
Other · Code Health — Whether a method that temporarily changes state belonging to the whole process — the working directory, an environment variable — puts it back on EVERY path: a restore reached only when nothing throws leaks the change to the rest of the process.
Method: Roslyn syntax + semantics: method bodies that write the process working directory or an environment variable and write it back in the same body, checked for whether that restore sits in a `finally`/`catch` or only on the straight-line path. On a repository with no .NET source the same rule reads production JavaScript/TypeScript off the engine’s own token stream (test, vendored and minified paths not): `process.chdir`, `process.env.NAME =`/`["NAME"] =` and `delete process.env.NAME`, and Deno’s `Deno.chdir`/`Deno.env.set`/`Deno.env.delete`, paired per function body (a nested function or arrow is its own body, and module top-level code is none), where the last write puts back a local the body captured from the same global or deletes a variable the first write set, with at least one statement between them; a write in a `catch`/`finally` of that body silences it. Deterministic, provable per finding. Advisory.
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.
Other · Code Health — Whether a method that TAKES a lock or semaphore and gives it back from a flag-guarded `finally` returns the value that flag implies — reporting success while the guard hands the primitive back admits a second caller the exclusion was there to keep out, and reporting failure while the guard keeps it leaves nothing to ever give it back.
Method: Roslyn syntax: `try` statements whose `finally` releases a synchronisation primitive under a bare local-bool guard, where the method also TOOK that same primitive before the `try`, checked for a `return` of a bool literal whose value disagrees with the flag state the method's own straight-line assignments put it in. Deterministic, provable per finding. Advisory.
Other · Code Health — Whether the work a diagnostic log line costs is paid only when that line is wanted — C# evaluates a call's arguments BEFORE the call, so a trace/debug message joined or projected out of a collection is built in full on every pass, and then discarded by a sink the shipped configuration leaves switched off.
Method: Roslyn syntax: log calls at a diagnostic level (a `Log`-prefixed method naming Trace/Debug/Verbose, or a bare `Debug`/`Trace`/`Verbose` on a receiver named for a logger), whose argument list is read for a call whose cost scales with a sequence — a LINQ operator, a materialisation, `string.Join`, a serializer — with no enclosing level check or conditional-compilation region. 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 `debug`/`trace`/`verbose` call on a receiver named for a logger, or a `log`-prefixed method naming the level, whose argument calls an array operator (`map`/`filter`/`reduce`/`sort`/…), `Array.from`, `Object.keys/values/entries`, `JSON.stringify`/`util.inspect` over anything but a literal, or an array `join` — outside any arrow or function passed as an argument, which the logger calls only when the level is on — with no enclosing `if`, `&&` or `?:` whose condition names a level, a level string, or the `NODE_ENV`/`__DEV__`/`DEV` build switch. Deterministic, provable per finding. Advisory.
Do you agree with this assessment?
X24 · Document value interpolated into markup unescaped10.0 / 10Exemplary○ Nothing flagged
Other · Security — Whether text read out of the document being converted is escaped before it is written into generated markup — a value the document's author chose, interpolated into an attribute the surrounding literal delimits, can close that attribute and open another.
Method: Roslyn semantic model over the whole compilation: a string-typed `Value`/`InnerText`/`InnerXml`/`Text` member declared inside `DocumentFormat.OpenXml` or `System.Xml` is a taint SOURCE, propagated through assignments, returns, arguments, tuple elements and string composition to its transitive closure, then read at interpolated-string holes that sit in a markup position the surrounding literal itself delimits. Escaper/encoder calls and enclosing validator conditions cut the flow. Flow- and container-insensitive by construction. A second arm needs no provenance at all and reports a type that CONTRADICTS ITSELF — the same expression escaped at one delimited markup hole and interpolated raw at another hole in the same markup position of the same type, which the type's own escaping proves is a defect without knowing where the value came from. On a repository with no .NET source it reads JavaScript/TypeScript off the token stream with the same rule: a DOM read of raw document text (`getAttribute`, `textContent`, `innerText`, `nodeValue`) is the source, propagated through local bindings and string composition, and judged at template-literal and concatenation holes in the same two delimited markup positions; escapers and validating conditions cut it, and documentation-site, test, vendored and minified scripts are not read. Deterministic, provable per finding. Advisory.
Other · Code Health — Whether a value the caller is invited to supply is the value the type actually uses — a constructor parameter stored in a private field that nothing ever reads while the default it was given is spelled out a second time at the site that should have read it, a keyed lookup that falls back to a different setting than the one its key names while the same type falls back to the matching one for that same key, or a culture-sensitive parse given no format provider by a type that feeds its own settable culture to the same kind of parse elsewhere, or a number an entry point writes to standard output under the host's culture while the same entry point formats with the invariant culture elsewhere. Either way, every caller who supplies a value silently gets something else.
Method: Roslyn syntax: private instance fields of a non-partial type assigned in a constructor from one of its own parameters with a `??` fallback, checked for whether anything in the type body reads the field and whether that same fallback expression is spelled out again outside the constructor; and `??` fallbacks onto a member access from a lookup call carrying exactly one string literal, grouped by that key across the type and checked for a fallback member whose folded name disagrees with the key while a sibling site for the same key agrees with it. On a repository with no .NET source the first two arms read JavaScript/TypeScript off the engine’s own token stream (tests included, bundles and vendored paths not): a `#x`, `private` or `private` parameter-property instance field filled in the constructor from a parameter (or one member of one) through `??`/`||` or a parameter default, never read anywhere in the file by name, whose constructed default is spelled again in the class body; and `lookup("key") ?? s.member` grouped by key per class, or per module outside every class. The culture arm has no JavaScript counterpart: its parses take no locale. Deterministic, provable per finding. Advisory.
Other · Code Health — Whether a value handed from a callback to the body that waits on it crosses on something built to be crossed — a `Queue<T>`/`List<T>`/`Dictionary<K,V>` written inside an event handler and read back outside it is mutated by two flows at once, and the semaphore or completion source beside it orders how MANY items exist while leaving the collection's own head, tail and backing array unprotected.
Method: Roslyn syntax: method, accessor, local-function and lambda bodies that declare BOTH a non-thread-safe generic collection (`Queue`/`Stack`/`List`/`Dictionary`/`HashSet`/`Sorted*`/`LinkedList`) and a synchronisation primitive (`SemaphoreSlim`/`TaskCompletionSource`/`ManualResetEvent(Slim)`/`AutoResetEvent`/`CountdownEvent`) as locals, then read for a `+=`-registered lambda that raises that primitive while the body outside every lambda waits on it — and, in that scope, a mutating call on the collection inside the lambda paired with a mention of it outside. Any `lock` in the scope abstains it. On a repository with no .NET source the same handoff is read in Java off the engine’s own token stream (test source sets, vendored and demonstration paths not): an `ArrayList`/`LinkedList`/`ArrayDeque`/`PriorityQueue`/`Hash*`/`LinkedHash*`/`Tree*` local and a `CountDownLatch`/`Semaphore`/`CompletableFuture` local, a lambda or anonymous class that raises the primitive and mutates the collection, and a wait outside it; any `synchronized` or `lock()` abstains the body. Because each of those primitives orders what the callback wrote before raising it, only a touch that provably overlaps the callback is convicted: one after the registration and before the next wait, or one in a loop registered-before, waiting on every pass and not declaring the collection. 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.
Other · Code Health — Whether exceptions are handled rather than silently swallowed or rethrown with lost stack traces.
Method: Roslyn syntax scan: every catch clause counted; empty catches and bare rethrows flagged. Population is all catch clauses, not estimated. Deterministic, hard fact.
`.catch(() => {})` handles the rejection by doing nothing — the failure is discarded with no log and no rethrow, and the chain carries on as if the work succeeded. Log it through whatever this codebase already uses to report problems, hand it to a caller that can (`next(error)`, a returned rejection), or don't catch it. (×3) — lsp/src/extension.ts:63, lsp/src/extension.ts:92, lsp/src/python-environment.ts:134
An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it. — lsp/src/python-environment.ts:51
What to do
Swallowed exception (empty catch)
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.
`warning` at line 69 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.warning("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.warning("order moved", order_id=order_id, status=status)` with structlog. — scripts/compare_typecheckers.py:69
`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. (×2) — scripts/compare_typecheckers.py:90, REDACTED:90
`info` at line 100 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. — scripts/compare_typecheckers.py:100
`info` at line 102 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. — scripts/compare_typecheckers.py:102
`warning` at line 150 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.warning("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.warning("order moved", order_id=order_id, status=status)` with structlog. — scripts/compare_typecheckers.py:150
`debug` at line 177 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.debug("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.debug("order moved", order_id=order_id, status=status)` with structlog. — scripts/compare_typecheckers.py:177
`debug` at line 189 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.debug("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.debug("order moved", order_id=order_id, status=status)` with structlog. — scripts/compare_typecheckers.py:189
`debug` at line 196 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.debug("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.debug("order moved", order_id=order_id, status=status)` with structlog. — scripts/compare_typecheckers.py:196
`info` at line 423 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. — scripts/compare_typecheckers.py:423
`info` at line 441 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. — scripts/compare_typecheckers.py:441
`info` at line 490 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. — scripts/compare_typecheckers.py:490
`warning` at line 574 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.warning("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.warning("order moved", order_id=order_id, status=status)` with structlog. — scripts/compare_typecheckers.py:574
`info` at line 702 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. — scripts/compare_typecheckers.py:702
`info` at line 771 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. — scripts/compare_typecheckers.py:771
`info` at line 788 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. — scripts/compare_typecheckers.py:788
`error` at line 803 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. — scripts/compare_typecheckers.py:803
`info` at line 884 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. — scripts/compare_typecheckers.py:884
`info` at line 886 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. — scripts/compare_typecheckers.py:886
`info` at line 894 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. — scripts/compare_typecheckers.py:894
`warning` at line 37 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.warning("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.warning("order moved", order_id=order_id, status=status)` with structlog. — scripts/setup_primer_deps.py:37
`info` at line 40 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. — scripts/setup_primer_deps.py:40
`info` at line 42 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. — scripts/setup_primer_deps.py:42
`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
`error` at line 326 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:326
`error` at line 341 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:341
`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 729 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:729
`debug!` at line 1646 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:1646
`debug!` at line 2278 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:2278
`info!` at line 2706 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:2706
`debug!` at line 3289 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:3289
`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
`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
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 — 53 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.
AC7 A11y enforcement — 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
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 did not expose a crawlable HTTP endpoint in time — no runtime evidence 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 is measured on C# only; JavaScript, Python, Rust, TypeScript, html 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+ projects each declaring an entity of their own. Declaring this codebase's bounded contexts (≥2) would let cross-boundary type coupling be assessed. Declare them in `.codehealth/config.yaml` at the repository root (create it if absent), mapping each context name to the module-path or namespace prefixes that belong to it — e.g. `architecture:` → `contexts:` → `Billing: ["src/billing", "Acme.Billing"]`, `Catalog: ["src/catalog", "Acme.Catalog"]`.
D24 Comment Value — D24 reads C# and Visual Basic comments only — this repository's production source is .py, .rs, .ts, .tsx, which was left unread. Not scored: this is a gap in the analyzer, not a verdict about this repository.
D25 ADR Conformance — no ADRs to check
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) — 55 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.
D39 IL Efficiency — D39 measures the IL emitted by a .NET build; this repository has no .NET solution or project files, so the dimension does not apply.
D40 Network Egress Confinement — No Kubernetes/orchestration workloads found in the repository manifests; network egress policy is a cluster-native control that may live at the platform/firewall layer, so there is nothing to assess here.
D41 Kernel & Syscall Confinement — No Kubernetes/orchestration workloads found in the repository manifests; seccomp/AppArmor/SELinux confinement is a workload-level control, so there is nothing to assess here.
D42 Runtime Threat Enforcement — No Kubernetes/orchestration workloads found in the repository manifests; runtime threat-detection and admission-control policy are cluster-level controls, so there is nothing to assess here.
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): 418 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 — no coverage report found on disk — produce a coverage report in a standard format (lcov — `cargo install cargo-llvm-cov`, then `cargo llvm-cov --lcov --output-path lcov.info`) and commit it — a hosted scan measures a clone of the repository, so a report that exists only in a working tree, a CI runner's or your own, never reaches it; the artefact is commonly gitignored, so `git add -f` that one file (or un-ignore its path) and commit it alongside the code it measures, or wire coverage collection into CI, to enable this cross-layer check
PF2 Allocation hygiene — Not applicable: Rust spells out every heap allocation and makes borrowed slices (&[T], &str) its ordinary parameter types, so the allocation-aware style this card rewards elsewhere is the language's baseline rather than a rung to climb.
R11 Import Boundaries — No recognizable feature-sliced/layered src layout — boundary rules not applicable.
S1 Web-Security Posture — No web surface: 448 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.
X2 Cancellation propagation — no C# was loaded; this repository's Python and Rust were read, and no request in it can be cancelled by a caller — a Python request takes no token: asyncio cancels the task and trio or anyio the scope that made it, from outside the call, and requests, httpx, aiohttp and gRPC take a timeout, not a cancellation; a Rust request takes no token: a future is cancelled by dropping it, from outside the call (select!, a timeout, an aborted task), and reqwest, hyper and tonic take none
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.
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:1464— `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:1527— `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:58— // 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:90— # 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 390) pyrefly/lib/alt/callable.rs:948— AnswersSolver::callable_infer_params has cognitive complexity 390 (threshold 15). Drivers by points: if/else 93 (253 pts), match/switch 26 (81 pts), loops 16 (36 pts), boolean chains 20 (nesting depth added 235). Of this number, 389 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 206) pyrefly/lib/alt/class/class_field.rs:1614— AnswersSolver::calculate_class_field has cognitive complexity 206 (threshold 15). Drivers by points: if/else 76 (139 pts), boolean chains 36, match/switch 10 (22 pts), loops 3 (9 pts) (nesting depth added 81). To reduce it, split the body into named stages: move each independent 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 167) pyrefly/lib/alt/narrow.rs:1404— AnswersSolver::atomic_narrow has cognitive complexity 167 (threshold 15). Drivers by points: if/else 60 (127 pts), match/switch 7 (20 pts), loops 4 (12 pts), boolean chains 8 (nesting depth added 88). 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::as_call_target_impl (cognitive 118) pyrefly/lib/alt/call.rs:378— AnswersSolver::as_call_target_impl has cognitive complexity 118 (threshold 15). Drivers by points: if/else 32 (71 pts), match/switch 17 (38 pts), loops 3 (9 pts) (nesting depth added 66). 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 117) pyrefly/lib/alt/class/class_field.rs:4229— AnswersSolver::check_consistent_override_for_field has cognitive complexity 117 (threshold 15). Drivers by points: if/else 42 (79 pts), boolean chains 24, match/switch 5 (10 pts), loops 2 (4 pts) (nesting depth added 44). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AnswersSolver::validate_type_shape_dsl_declaration (cognitive 109) pyrefly/lib/alt/type_level_dsl.rs:290— 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:423— 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::lookup_attr_static1 (cognitive 100) pyrefly/lib/alt/attr.rs:1775— AnswersSolver::lookup_attr_static1 has cognitive complexity 100 (threshold 15). Drivers by points: if/else 25 (48 pts), match/switch 17 (40 pts), boolean chains 7, loops 2 (5 pts) (nesting depth added 49). 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::call_functools_partial (cognitive 92) pyrefly/lib/alt/functools.rs:45— AnswersSolver::call_functools_partial has cognitive complexity 92 (threshold 15). Drivers by points: if/else 30 (51 pts), match/switch 12 (24 pts), loops 5 (13 pts), boolean chains 4 (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::subscript_infer_for_type_with_key_present_inner (cognitive 91) pyrefly/lib/alt/expr.rs:3874— AnswersSolver::subscript_infer_for_type_with_key_present_inner has cognitive complexity 91 (threshold 15). Drivers by points: if/else 30 (56 pts), match/switch 12 (23 pts), boolean chains 12 (nesting depth added 37). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AnswersSolver::expr_infer_impl_helper (cognitive 82) pyrefly/lib/alt/expr.rs:935— AnswersSolver::expr_infer_impl_helper has cognitive complexity 82 (threshold 15). Drivers by points: if/else 28 (47 pts), match/switch 15 (31 pts), boolean chains 2, loops 1 (2 pts) (nesting depth added 36). 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 82) pyrefly/lib/alt/special_calls.rs:549— AnswersSolver::check_type_is_class_object has cognitive complexity 82 (threshold 15). Drivers by points: if/else 18 (62 pts), loops 3 (14 pts), boolean chains 6 (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::tuple_infer (cognitive 71) pyrefly/lib/alt/expr.rs:2044— 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:841— 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::dict_items_infer_inner (cognitive 69) pyrefly/lib/alt/expr.rs:2331— AnswersSolver::dict_items_infer_inner has cognitive complexity 69 (threshold 15). Drivers by points: if/else 20 (52 pts), boolean chains 11, loops 1 (4 pts), match/switch 1 (2 pts) (nesting depth added 36). 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 68) pyrefly/lib/alt/attr.rs:2589— AnswersSolver::as_attribute_base1 has cognitive complexity 68 (threshold 15). Drivers by points: if/else 16 (39 pts), loops 8 (25 pts), match/switch 2 (3 pts), boolean chains 1 (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 67) pyrefly/lib/alt/narrow.rs:2113— AnswersSolver::narrow has cognitive complexity 67 (threshold 15). Drivers by points: if/else 20 (38 pts), match/switch 10 (21 pts), boolean chains 5, loops 1 (3 pts) (nesting depth added 31). To reduce it, split the body into named stages: move each independent 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::solve_expectation (cognitive 63) pyrefly/lib/alt/solve.rs:2816— AnswersSolver::solve_expectation has cognitive complexity 63 (threshold 15). Drivers by points: if/else 13 (30 pts), match/switch 7 (18 pts), boolean chains 11, loops 2 (4 pts) (nesting depth added 30). Of this number, 57 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::as_attribute_base1_of_type (cognitive 58) pyrefly/lib/alt/attr.rs:2876— AnswersSolver::as_attribute_base1_of_type has cognitive complexity 58 (threshold 15). Drivers by points: if/else 10 (29 pts), loops 7 (24 pts), match/switch 3 (5 pts) (nesting depth added 38). 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::class_metadata_of (cognitive 58) pyrefly/lib/alt/class/class_metadata.rs:188— AnswersSolver::class_metadata_of has cognitive complexity 58 (threshold 15). Drivers by points: if/else 22 (30 pts), boolean chains 16, match/switch 3 (7 pts), 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.
AnswersSolver::check_consistent_multiple_inheritance (cognitive 57) pyrefly/lib/alt/class/class_field.rs:4710— 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::decorated_function_type (cognitive 57) pyrefly/lib/alt/function.rs:773— AnswersSolver::decorated_function_type has cognitive complexity 57 (threshold 15). Drivers by points: if/else 22 (34 pts), boolean chains 19, 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::binding_to_type_unpacked_value (cognitive 56) pyrefly/lib/alt/solve.rs:5285— AnswersSolver::binding_to_type_unpacked_value has cognitive complexity 56 (threshold 15). Drivers by points: if/else 15 (32 pts), match/switch 7 (20 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::call_infer_with_callee_range (cognitive 54) pyrefly/lib/alt/call.rs:1767— AnswersSolver::call_infer_with_callee_range has cognitive complexity 54 (threshold 15). Drivers by points: if/else 16 (27 pts), match/switch 5 (14 pts), boolean chains 7, 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.
MethodTooLong: BindingsBuilder.stmt_impl pyrefly/lib/binding/stmt.rs:867— MethodTooLong — stmt_impl runs 892 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 792 over it, 8.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.callable_infer_params pyrefly/lib/alt/callable.rs:948— MethodTooLong — callable_infer_params runs 813 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 713 over it, 8.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: Subset.is_subset_eq_no_recursive_check pyrefly/lib/solver/subset.rs:1926— MethodTooLong — is_subset_eq_no_recursive_check runs 710 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 610 over it, 7.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: StructurallyValidatedTypeShapeDslFunction.evaluate_expression crates/pyrefly_types/src/type_level_dsl.rs:6985— MethodTooLong — evaluate_expression runs 709 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 609 over it, 7.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.
MethodTooLong: AnswersSolver.calculate_class_field pyrefly/lib/alt/class/class_field.rs:1614— MethodTooLong — calculate_class_field runs 694 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 594 over it, 6.94× 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:2094— MethodTooLong — process_event runs 621 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 521 over it, 6.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.
MethodTooLong: TypeDisplayContext.fmt_helper_generic crates/pyrefly_types/src/display.rs:917— MethodTooLong — fmt_helper_generic runs 596 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 496 over it, 5.96× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: AnswersSolver.validate_type_shape_dsl_declaration pyrefly/lib/alt/type_level_dsl.rs:290— MethodTooLong — validate_type_shape_dsl_declaration runs 527 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 427 over it, 5.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: AnswersSolver.subscript_infer_for_type_with_key_present_inner pyrefly/lib/alt/expr.rs:3874— MethodTooLong — subscript_infer_for_type_with_key_present_inner runs 440 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 340 over it, 4.40× 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:284— MethodTooLong — bind_pattern runs 408 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 308 over it, 4.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.expr_infer_impl_helper pyrefly/lib/alt/expr.rs:935— MethodTooLong — expr_infer_impl_helper runs 391 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 291 over it, 3.91× 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:4651— 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.atomic_narrow pyrefly/lib/alt/narrow.rs:1404— MethodTooLong — atomic_narrow runs 342 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 242 over it, 3.42× 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:378— MethodTooLong — as_call_target_impl runs 334 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 234 over it, 3.34× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: Subset.is_subset_eq_var pyrefly/lib/solver/solver.rs:3881— MethodTooLong — is_subset_eq_var runs 328 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 228 over it, 3.28× 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:8131— 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: Transaction.find_definition pyrefly/lib/state/lsp.rs:2888— MethodTooLong — find_definition runs 325 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 225 over it, 3.25× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: AnswersSolver.class_metadata_of pyrefly/lib/alt/class/class_metadata.rs:188— MethodTooLong — class_metadata_of runs 322 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 222 over it, 3.22× 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:4229— MethodTooLong — check_consistent_override_for_field runs 320 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 220 over it, 3.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.
MethodTooLong: BindingsBuilder.ensure_expr pyrefly/lib/binding/expr.rs:781— 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: CheckArgs.finish_cli_run pyrefly/lib/commands/check.rs:1907— MethodTooLong — finish_cli_run runs 303 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 203 over it, 3.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.
MethodTooLong: DefinitionsBuilder.stmt pyrefly/lib/export/definitions.rs:582— MethodTooLong — stmt runs 293 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 193 over it, 2.93× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: AnswersSolver.is_class_attribute_subset pyrefly/lib/alt/class/class_field.rs:5833— MethodTooLong — is_class_attribute_subset runs 291 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 191 over it, 2.91× 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: Binding.fmt pyrefly/lib/binding/binding.rs:2758— MethodTooLong — fmt runs 273 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 173 over it, 2.73× 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:1767— MethodTooLong — call_infer_with_callee_range runs 268 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 168 over it, 2.68× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
AnswersSolver::callable_infer_params (cyclomatic 155) pyrefly/lib/alt/callable.rs:948— AnswersSolver::callable_infer_params has cyclomatic complexity 155 (threshold 15). Of this number, 153 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 125) pyrefly/lib/alt/class/class_field.rs:1614— AnswersSolver::calculate_class_field has cyclomatic complexity 125 (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 120) pyrefly/lib/alt/narrow.rs:1404— AnswersSolver::atomic_narrow has cyclomatic complexity 120 (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 88) pyrefly/lib/alt/call.rs:378— AnswersSolver::as_call_target_impl has cyclomatic complexity 88 (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 84) pyrefly/lib/alt/expr.rs:3874— AnswersSolver::subscript_infer_for_type_with_key_present_inner has cyclomatic complexity 84 (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::validate_type_shape_dsl_declaration (cyclomatic 80) pyrefly/lib/alt/type_level_dsl.rs:290— 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 76) pyrefly/lib/alt/attr.rs:2589— AnswersSolver::as_attribute_base1 has cyclomatic complexity 76 (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::lookup_attr_static1 (cyclomatic 71) pyrefly/lib/alt/attr.rs:1775— AnswersSolver::lookup_attr_static1 has cyclomatic complexity 71 (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 71) pyrefly/lib/alt/expr.rs:935— AnswersSolver::expr_infer_impl_helper has cyclomatic complexity 71 (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 68) pyrefly/lib/alt/class/class_field.rs:4229— AnswersSolver::check_consistent_override_for_field has cyclomatic complexity 68 (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 68) pyrefly/lib/alt/solve.rs:6802— AnswersSolver::binding_to_type 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::solve_expectation (cyclomatic 55) pyrefly/lib/alt/solve.rs:2816— AnswersSolver::solve_expectation has cyclomatic complexity 55 (threshold 15). Of this number, 50 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.
AnswersSolver::call_functools_partial (cyclomatic 51) pyrefly/lib/alt/functools.rs:45— AnswersSolver::call_functools_partial 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.
AnswersSolver::as_attribute_base1_of_type (cyclomatic 49) pyrefly/lib/alt/attr.rs:2876— 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::class_metadata_of (cyclomatic 47) pyrefly/lib/alt/class/class_metadata.rs:188— AnswersSolver::class_metadata_of 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::decorated_function_type (cyclomatic 44) pyrefly/lib/alt/function.rs:773— AnswersSolver::decorated_function_type 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::narrow (cyclomatic 43) pyrefly/lib/alt/narrow.rs:2113— AnswersSolver::narrow 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::subscript_str_literal (cyclomatic 43) pyrefly/lib/alt/subscript.rs:423— 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::parse_dimension_expr_with_context (cyclomatic 42) pyrefly/lib/alt/expr.rs:4857— AnswersSolver::parse_dimension_expr_with_context has cyclomatic complexity 42 (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_call_infer (cyclomatic 40) pyrefly/lib/alt/call.rs:2554— AnswersSolver::expr_call_infer 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.
AnswersSolver::is_class_attribute_subset (cyclomatic 39) pyrefly/lib/alt/class/class_field.rs:5833— AnswersSolver::is_class_attribute_subset has cyclomatic complexity 39 (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 36) pyrefly/lib/alt/call.rs:1767— AnswersSolver::call_infer_with_callee_range has cyclomatic complexity 36 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
AnswersSolver::check_fstring_format_spec_for_type (cyclomatic 36) pyrefly/lib/alt/expr.rs:542— 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::untype_opt_with_context (cyclomatic 36) pyrefly/lib/alt/solve.rs:7485— AnswersSolver::untype_opt_with_context 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.
AnswersSolver::resolve_type_shape_dsl_intrinsic (cyclomatic 36) pyrefly/lib/alt/type_level_dsl.rs:961— AnswersSolver::resolve_type_shape_dsl_intrinsic has cyclomatic complexity 36 (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.
Hotspot: crates/pyrefly_types/src/type_level_dsl.rs crates/pyrefly_types/src/type_level_dsl.rs:6985— crates/pyrefly_types/src/type_level_dsl.rs changed 84 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 279 in StructurallyValidatedTypeShapeDslFunction::evaluate_expression at line 6985. 3 of those changes were fix/bug commits, and the other 81 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-07-29..2026-10-27, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-29 08:23:10 -07:00' --until='2026-10-27 08:23:10 -07: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:1926— pyrefly/lib/solver/subset.rs changed 62 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 249 in Subset::is_subset_eq_no_recursive_check at line 1926. 8 of those changes were fix/bug commits, and the other 54 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-07-29..2026-10-27, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-29 08:23:10 -07:00' --until='2026-10-27 08:23:10 -07: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:1614— pyrefly/lib/alt/class/class_field.rs changed 85 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 125 in AnswersSolver::calculate_class_field at line 1614. 18 of those changes were fix/bug commits, and the other 67 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-07-29..2026-10-27, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-29 08:23:10 -07:00' --until='2026-10-27 08:23:10 -07: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:6802— pyrefly/lib/alt/solve.rs changed 143 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 68 in AnswersSolver::binding_to_type at line 6802. 11 of those changes were fix/bug commits, and the other 132 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-07-29..2026-10-27, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-29 08:23:10 -07:00' --until='2026-10-27 08:23:10 -07: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/alt/expr.rs pyrefly/lib/alt/expr.rs:3874— pyrefly/lib/alt/expr.rs changed 111 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 84 in AnswersSolver::subscript_infer_for_type_with_key_present_inner at line 3874. 9 of those changes were fix/bug commits, and the other 102 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-07-29..2026-10-27, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-29 08:23:10 -07:00' --until='2026-10-27 08:23:10 -07: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:2094— pyrefly/lib/lsp/non_wasm/server.rs changed 68 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 132 in Server::process_event at line 2094. 8 of those changes were fix/bug commits, and the other 60 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-07-29..2026-10-27, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-29 08:23:10 -07:00' --until='2026-10-27 08:23:10 -07: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:948— pyrefly/lib/alt/callable.rs changed 56 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 155 in AnswersSolver::callable_infer_params at line 948. 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-07-29..2026-10-27, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-29 08:23:10 -07:00' --until='2026-10-27 08:23:10 -07: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: pyrefly/lib/alt/type_level_dsl.rs pyrefly/lib/alt/type_level_dsl.rs:290— pyrefly/lib/alt/type_level_dsl.rs changed 78 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 290. 2 of those changes were fix/bug commits, and the other 76 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-07-29..2026-10-27, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-29 08:23:10 -07:00' --until='2026-10-27 08:23:10 -07: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/binding/stmt.rs pyrefly/lib/binding/stmt.rs:867— pyrefly/lib/binding/stmt.rs changed 37 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 164 in BindingsBuilder::stmt_impl at line 867. 7 of those changes were fix/bug commits, and the other 30 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-07-29..2026-10-27, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-29 08:23:10 -07:00' --until='2026-10-27 08:23:10 -07: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: crates/pyrefly_types/src/display.rs crates/pyrefly_types/src/display.rs:917— crates/pyrefly_types/src/display.rs changed 38 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 154 in TypeDisplayContext::fmt_helper_generic at line 917. 5 of those changes were fix/bug commits, and the other 33 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-07-29..2026-10-27, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-29 08:23:10 -07:00' --until='2026-10-27 08:23:10 -07: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/call.rs pyrefly/lib/alt/call.rs:378— pyrefly/lib/alt/call.rs changed 65 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 88 in AnswersSolver::as_call_target_impl at line 378. 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-07-29..2026-10-27, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-29 08:23:10 -07:00' --until='2026-10-27 08:23:10 -07: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:2758— pyrefly/lib/binding/binding.rs changed 66 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 76 in Binding::fmt at line 2758. 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-07-29..2026-10-27, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-29 08:23:10 -07:00' --until='2026-10-27 08:23:10 -07: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/narrow.rs pyrefly/lib/alt/narrow.rs:1404— pyrefly/lib/alt/narrow.rs changed 39 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 120 in AnswersSolver::atomic_narrow at line 1404. 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-07-29..2026-10-27, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-29 08:23:10 -07:00' --until='2026-10-27 08:23:10 -07: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/solver/solver.rs pyrefly/lib/solver/solver.rs:3881— pyrefly/lib/solver/solver.rs changed 85 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 3881. 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-07-29..2026-10-27, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-29 08:23:10 -07:00' --until='2026-10-27 08:23:10 -07: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/alt/attr.rs pyrefly/lib/alt/attr.rs:2589— pyrefly/lib/alt/attr.rs changed 49 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 76 in AnswersSolver::as_attribute_base1 at line 2589. 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-07-29..2026-10-27, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-29 08:23:10 -07:00' --until='2026-10-27 08:23:10 -07: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: crates/pyrefly_config/src/error_kind.rs crates/pyrefly_config/src/error_kind.rs:602— crates/pyrefly_config/src/error_kind.rs changed 41 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 80 in ErrorKind::default_severity at line 602. 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-07-29..2026-10-27, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-29 08:23:10 -07:00' --until='2026-10-27 08:23:10 -07:00' --full-history --no-merges -- crates/pyrefly_config/src/error_kind.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:1635— crates/pyrefly_config/src/config.rs changed 54 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 59 in ConfigFile::configure_at at line 1635. 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-07-29..2026-10-27, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-29 08:23:10 -07:00' --until='2026-10-27 08:23:10 -07: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/alt/polars_specials.rs pyrefly/lib/alt/polars_specials.rs:3356— pyrefly/lib/alt/polars_specials.rs changed 87 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 31 in AnswersSolver::polars_join at line 3356. 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-07-29..2026-10-27, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-29 08:23:10 -07:00' --until='2026-10-27 08:23:10 -07:00' --full-history --no-merges -- pyrefly/lib/alt/polars_specials.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:2888— pyrefly/lib/state/lsp.rs changed 56 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 48 in Transaction::find_definition at line 2888. 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-07-29..2026-10-27, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-29 08:23:10 -07:00' --until='2026-10-27 08:23:10 -07: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: crates/pyrefly_types/src/types.rs crates/pyrefly_types/src/types.rs:1082— crates/pyrefly_types/src/types.rs changed 49 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 54 in Type::recurse at line 1082. 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-07-29..2026-10-27, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-29 08:23:10 -07:00' --until='2026-10-27 08:23:10 -07:00' --full-history --no-merges -- crates/pyrefly_types/src/types.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:773— pyrefly/lib/alt/function.rs changed 60 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 44 in AnswersSolver::decorated_function_type at line 773. 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-07-29..2026-10-27, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-29 08:23:10 -07:00' --until='2026-10-27 08:23:10 -07: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/commands/check.rs pyrefly/lib/commands/check.rs:1907— pyrefly/lib/commands/check.rs changed 47 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 55 in CheckArgs::finish_cli_run at line 1907. 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-07-29..2026-10-27, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-29 08:23:10 -07:00' --until='2026-10-27 08:23:10 -07: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/state/state.rs pyrefly/lib/state/state.rs:1480— pyrefly/lib/state/state.rs changed 57 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 36 in Transaction::demand at line 1480. 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-07-29..2026-10-27, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-29 08:23:10 -07:00' --until='2026-10-27 08:23:10 -07: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/binding/expr.rs pyrefly/lib/binding/expr.rs:781— pyrefly/lib/binding/expr.rs changed 21 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 77 in BindingsBuilder::ensure_expr at line 781. 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-07-29..2026-10-27, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-29 08:23:10 -07:00' --until='2026-10-27 08:23:10 -07: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/alt/class/class_metadata.rs pyrefly/lib/alt/class/class_metadata.rs:188— 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 47 in AnswersSolver::class_metadata_of at line 188. 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-07-29..2026-10-27, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-29 08:23:10 -07:00' --until='2026-10-27 08:23:10 -07: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.
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 — 5522 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 (445-8125). The bar is 500 significant lines; this is 5022 over it, 11.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: non_wasm/server.rs pyrefly/lib/lsp/non_wasm/server.rs— FileTooLong — 5153 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, 1151-7728). The bar is 500 significant lines; this is 4653 over it, 10.31× 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 — 4345 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), about 77% of them inside a single declaration: AnswersSolver (1515-6441). The bar is 500 significant lines; this is 3845 over it, 8.69× 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 — 4288 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 (462-6088). The bar is 500 significant lines; this is 3788 over it, 8.58× 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 — 3810 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, 842-5566). The bar is 500 significant lines; this is 3310 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: pysa/call_graph.rs pyrefly/lib/report/pysa/call_graph.rs— FileTooLong — 3022 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, 1497-4465). The bar is 500 significant lines; this is 2522 over it, 6.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: solver/solver.rs pyrefly/lib/solver/solver.rs— FileTooLong — 2746 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 2246 over it, 5.49× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: binding/scope.rs pyrefly/lib/binding/scope.rs— FileTooLong — 2553 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 2053 over it, 5.11× 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 — 2544 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), about 72% of them inside a single declaration: AnswersSolver (1033-3637), declaring 35 free functions. The bar is 500 significant lines; this is 2044 over it, 5.09× 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/meta_shape_dsl.rs crates/pyrefly_types/src/meta_shape_dsl.rs— FileTooLong — 2422 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), declaring 52 free functions. The bar is 500 significant lines; this is 1922 over it, 4.84× 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/attr.rs pyrefly/lib/alt/attr.rs— FileTooLong — 2382 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, 622-3666). The bar is 500 significant lines; this is 1882 over it, 4.76× 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 — 2364 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 1864 over it, 4.73× 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 — 2356 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 1856 over it, 4.71× 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: solver/subset.rs pyrefly/lib/solver/subset.rs— FileTooLong — 2334 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 (212-3545). The bar is 500 significant lines; this is 1834 over it, 4.67× 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 — 2216 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), about 91% of them inside a single declaration: AnswersSolver (281-3034). The bar is 500 significant lines; this is 1716 over it, 4.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/answers_solver.rs pyrefly/lib/alt/answers_solver.rs— FileTooLong — 2162 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 1662 over it, 4.32× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: alt/function.rs pyrefly/lib/alt/function.rs— FileTooLong — 2056 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 (262-2949). The bar is 500 significant lines; this is 1556 over it, 4.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: alt/callable.rs pyrefly/lib/alt/callable.rs— FileTooLong — 1930 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), about 71% of them inside a single declaration: AnswersSolver (818-2818). The bar is 500 significant lines; this is 1430 over it, 3.86× 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/bindings.rs pyrefly/lib/binding/bindings.rs— FileTooLong — 1876 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), about 62% of them inside a single declaration: BindingsBuilder (5 blocks, 299-3119). The bar is 500 significant lines; this is 1376 over it, 3.75× 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 — 1826 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 (123-2744). The bar is 500 significant lines; this is 1326 over it, 3.65× 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_metadata.rs pyrefly/lib/alt/class/class_metadata.rs— FileTooLong — 1718 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 (151-2451). The bar is 500 significant lines; this is 1218 over it, 3.44× 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 — 1649 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), declaring 41 free functions. The bar is 500 significant lines; this is 1149 over it, 3.30× 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/stmt.rs pyrefly/lib/binding/stmt.rs— FileTooLong — 1530 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: BindingsBuilder (191-2351). The bar is 500 significant lines; this is 1030 over it, 3.06× 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: scripts/projects.py scripts/projects.py— FileTooLong — 1517 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 1017 over it, 3.03× 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.
pyrefly::lib::error::suppress::update_suppressions_in_files (cognitive 145) pyrefly/lib/error/suppress.rs:399— 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:833— 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::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:257— 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::binding::function::function_last_expressions::f (cognitive 42) pyrefly/lib/binding/function.rs:1000— pyrefly::lib::binding::function::function_last_expressions::f has cognitive complexity 42 (threshold 15). Drivers by points: if/else 13 (24 pts), loops 4 (9 pts), match/switch 2 (5 pts), boolean chains 4 (nesting depth added 19). 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::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_instance_attrs (cognitive 36) pyrefly/lib/commands/coverage/collect.rs:697— 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::commands::coverage::collect::collect_module_reports (cognitive 35) pyrefly/lib/commands/coverage/collect.rs:1806— pyrefly::lib::commands::coverage::collect::collect_module_reports has cognitive complexity 35 (threshold 15). Drivers by points: if/else 15 (24 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::lsp::non_wasm::server::dispatch_lsp_events (cognitive 35) pyrefly/lib/lsp/non_wasm/server.rs:1484— 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::parse_variables (cognitive 34) pyrefly/lib/commands/coverage/collect.rs:462— pyrefly::lib::commands::coverage::collect::parse_variables has cognitive complexity 34 (threshold 15). Drivers by points: match/switch 8 (16 pts), if/else 8 (12 pts), boolean chains 5, loops 1 (nesting depth added 12). Of this number, 24 points are the body's own statements and 10 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. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
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::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::module::finder::find_import_with_mode (cognitive 30) pyrefly/lib/module/finder.rs:601— pyrefly::lib::module::finder::find_import_with_mode has cognitive complexity 30 (threshold 15). Drivers by points: if/else 18 (19 pts), boolean chains 11 (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.
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::commands::infer::format_hints (cognitive 26) pyrefly/lib/commands/infer.rs:186— pyrefly::lib::commands::infer::format_hints has cognitive complexity 26 (threshold 15). Drivers by points: if/else 12 (18 pts), match/switch 2 (4 pts), boolean chains 3, 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.
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::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:85— pyrefly::lib::module::finder::resolve_third_party_stub has cognitive complexity 24 (threshold 15). Drivers by points: if/else 12 (21 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::module::finder::find_extra_extension_module (cognitive 24) pyrefly/lib/module/finder.rs:348— 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.
pyrefly::lib::state::lsp::quick_fixes::move_module::sibling_module_targets (cognitive 24) pyrefly/lib/state/lsp/quick_fixes/move_module.rs:799— pyrefly::lib::state::lsp::quick_fixes::move_module::sibling_module_targets has cognitive complexity 24 (threshold 15). Drivers by points: if/else 11 (19 pts), boolean chains 4, loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
pyrefly::lib::commands::dump_config::dump_config (cognitive 23) pyrefly/lib/commands/dump_config.rs:99— pyrefly::lib::commands::dump_config::dump_config has cognitive complexity 23 (threshold 15). Drivers by points: if/else 7 (14 pts), loops 5 (7 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::lib::lsp::non_wasm::will_rename_files::will_rename_files (cognitive 23) pyrefly/lib/lsp/non_wasm/will_rename_files.rs:167— pyrefly::lib::lsp::non_wasm::will_rename_files::will_rename_files has cognitive complexity 23 (threshold 15). Drivers by points: if/else 8 (12 pts), match/switch 3 (6 pts), loops 3 (5 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
pyrefly::lib::alt::class::variance_inference::on_type (cognitive 22) pyrefly/lib/alt/class/variance_inference.rs:375— pyrefly::lib::alt::class::variance_inference::on_type has cognitive complexity 22 (threshold 15). Drivers by points: loops 7 (16 pts), if/else 2 (3 pts), match/switch 2 (3 pts) (nesting depth added 11). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
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.
Duplicated block (5 lines × 2) crates/pyrefly_types/src/meta_shape_dsl.rs:2487— crates/pyrefly_types/src/meta_shape_dsl.rs:2487-2491 | crates/pyrefly_types/src/meta_shape_dsl.rs:2494-2498 — both copies are in the same file, so extract the 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) crates/pyrefly_types/src/meta_shape_dsl.rs:2959— crates/pyrefly_types/src/meta_shape_dsl.rs:2959-2965 | crates/pyrefly_types/src/meta_shape_dsl.rs:2982-2986 — both copies are in the same file, so extract the 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) crates/pyrefly_types/src/type_level_dsl.rs:6994— crates/pyrefly_types/src/type_level_dsl.rs:6994-6998 | crates/pyrefly_types/src/type_level_dsl.rs:7020-7024 — both copies are in the same file, so extract the 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) crates/pyrefly_types/src/type_level_dsl.rs:7570— crates/pyrefly_types/src/type_level_dsl.rs:7570-7574 | crates/pyrefly_types/src/type_level_dsl.rs:7589-7593 — both copies are in the same file, so extract the 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:2381— pyrefly/lib/alt/call.rs:2381-2385 | pyrefly/lib/alt/call.rs:2406-2410 — both copies are in the same file, so extract the 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/overload.rs:910— pyrefly/lib/alt/overload.rs:910-914 | pyrefly/lib/alt/overload.rs:923-927 — both copies are in the same file, so extract the 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/binding/class.rs:709— pyrefly/lib/binding/class.rs:709-713 | pyrefly/lib/binding/class.rs:1213-1220 — both copies are in the same file, so extract the 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/quick_fixes/extract_field.rs:178— pyrefly/lib/state/lsp/quick_fixes/extract_field.rs:178-182 | pyrefly/lib/state/lsp/quick_fixes/introduce_parameter.rs:303-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.
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:41— pyrefly/lib/alt/int_list_literal.rs:41-45 | pyrefly/lib/alt/regular_nested_list.rs:56-60 — 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) crates/pyrefly_types/src/meta_shape_dsl.rs:3558— crates/pyrefly_types/src/meta_shape_dsl.rs:3558-3562 | crates/pyrefly_types/src/type_level_dsl.rs:5664-5668 — 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) crates/pyrefly_types/src/type_level_dsl.rs:7563— crates/pyrefly_types/src/type_level_dsl.rs:7563-7567 | crates/pyrefly_types/src/type_level_dsl.rs:7584-7588 — both copies are in the same file, so extract the 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) crates/pyrefly_types/src/type_level_dsl.rs:7778— crates/pyrefly_types/src/type_level_dsl.rs:7778-7782 | crates/pyrefly_types/src/type_level_dsl.rs:7809-7813 — both copies are in the same file, so extract the 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/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.
Duplicated block (5 lines × 2) pyrefly/lib/alt/solve.rs:7217— pyrefly/lib/alt/solve.rs:7217-7221 | pyrefly/lib/alt/solve.rs:7342-7346 — both copies are in the same file, so extract the 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/lsp/non_wasm/code_lens.rs:46— pyrefly/lib/lsp/non_wasm/code_lens.rs:46-50 | pyrefly/lib/lsp/non_wasm/code_lens.rs:54-58 — both copies are in the same file, so extract the 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:1160— pyrefly/lib/solver/subset.rs:1160-1164 | pyrefly/lib/solver/subset.rs:1173-1177 — both copies are in the same file, so extract the 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-numpy-stubs/examples/physical_science.py:89— tensor-shapes/pyrefly-numpy-stubs/examples/physical_science.py:89-93 | tensor-shapes/pyrefly-numpy-stubs/examples/physical_science.py:146-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 (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 17 separate duplicated blocks between them, totalling at least 201 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the 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 16 separate duplicated blocks between them, totalling at least 282 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the 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 16 separate duplicated blocks between them, totalling at least 282 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
BindingsBuilder::stmt_impl (cognitive 339) pyrefly/lib/binding/stmt.rs:867— BindingsBuilder::stmt_impl has cognitive complexity 339 (threshold 15). Drivers by points: if/else 103 (251 pts), match/switch 14 (43 pts), loops 9 (23 pts), boolean chains 22 (nesting depth added 191). To reduce it, split the body into named stages: move each independent 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 151) pyrefly/lib/binding/pattern.rs:284— BindingsBuilder::bind_pattern has cognitive complexity 151 (threshold 15). Drivers by points: if/else 49 (96 pts), match/switch 7 (24 pts), boolean chains 23, loops 4 (8 pts) (nesting depth added 68). 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 140) pyrefly/lib/binding/expr.rs:781— BindingsBuilder::ensure_expr has cognitive complexity 140 (threshold 15). Drivers by points: if/else 32 (73 pts), loops 13 (41 pts), match/switch 8 (16 pts), boolean chains 10 (nesting depth added 77). Of this number, 138 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::type_params_with_owner (cognitive 45) pyrefly/lib/binding/bindings.rs:2408— 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::stmt_match (cognitive 44) pyrefly/lib/binding/pattern.rs:874— BindingsBuilder::stmt_match has cognitive complexity 44 (threshold 15). Drivers by points: if/else 18 (29 pts), match/switch 4 (9 pts), boolean chains 5, 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::merged_flow_info (cognitive 43) pyrefly/lib/binding/scope.rs:4055— BindingsBuilder::merged_flow_info has cognitive complexity 43 (threshold 15). Drivers by points: if/else 17 (35 pts), boolean chains 5, match/switch 2, 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.
BindingsBuilder::extract_shaped_array_metadata (cognitive 43) pyrefly/lib/binding/shape_type.rs:1020— BindingsBuilder::extract_shaped_array_metadata has cognitive complexity 43 (threshold 15). Drivers by points: if/else 16 (40 pts), loops 2 (3 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.
BindingsBuilder::extract_django_fields_from_class_body (cognitive 34) pyrefly/lib/binding/django.rs:40— 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:2254— 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::class_def_inner (cognitive 32) pyrefly/lib/binding/class.rs:247— BindingsBuilder::class_def_inner has cognitive complexity 32 (threshold 15). Drivers by points: if/else 13 (20 pts), match/switch 5 (7 pts), boolean chains 3, 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.
BindingsBuilder::typealiastype_from_call (cognitive 31) pyrefly/lib/binding/stmt.rs:600— 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::prescan_synthesized_bases (cognitive 30) pyrefly/lib/binding/class.rs:167— 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::ensure_name_impl (cognitive 29) pyrefly/lib/binding/expr.rs:383— BindingsBuilder::ensure_name_impl has cognitive complexity 29 (threshold 15). Drivers by points: if/else 14 (22 pts), boolean chains 6, match/switch 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::bind_single_name_assign (cognitive 29) pyrefly/lib/binding/target.rs:671— BindingsBuilder::bind_single_name_assign has cognitive complexity 29 (threshold 15). Drivers by points: if/else 17 (20 pts), boolean chains 8, match/switch 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.
BindingsBuilder::shape_comment_target (cognitive 28) pyrefly/lib/binding/shape_type.rs:319— 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::stmts (cognitive 27) pyrefly/lib/binding/bindings.rs:1421— BindingsBuilder::stmts has cognitive complexity 27 (threshold 15). Drivers by points: if/else 12 (18 pts), boolean chains 8, 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.
BindingsBuilder::ensure_type_impl (cognitive 27) pyrefly/lib/binding/expr.rs:1334— 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::extract_pydantic_config_dict (cognitive 25) pyrefly/lib/binding/pydantic.rs:280— BindingsBuilder::extract_pydantic_config_dict has cognitive complexity 25 (threshold 15). Drivers by points: if/else 11 (16 pts), boolean chains 7, loops 1 (2 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
BindingsBuilder::bind_targets_with_value (cognitive 25) pyrefly/lib/binding/target.rs:440— 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:884— 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:1317— 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::function_body (cognitive 24) pyrefly/lib/binding/function.rs:697— BindingsBuilder::function_body has cognitive complexity 24 (threshold 15). Drivers by points: boolean chains 10, if/else 9 (10 pts), match/switch 3 (4 pts) (nesting depth added 2). To reduce it, split the body into named stages: move each independent 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:281— 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::merge_flow (cognitive 20) pyrefly/lib/binding/scope.rs:4269— BindingsBuilder::merge_flow has cognitive complexity 20 (threshold 15). Drivers by points: if/else 8, boolean chains 6, loops 5 (6 pts) (nesting depth added 1). To reduce it, split the body into named stages: move each independent 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_lambda (cognitive 19) pyrefly/lib/binding/expr.rs:571— BindingsBuilder::bind_lambda has cognitive complexity 19 (threshold 15). Drivers by points: if/else 8 (12 pts), loops 4 (6 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.
Transaction::completion_sorted_opt_with_incomplete (cognitive 95) pyrefly/lib/lsp/wasm/completion.rs:1073— Transaction::completion_sorted_opt_with_incomplete has cognitive complexity 95 (threshold 15). Drivers by points: if/else 27 (69 pts), boolean chains 13, loops 3 (8 pts), match/switch 2 (5 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.
Transaction::inlay_hints (cognitive 95) pyrefly/lib/lsp/wasm/inlay_hints.rs:234— 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::local_quickfix_code_actions_sorted (cognitive 93) pyrefly/lib/state/lsp.rs:3553— Transaction::local_quickfix_code_actions_sorted has cognitive complexity 93 (threshold 15). Drivers by points: if/else 22 (69 pts), loops 6 (12 pts), boolean chains 10, match/switch 1 (2 pts) (nesting depth added 54). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Transaction::find_definition (cognitive 74) pyrefly/lib/state/lsp.rs:2888— Transaction::find_definition has cognitive complexity 74 (threshold 15). Drivers by points: if/else 23 (47 pts), match/switch 9 (22 pts), boolean chains 5 (nesting depth added 37). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Transaction::demand (cognitive 56) pyrefly/lib/state/state.rs:1480— Transaction::demand has cognitive complexity 56 (threshold 15). Drivers by points: if/else 22 (42 pts), boolean chains 6, 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 44) pyrefly/lib/state/lsp/dict_completions.rs:951— Transaction::extend_dict_key_suggestions has cognitive complexity 44 (threshold 15). Drivers by points: if/else 15 (32 pts), loops 3 (11 pts), boolean chains 1 (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::inferred_types (cognitive 42) pyrefly/lib/lsp/wasm/inlay_hints.rs:831— 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::dict_literal_string_literal_at (cognitive 38) pyrefly/lib/state/lsp/dict_completions.rs:635— Transaction::dict_literal_string_literal_at has cognitive complexity 38 (threshold 15). Drivers by points: if/else 9 (24 pts), boolean chains 6, match/switch 2 (5 pts), loops 2 (3 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.
Transaction::dict_literal_value_string_literal_at (cognitive 36) pyrefly/lib/state/lsp/dict_completions.rs:693— Transaction::dict_literal_value_string_literal_at has cognitive complexity 36 (threshold 15). Drivers by points: if/else 8 (22 pts), boolean chains 6, match/switch 2 (5 pts), loops 2 (3 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.
Transaction::clean (cognitive 36) pyrefly/lib/state/state.rs:1309— 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:2391— 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:4229— 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_autoimport_completions (cognitive 31) pyrefly/lib/lsp/wasm/completion.rs:652— 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_kwargs_completions (cognitive 27) pyrefly/lib/lsp/wasm/completion.rs:374— Transaction::add_kwargs_completions has cognitive complexity 27 (threshold 15). Drivers by points: loops 3 (12 pts), if/else 3 (10 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.
Transaction::add_inlay_hints_for_positional_function_args (cognitive 27) pyrefly/lib/lsp/wasm/inlay_hints.rs:538— 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::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::refine_keyword_argument_definition_for_class (cognitive 24) pyrefly/lib/state/lsp.rs:1297— 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:1207— 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:548— 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::infer_parameter_annotations (cognitive 22) pyrefly/lib/lsp/wasm/inlay_hints.rs:733— 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::dict_key_string_literal_at (cognitive 22) pyrefly/lib/state/lsp/dict_completions.rs:480— Transaction::dict_key_string_literal_at has cognitive complexity 22 (threshold 15). Drivers by points: match/switch 4 (11 pts), if/else 3 (7 pts), boolean chains 3, loops 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.
Transaction::add_dict_key_completions (cognitive 20) pyrefly/lib/state/lsp/dict_completions.rs:857— Transaction::add_dict_key_completions has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (12 pts), loops 1 (3 pts), match/switch 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.
Transaction::resolve_named_import (cognitive 20) pyrefly/lib/state/lsp.rs:1723— 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.
Transaction::dataframe_call_source (cognitive 19) pyrefly/lib/state/lsp/dict_completions.rs:583— Transaction::dataframe_call_source has cognitive complexity 19 (threshold 15). Drivers by points: if/else 8 (16 pts), boolean chains 2, loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Transaction::type_from_resolution (cognitive 19) pyrefly/lib/state/lsp.rs:1480— Transaction::type_from_resolution has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (16 pts), boolean chains 2, match/switch 1 (nesting depth added 9). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
Duplicated block (7 lines × 2) crates/pyrefly_config/src/migration/run.rs:394— crates/pyrefly_config/src/migration/run.rs:394-400 | pyrefly/lib/commands/init.rs:321-327 — 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:766— crates/pyrefly_types/src/dimension.rs:766-772 | crates/pyrefly_types/src/dimension.rs:959-965 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (7 lines × 2) crates/pyrefly_types/src/display.rs:1398— crates/pyrefly_types/src/display.rs:1398-1404 | crates/pyrefly_types/src/display.rs:1414-1420 — both copies are in the same file, so extract the 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_level_dsl.rs:3664— crates/pyrefly_types/src/type_level_dsl.rs:3664-3670 | crates/pyrefly_types/src/type_level_dsl.rs:3790-3796 — both copies are in the same file, so extract the 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_level_dsl.rs:7784— crates/pyrefly_types/src/type_level_dsl.rs:7784-7790 | crates/pyrefly_types/src/type_level_dsl.rs:7815-7821 — both copies are in the same file, so extract the 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/map_int_tuples.rs:763— pyrefly/lib/alt/map_int_tuples.rs:763-769 | pyrefly/lib/alt/shape_extension.rs:346-352 — 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/narrow.rs:1181— pyrefly/lib/alt/narrow.rs:1181-1187 | pyrefly/lib/alt/narrow.rs:1204-1210 — both copies are in the same file, so extract the 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/solve.rs:3956— pyrefly/lib/alt/solve.rs:3956-3962 | pyrefly/lib/alt/solve.rs:3964-3970 — both copies are in the same file, so extract the 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/binding/scope.rs:2514— pyrefly/lib/binding/scope.rs:2514-2520 | pyrefly/lib/binding/scope.rs:2576-2582 — both copies are in the same file, so extract the 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/lsp/non_wasm/server.rs:5036— pyrefly/lib/lsp/non_wasm/server.rs:5036-5042 | pyrefly/lib/lsp/non_wasm/server.rs:5065-5071 — both copies are in the same file, so extract the 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/lsp/non_wasm/server.rs:6254— pyrefly/lib/lsp/non_wasm/server.rs:6254-6260 | pyrefly/lib/playground.rs:526-532 — 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/lsp/non_wasm/server.rs:6307— pyrefly/lib/lsp/non_wasm/server.rs:6307-6313 | pyrefly/lib/playground.rs:496-502 — 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/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.
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.
Duplicated block (7 lines × 2) pyrefly/lib/solver/subset.rs:853— pyrefly/lib/solver/subset.rs:853-859 | pyrefly/lib/solver/subset.rs:886-892 — both copies are in the same file, so extract the 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/state/lsp/dict_completions.rs:677— pyrefly/lib/state/lsp/dict_completions.rs:677-683 | pyrefly/lib/state/lsp/dict_completions.rs:713-719 — both copies are in the same file, so extract the 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/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:503— pyrefly/lib/alt/polars_specials.rs:503-509 | 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:535— pyrefly/lib/binding/bindings.rs:535-541 | pyrefly/lib/binding/shape_type.rs:188-197 — 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/meta_shape_dsl.rs:2403— crates/pyrefly_types/src/meta_shape_dsl.rs:2403-2413 | crates/pyrefly_types/src/meta_shape_dsl.rs:2442-2448 — both copies are in the same file, so extract the 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_level_dsl.rs:3522— crates/pyrefly_types/src/type_level_dsl.rs:3522-3528 | crates/pyrefly_types/src/type_level_dsl.rs:3572-3578 — both copies are in the same file, so extract the 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/variance_inference.rs:855— pyrefly/lib/alt/class/variance_inference.rs:855-861 | pyrefly/lib/alt/class/variance_inference.rs:867-873 — both copies are in the same file, so extract the 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_config/src/args.rs:493— crates/pyrefly_config/src/args.rs:493-499 | crates/pyrefly_config/src/args.rs:500-506 — both copies are in the same file, so extract the 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/binding/binding.rs:1467— pyrefly/lib/binding/binding.rs:1467-1473 | pyrefly/lib/binding/binding.rs:2831-2837 — both copies are in the same file, so extract the 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/state/lsp/quick_fixes/inline_parameter.rs:91— pyrefly/lib/state/lsp/quick_fixes/inline_parameter.rs:91-97 | pyrefly/lib/state/lsp/quick_fixes/inline_variable.rs:96-102 — 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.
pyrefly_types::meta_shape_dsl::eval_dsl_expr (cognitive 76) crates/pyrefly_types/src/meta_shape_dsl.rs:2373— pyrefly_types::meta_shape_dsl::eval_dsl_expr has cognitive complexity 76 (threshold 15). Drivers by points: if/else 18 (40 pts), match/switch 12 (28 pts), loops 2 (6 pts), boolean chains 2 (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.
pyrefly_types::shape_index::lower_index_type_in_position (cognitive 59) crates/pyrefly_types/src/shape_index.rs:402— 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::meta_shape_dsl::eval_call (cognitive 49) crates/pyrefly_types/src/meta_shape_dsl.rs:2946— pyrefly_types::meta_shape_dsl::eval_call has cognitive complexity 49 (threshold 15). Drivers by points: if/else 9 (22 pts), match/switch 6 (15 pts), loops 4 (12 pts) (nesting depth added 30). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
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:217— 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::meta_shape_dsl::val_to_type (cognitive 36) crates/pyrefly_types/src/meta_shape_dsl.rs:3302— pyrefly_types::meta_shape_dsl::val_to_type has cognitive complexity 36 (threshold 15). Drivers by points: if/else 10 (21 pts), match/switch 6 (12 pts), loops 1 (2 pts), boolean chains 1 (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.
pyrefly_types::dimension::canonicalize_division (cognitive 35) crates/pyrefly_types/src/dimension.rs:971— 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:1199— 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::meta_shape_dsl::convert_expr (cognitive 34) crates/pyrefly_types/src/meta_shape_dsl.rs:1030— pyrefly_types::meta_shape_dsl::convert_expr has cognitive complexity 34 (threshold 15). Drivers by points: match/switch 9 (18 pts), if/else 6 (11 pts), loops 2 (5 pts) (nesting depth added 17). 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::dimension::canonicalize_product (cognitive 33) crates/pyrefly_types/src/dimension.rs:818— 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::meta_shape_dsl::infer_call (cognitive 32) crates/pyrefly_types/src/meta_shape_dsl.rs:1938— pyrefly_types::meta_shape_dsl::infer_call has cognitive complexity 32 (threshold 15). Drivers by points: if/else 10 (27 pts), match/switch 3 (5 pts) (nesting depth added 19). 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_types::simplify::collapse_literals (cognitive 32) crates/pyrefly_types/src/simplify.rs:195— 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::meta_shape_dsl::infer_expr (cognitive 31) crates/pyrefly_types/src/meta_shape_dsl.rs:2049— pyrefly_types::meta_shape_dsl::infer_expr has cognitive complexity 31 (threshold 15). Drivers by points: if/else 12 (22 pts), match/switch 5 (9 pts) (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
pyrefly_types::type_level_dsl::lower_parameter (cognitive 27) crates/pyrefly_types/src/type_level_dsl.rs:8664— 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::meta_shape_dsl::eval_binop (cognitive 20) crates/pyrefly_types/src/meta_shape_dsl.rs:2799— pyrefly_types::meta_shape_dsl::eval_binop has cognitive complexity 20 (threshold 15). Drivers by points: match/switch 10 (14 pts), if/else 2 (6 pts) (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::einsum::evaluate_einops_einsum (cognitive 19) crates/pyrefly_types/src/einsum.rs:307— 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:831— 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:452— 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:419— 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:521— 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::meta_shape_dsl::bind_comp_vars (cognitive 18) crates/pyrefly_types/src/meta_shape_dsl.rs:1878— pyrefly_types::meta_shape_dsl::bind_comp_vars has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (11 pts), loops 2 (5 pts), boolean chains 1, match/switch 1 (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.
pyrefly_types::shape_index::lower_integer_type (cognitive 16) crates/pyrefly_types/src/shape_index.rs:125— 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:281— 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.
pyrefly::lib::lsp::wasm::hover::keyword_documentation (cyclomatic 73) pyrefly/lib/lsp/wasm/hover.rs:802— 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:399— 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 47) pyrefly/lib/report/cinderx/convert.rs:177— pyrefly::lib::report::cinderx::convert::type_to_structured has cyclomatic complexity 47 (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:833— 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::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::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::commands::coverage::collect::parse_variables (cyclomatic 32) pyrefly/lib/commands/coverage/collect.rs:462— pyrefly::lib::commands::coverage::collect::parse_variables has cyclomatic complexity 32 (threshold 15). Of this number, 19 points are the body's own statements and 13 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::function::function_last_expressions::f (cyclomatic 28) pyrefly/lib/binding/function.rs:1000— pyrefly::lib::binding::function::function_last_expressions::f 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.
pyrefly::lib::module::finder::find_import_with_mode (cyclomatic 27) pyrefly/lib/module/finder.rs:601— pyrefly::lib::module::finder::find_import_with_mode has cyclomatic complexity 27 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
pyrefly::lib::alt::class::variance_inference::on_type (cyclomatic 22) pyrefly/lib/alt/class/variance_inference.rs:375— pyrefly::lib::alt::class::variance_inference::on_type has cyclomatic complexity 22 (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.
pyrefly::lib::commands::coverage::collect::parse_instance_attrs (cyclomatic 22) pyrefly/lib/commands/coverage/collect.rs:697— 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::commands::coverage::collect::collect_module_reports (cyclomatic 22) pyrefly/lib/commands/coverage/collect.rs:1806— pyrefly::lib::commands::coverage::collect::collect_module_reports 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:1484— 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::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::commands::infer::format_hints (cyclomatic 21) pyrefly/lib/commands/infer.rs:186— pyrefly::lib::commands::infer::format_hints 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::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::report::cinderx::collect::collect_call_contextual_types (cyclomatic 20) pyrefly/lib/report/cinderx/collect.rs:257— 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::lsp::wasm::hover::get_hover_with_verbosity (cyclomatic 19) pyrefly/lib/lsp/wasm/hover.rs:1397— pyrefly::lib::lsp::wasm::hover::get_hover_with_verbosity has cyclomatic complexity 19 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
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::report::pysa::types::get_classes_of_type (cyclomatic 18) pyrefly/lib/report/pysa/types.rs:263— pyrefly::lib::report::pysa::types::get_classes_of_type 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::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:972— 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_types::meta_shape_dsl::eval_dsl_expr (cyclomatic 54) crates/pyrefly_types/src/meta_shape_dsl.rs:2373— pyrefly_types::meta_shape_dsl::eval_dsl_expr has cyclomatic complexity 54 (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::meta_shape_dsl::convert_expr (cyclomatic 47) crates/pyrefly_types/src/meta_shape_dsl.rs:1030— pyrefly_types::meta_shape_dsl::convert_expr has cyclomatic complexity 47 (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::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:402— 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:195— 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::meta_shape_dsl::infer_expr (cyclomatic 32) crates/pyrefly_types/src/meta_shape_dsl.rs:2049— pyrefly_types::meta_shape_dsl::infer_expr has cyclomatic complexity 32 (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::meta_shape_dsl::eval_call (cyclomatic 31) crates/pyrefly_types/src/meta_shape_dsl.rs:2946— pyrefly_types::meta_shape_dsl::eval_call has cyclomatic complexity 31 (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_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::meta_shape_dsl::eval_binop (cyclomatic 27) crates/pyrefly_types/src/meta_shape_dsl.rs:2799— pyrefly_types::meta_shape_dsl::eval_binop 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.
pyrefly_types::meta_shape_dsl::val_to_type (cyclomatic 22) crates/pyrefly_types/src/meta_shape_dsl.rs:3302— pyrefly_types::meta_shape_dsl::val_to_type 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::shaped_array::reduce_axis_shape (cyclomatic 22) crates/pyrefly_types/src/shaped_array.rs:1199— 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:8664— 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:217— 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:971— 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::meta_shape_dsl::collect_call_targets_expr (cyclomatic 19) crates/pyrefly_types/src/meta_shape_dsl.rs:3632— pyrefly_types::meta_shape_dsl::collect_call_targets_expr 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:336— 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::meta_shape_dsl::convert_call (cyclomatic 18) crates/pyrefly_types/src/meta_shape_dsl.rs:1303— pyrefly_types::meta_shape_dsl::convert_call 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:281— 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:818— 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::meta_shape_dsl::infer_call (cyclomatic 17) crates/pyrefly_types/src/meta_shape_dsl.rs:1938— pyrefly_types::meta_shape_dsl::infer_call 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_types::type_level_dsl::evaluate_dimension_arithmetic (cyclomatic 17) crates/pyrefly_types/src/type_level_dsl.rs:8733— 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:419— 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.
pyrefly_types::literal::write_escaped_string (cyclomatic 16) crates/pyrefly_types/src/literal.rs:62— pyrefly_types::literal::write_escaped_string 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.
FunctionTooLong: pyrefly::lib::lsp::wasm::hover::keyword_documentation pyrefly/lib/lsp/wasm/hover.rs:802— 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: pyrefly::lib::error::suppress::update_suppressions_in_files pyrefly/lib/error/suppress.rs:399— 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:177— FunctionTooLong — pyrefly::lib::report::cinderx::convert::type_to_structured runs 211 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 111 over it, 2.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.
FunctionTooLong: pyrefly_types::meta_shape_dsl::eval_dsl_expr crates/pyrefly_types/src/meta_shape_dsl.rs:2373— FunctionTooLong — pyrefly_types::meta_shape_dsl::eval_dsl_expr runs 208 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 108 over it, 2.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.
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:266— FunctionTooLong — pyrefly::lib::query::type_table::type_to_indexed_shape runs 192 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 92 over it, 1.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.
FunctionTooLong: extension.activate lsp/src/extension.ts:234— FunctionTooLong — activate runs 176 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 76 over it, 1.76× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: pyrefly_types::meta_shape_dsl::convert_expr crates/pyrefly_types/src/meta_shape_dsl.rs:1030— FunctionTooLong — pyrefly_types::meta_shape_dsl::convert_expr runs 174 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 74 over it, 1.74× 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::meta_shape_dsl::eval_call crates/pyrefly_types/src/meta_shape_dsl.rs:2946— FunctionTooLong — pyrefly_types::meta_shape_dsl::eval_call runs 158 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 58 over it, 1.58× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: pyrefly::lib::lsp::wasm::hover::get_hover_with_verbosity pyrefly/lib/lsp/wasm/hover.rs:1397— FunctionTooLong — pyrefly::lib::lsp::wasm::hover::get_hover_with_verbosity runs 152 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 52 over it, 1.52× 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_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:167— FunctionTooLong — pyrefly::lib::lsp::non_wasm::will_rename_files::will_rename_files runs 118 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 18 over it, 1.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.
FunctionTooLong: pyrefly::lib::module::finder::find_import_with_mode pyrefly/lib/module/finder.rs:601— FunctionTooLong — pyrefly::lib::module::finder::find_import_with_mode runs 117 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 17 over it, 1.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: 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_types::meta_shape_dsl::convert_call crates/pyrefly_types/src/meta_shape_dsl.rs:1303— FunctionTooLong — pyrefly_types::meta_shape_dsl::convert_call runs 106 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 6 over it, 1.06× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: pyrefly::lib::lsp::non_wasm::server::capabilities pyrefly/lib/lsp/non_wasm/server.rs:1627— 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: 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.
TooManyMethods: AnswersSolver pyrefly/lib/alt/answers_solver.rs:2070— TooManyMethods — 1218 methods, declared across 51 files: alt/solve.rs (158), alt/expr.rs (112), class/class_field.rs (96), alt/answers_solver.rs (93), +47 more file(s). The bar is 30 methods; this is 1188 over it, 40.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: Transaction pyrefly/lib/state/state.rs:755— TooManyMethods — 294 methods, declared across 13 files: state/lsp.rs (119), state/state.rs (85), lsp/dict_completions.rs (29), wasm/completion.rs (22), +9 more file(s). The bar is 30 methods; this is 264 over it, 9.80× 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:299— TooManyMethods — 228 methods, declared across 13 files: binding/bindings.rs (79), binding/class.rs (24), binding/expr.rs (24), binding/stmt.rs (24), +9 more file(s). The bar is 30 methods; this is 198 over it, 7.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: Scopes pyrefly/lib/binding/scope.rs:1621— TooManyMethods — 140 methods. The bar is 30 methods; this is 110 over it, 4.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: Type crates/pyrefly_types/src/types.rs:917— TooManyMethods — 117 methods, declared across 3 files: src/types.rs (104), src/boundary.rs (9), src/display.rs (4). The bar is 30 methods; this is 87 over it, 3.90× 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:1151— TooManyMethods — 113 methods. The bar is 30 methods; this is 83 over it, 3.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: Stdlib crates/pyrefly_types/src/stdlib.rs:51— 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:571— TooManyMethods — 79 methods. The bar is 30 methods; this is 49 over it, 2.63× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: TypeHeap crates/pyrefly_types/src/heap.rs:86— TooManyMethods — 66 methods. The bar is 30 methods; this is 36 over it, 2.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: 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: Subset pyrefly/lib/solver/solver.rs:3436— TooManyMethods — 63 methods, declared across 2 files: solver/subset.rs (46), solver/solver.rs (17). The bar is 30 methods; this is 33 over it, 2.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: ConfigFile crates/pyrefly_config/src/config.rs:580— TooManyMethods — 54 methods. The bar is 30 methods; this is 24 over it, 1.80× 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: ModuleName crates/pyrefly_python/src/module_name.rs:39— TooManyMethods — 53 methods. The bar is 30 methods; this is 23 over it, 1.77× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: DslValidator crates/pyrefly_types/src/type_level_dsl.rs:1960— 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: CallGraphVisitor pyrefly/lib/report/pysa/call_graph.rs:1497— 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: ClassField pyrefly/lib/alt/class/class_field.rs:347— TooManyMethods — 46 methods. The bar is 30 methods; this is 16 over it, 1.53× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: TypeDisplayContext crates/pyrefly_types/src/display.rs:163— TooManyMethods — 42 methods. The bar is 30 methods; this is 12 over it, 1.40× 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:65— TooManyMethods — 37 methods. The bar is 30 methods; this is 7 over it, 1.23× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: Bindings pyrefly/lib/binding/bindings.rs:218— TooManyMethods — 37 methods. The bar is 30 methods; this is 7 over it, 1.23× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: CalcStack pyrefly/lib/alt/answers_solver.rs:534— 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: TypeOrder pyrefly/lib/solver/type_order.rs:49— 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: Answers pyrefly/lib/alt/answers.rs:244— TooManyMethods — 33 methods. The bar is 30 methods; this is 3 over it, 1.10× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: 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.
Duplicated block (8 lines × 2) crates/pyrefly_types/src/callable.rs:680— crates/pyrefly_types/src/callable.rs:680-687 | crates/pyrefly_types/src/callable.rs:694-701 — both copies are in the same file, so extract the 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/dimension.rs:1061— crates/pyrefly_types/src/dimension.rs:1061-1068 | crates/pyrefly_types/src/dimension.rs:1072-1081 — both copies are in the same file, so extract the 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/meta_shape_dsl.rs:1762— crates/pyrefly_types/src/meta_shape_dsl.rs:1762-1769 | crates/pyrefly_types/src/meta_shape_dsl.rs:1780-1787 — both copies are in the same file, so extract the 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/attr.rs:2153— pyrefly/lib/alt/attr.rs:2153-2160 | pyrefly/lib/alt/attr.rs:2275-2282 — both copies are in the same file, so extract the 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/class/class_field.rs:897— pyrefly/lib/alt/class/class_field.rs:897-904 | pyrefly/lib/alt/class/class_field.rs:1222-1232 — both copies are in the same file, so extract the 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/narrow.rs:502— pyrefly/lib/alt/narrow.rs:502-509 | pyrefly/lib/alt/narrow.rs:1908-1916 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (8 lines × 2) pyrefly/lib/alt/narrow.rs:1260— pyrefly/lib/alt/narrow.rs:1260-1267 | pyrefly/lib/alt/narrow.rs:1276-1283 — both copies are in the same file, so extract the 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/operators.rs:321— pyrefly/lib/alt/operators.rs:321-328 | pyrefly/lib/alt/operators.rs:335-342 — both copies are in the same file, so extract the 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:223— pyrefly/lib/alt/unwrap.rs:223-230 | pyrefly/lib/alt/unwrap.rs:272-279 — both copies are in the same file, so extract the 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:292— pyrefly/lib/alt/unwrap.rs:292-299 | pyrefly/lib/alt/unwrap.rs:465-472 — both copies are in the same file, so extract the 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:1015— pyrefly/lib/binding/expr.rs:1015-1022 | pyrefly/lib/binding/expr.rs:1035-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 (8 lines × 2) pyrefly/lib/binding/narrow.rs:863— pyrefly/lib/binding/narrow.rs:863-870 | pyrefly/lib/binding/narrow.rs:884-891 — both copies are in the same file, so extract the 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/stmt.rs:489— pyrefly/lib/binding/stmt.rs:489-496 | pyrefly/lib/binding/stmt.rs:531-538 — both copies are in the same file, so extract the 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:301— pyrefly/lib/commands/init.rs:301-308 | pyrefly/lib/commands/init.rs:347-354 — both copies are in the same file, so extract the 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/lsp/non_wasm/server.rs:2471— pyrefly/lib/lsp/non_wasm/server.rs:2471-2478 | pyrefly/lib/lsp/non_wasm/server.rs:2593-2600 — both copies are in the same file, so extract the 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/lsp/non_wasm/server.rs:6258— pyrefly/lib/lsp/non_wasm/server.rs:6258-6265 | pyrefly/lib/lsp/non_wasm/server.rs:6311-6318 — both copies are in the same file, so extract the 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_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.
Duplicated block (8 lines × 2) pyrefly/lib/lsp/non_wasm/server.rs:4355— pyrefly/lib/lsp/non_wasm/server.rs:4355-4362 | pyrefly/lib/lsp/non_wasm/server.rs:4430-4437 — both copies are in the same file, so extract the 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.
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/meta_shape_dsl.rs:905— crates/pyrefly_types/src/meta_shape_dsl.rs:905-910 | crates/pyrefly_types/src/meta_shape_dsl.rs:921-926 — both copies are in the same file, so extract the 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:7797— crates/pyrefly_types/src/type_level_dsl.rs:7797-7802 | crates/pyrefly_types/src/type_level_dsl.rs:7836-7841 — both copies are in the same file, so extract the 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/alt/attr.rs:2750— pyrefly/lib/alt/attr.rs:2750-2755 | pyrefly/lib/alt/attr.rs:2926-2931 — both copies are in the same file, so extract the 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/alt/expr.rs:4518— pyrefly/lib/alt/expr.rs:4518-4523 | pyrefly/lib/alt/expr.rs:4549-4555 — both copies are in the same file, so extract the 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/alt/function.rs:2799— pyrefly/lib/alt/function.rs:2799-2804 | pyrefly/lib/alt/function.rs:2896-2901 — both copies are in the same file, so extract the 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/alt/narrow.rs:2487— pyrefly/lib/alt/narrow.rs:2487-2494 | pyrefly/lib/alt/narrow.rs:2552-2557 — both copies are in the same file, so extract the 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/alt/polars_specials.rs:1233— pyrefly/lib/alt/polars_specials.rs:1233-1238 | pyrefly/lib/alt/polars_specials.rs:1643-1648 — both copies are in the same file, so extract the 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/binding/expr.rs:1194— pyrefly/lib/binding/expr.rs:1194-1199 | pyrefly/lib/binding/expr.rs:1201-1206 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (6 lines × 2) pyrefly/lib/export/definitions.rs:337— pyrefly/lib/export/definitions.rs:337-342 | pyrefly/lib/export/deprecation.rs:20-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.
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/report/pysa/capnp_writer.rs:655— pyrefly/lib/report/pysa/capnp_writer.rs:655-660 | pyrefly/lib/report/pysa/capnp_writer.rs:722-727 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (6 lines × 2) pyrefly/lib/solver/subset.rs:501— pyrefly/lib/solver/subset.rs:501-506 | pyrefly/lib/solver/subset.rs:512-517 — both copies are in the same file, so extract the 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/state/lsp/quick_fixes/convert_dict.rs:302— pyrefly/lib/state/lsp/quick_fixes/convert_dict.rs:302-307 | pyrefly/lib/state/lsp/quick_fixes/convert_dict.rs:336-341 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (6 lines × 2) pyrefly/lib/state/lsp/quick_fixes/convert_star_import.rs:171— pyrefly/lib/state/lsp/quick_fixes/convert_star_import.rs:171-176 | pyrefly/lib/state/lsp/quick_fixes/extract_shared.rs:486-491 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (6 lines × 2) crates/pyrefly_types/src/type_level_dsl.rs:7143— crates/pyrefly_types/src/type_level_dsl.rs:7143-7148 | crates/pyrefly_types/src/type_level_dsl.rs:7352-7357 — both copies are in the same file, so extract the 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/shape_index.rs:650— crates/pyrefly_types/src/shape_index.rs:650-655 | crates/pyrefly_types/src/shape_index.rs:663-668 — both copies are in the same file, so extract the 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/runtime/gptfast_future_annotations_runnable.py:372— tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations_runnable.py:372-377 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var_runnable.py:371-376 — 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 17 separate duplicated blocks between them, totalling at least 201 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (6 lines × 2) tensor-shapes/pyrefly-torch-stubs/examples/unet.py:232— tensor-shapes/pyrefly-torch-stubs/examples/unet.py:232-237 | tensor-shapes/pyrefly-torch-stubs/examples/unet.py:292-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 (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.
ClassTooLong: Server pyrefly/lib/lsp/non_wasm/server.rs:1151— ClassTooLong — 4065 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 113 methods, 3 blocks, lines 1151-7728. The bar is 400 significant lines; this is 3665 over it, 10.16× 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:1497— ClassTooLong — 2035 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 1497-4465. The bar is 400 significant lines; this is 1635 over it, 5.09× 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:928— ClassTooLong — 1474 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 928-8575. The bar is 400 significant lines; this is 1074 over it, 3.69× 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:571— ClassTooLong — 1376 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 79 methods, 3 blocks, lines 571-2769. The bar is 400 significant lines; this is 976 over it, 3.44× 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:755— ClassTooLong — 1240 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 294 methods, 2 blocks, lines 755-2801. The bar is 400 significant lines; this is 840 over it, 3.10× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: Scopes pyrefly/lib/binding/scope.rs:1621— ClassTooLong — 1205 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 140 methods, 2 blocks, lines 1621-3812. The bar is 400 significant lines; this is 805 over it, 3.01× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: BindingsBuilder pyrefly/lib/binding/bindings.rs:299— ClassTooLong — 1155 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 228 methods, 5 blocks, lines 299-3119. The bar is 400 significant lines; this is 755 over it, 2.89× 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:163— ClassTooLong — 1130 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 42 methods, 2 blocks, lines 163-1789. The bar is 400 significant lines; this is 730 over it, 2.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.
ClassTooLong: AnswersSolver pyrefly/lib/alt/answers_solver.rs:2070— ClassTooLong — 1108 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 1218 methods, 2 blocks, lines 2070-4105. The bar is 400 significant lines; this is 708 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.
ClassTooLong: Type crates/pyrefly_types/src/types.rs:917— ClassTooLong — 963 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 117 methods, 4 blocks, lines 917-2545. The bar is 400 significant lines; this is 563 over it, 2.41× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: ConfigFile crates/pyrefly_config/src/config.rs:580— ClassTooLong — 917 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 54 methods, 5 blocks, lines 580-2428. The bar is 400 significant lines; this is 517 over it, 2.29× 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:347— ClassTooLong — 615 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 46 methods, 2 blocks, lines 429-1282. The bar is 400 significant lines; this is 215 over it, 1.54× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: Subset pyrefly/lib/solver/solver.rs:3436— ClassTooLong — 596 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 63 methods, 2 blocks, lines 3436-4360. The bar is 400 significant lines; this is 196 over it, 1.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: CheckArgs pyrefly/lib/commands/check.rs:226— ClassTooLong — 506 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 9 methods, 2 blocks, lines 226-2332. The bar is 400 significant lines; this is 106 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:152— ClassTooLong — 503 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 152-1765. The bar is 400 significant lines; this is 103 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: CalleesWithLocation pyrefly/lib/query.rs:377— ClassTooLong — 500 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 25 methods, 2 blocks, lines 377-1068. The bar is 400 significant lines; this is 100 over it, 1.25× 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:2529— ClassTooLong — 433 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 2529-3202. The bar is 400 significant lines; this is 33 over it, 1.08× 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.
Duplicated block (10 lines × 2) crates/pyrefly_types/src/display.rs:1516— crates/pyrefly_types/src/display.rs:1516-1525 | crates/pyrefly_types/src/display.rs:1541-1550 — both copies are in the same file, so extract the 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:2612— crates/pyrefly_types/src/type_level_dsl.rs:2612-2621 | crates/pyrefly_types/src/type_level_dsl.rs:2903-2912 — both copies are in the same file, so extract the 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:3653— crates/pyrefly_types/src/type_level_dsl.rs:3653-3662 | crates/pyrefly_types/src/type_level_dsl.rs:3779-3788 — both copies are in the same file, so extract the 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/alt/class/class_field.rs:5882— pyrefly/lib/alt/class/class_field.rs:5882-5891 | pyrefly/lib/alt/class/class_field.rs:6148-6157 — both copies are in the same file, so extract the 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/alt/solve.rs:251— pyrefly/lib/alt/solve.rs:251-260 | pyrefly/lib/alt/solve.rs:273-282 — both copies are in the same file, so extract the 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/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.
Duplicated block (10 lines × 2) pyrefly/lib/commands/check.rs:809— pyrefly/lib/commands/check.rs:809-818 | pyrefly/lib/commands/check.rs:825-834 — both copies are in the same file, so extract the 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/lsp/non_wasm/server.rs:5013— pyrefly/lib/lsp/non_wasm/server.rs:5013-5022 | pyrefly/lib/lsp/non_wasm/server.rs:5040-5049 — both copies are in the same file, so extract the 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/solver/solver.rs:3806— pyrefly/lib/solver/solver.rs:3806-3815 | pyrefly/lib/solver/solver.rs:3817-3826 — both copies are in the same file, so extract the 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/solver/subset.rs:918— pyrefly/lib/solver/subset.rs:918-927 | pyrefly/lib/solver/subset.rs:932-941 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (10 lines × 2) pyrefly/lib/state/lsp/dict_completions.rs:508— pyrefly/lib/state/lsp/dict_completions.rs:508-517 | pyrefly/lib/state/lsp/dict_completions.rs:710-719 — both copies are in the same file, so extract the 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.
Duplicated block (10 lines × 2) pyrefly/lib/alt/expr.rs:1683— pyrefly/lib/alt/expr.rs:1683-1694 | pyrefly/lib/alt/expr.rs:1721-1730 — both copies are in the same file, so extract the 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/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.
Duplicated block (10 lines × 2) pyrefly/lib/binding/stmt.rs:2186— pyrefly/lib/binding/stmt.rs:2186-2195 | pyrefly/lib/binding/stmt.rs:2200-2209 — both copies are in the same file, so extract the 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:706— pyrefly/lib/state/errors.rs:706-715 | pyrefly/lib/state/errors.rs:726-735 — both copies are in the same file, so extract the 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/tsp/type_conversion.rs:949— pyrefly/lib/tsp/type_conversion.rs:949-958 | pyrefly/lib/tsp/type_conversion.rs:964-973 — both copies are in the same file, so extract the 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/binding/narrow.rs:484— pyrefly/lib/binding/narrow.rs:484-493 | pyrefly/lib/binding/narrow.rs:495-504 — both copies are in the same file, so extract the 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) tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations_runnable.py:482— tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations_runnable.py:482-491 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var_runnable.py:459-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 16 separate duplicated blocks between them, totalling at least 282 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the 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.
BindingsBuilder::stmt_impl (cyclomatic 164) pyrefly/lib/binding/stmt.rs:867— BindingsBuilder::stmt_impl has cyclomatic complexity 164 (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 77) pyrefly/lib/binding/expr.rs:781— BindingsBuilder::ensure_expr has cyclomatic complexity 77 (threshold 15). Of this number, 76 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::bind_pattern (cyclomatic 76) pyrefly/lib/binding/pattern.rs:284— BindingsBuilder::bind_pattern 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.
BindingsBuilder::ensure_type_impl (cyclomatic 35) pyrefly/lib/binding/expr.rs:1334— 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::stmt_match (cyclomatic 27) pyrefly/lib/binding/pattern.rs:874— BindingsBuilder::stmt_match 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.
BindingsBuilder::class_def_inner (cyclomatic 24) pyrefly/lib/binding/class.rs:247— BindingsBuilder::class_def_inner 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.
BindingsBuilder::function_body (cyclomatic 24) pyrefly/lib/binding/function.rs:697— BindingsBuilder::function_body has cyclomatic complexity 24 (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::merged_flow_info (cyclomatic 24) pyrefly/lib/binding/scope.rs:4055— BindingsBuilder::merged_flow_info 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.
BindingsBuilder::stmts (cyclomatic 21) pyrefly/lib/binding/bindings.rs:1421— BindingsBuilder::stmts 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::bind_single_name_assign (cyclomatic 21) pyrefly/lib/binding/target.rs:671— BindingsBuilder::bind_single_name_assign has cyclomatic complexity 21 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
BindingsBuilder::ensure_name_impl (cyclomatic 20) pyrefly/lib/binding/expr.rs:383— BindingsBuilder::ensure_name_impl 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.
BindingsBuilder::extract_pydantic_config_dict (cyclomatic 19) pyrefly/lib/binding/pydantic.rs:280— BindingsBuilder::extract_pydantic_config_dict 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.
BindingsBuilder::as_assert_in_test (cyclomatic 18) pyrefly/lib/binding/expr.rs:635— 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::extract_shaped_array_metadata (cyclomatic 18) pyrefly/lib/binding/shape_type.rs:1020— BindingsBuilder::extract_shaped_array_metadata 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.
BindingsBuilder::merge_flow (cyclomatic 17) pyrefly/lib/binding/scope.rs:4269— BindingsBuilder::merge_flow 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.
BindingsBuilder::shape_comment_target (cyclomatic 17) pyrefly/lib/binding/shape_type.rs:319— 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:40— 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:600— 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.
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.
Duplicated block (9 lines × 2) crates/pyrefly_types/src/type_level_dsl.rs:3672— crates/pyrefly_types/src/type_level_dsl.rs:3672-3680 | crates/pyrefly_types/src/type_level_dsl.rs:3798-3806 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (9 lines × 2) crates/pyrefly_types/src/type_level_dsl.rs:7848— crates/pyrefly_types/src/type_level_dsl.rs:7848-7856 | crates/pyrefly_types/src/type_level_dsl.rs:7886-7894 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (9 lines × 2) pyrefly/lib/alt/call.rs:621— pyrefly/lib/alt/call.rs:621-629 | pyrefly/lib/alt/call.rs:644-652 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (9 lines × 2) pyrefly/lib/alt/class/class_field.rs:908— pyrefly/lib/alt/class/class_field.rs:908-916 | pyrefly/lib/alt/class/class_field.rs:920-928 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (9 lines × 2) pyrefly/lib/alt/class/class_field.rs:6114— pyrefly/lib/alt/class/class_field.rs:6114-6122 | pyrefly/lib/alt/class/class_field.rs:6159-6167 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (9 lines × 2) pyrefly/lib/alt/narrow.rs:1428— pyrefly/lib/alt/narrow.rs:1428-1436 | pyrefly/lib/alt/narrow.rs:1450-1458 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (9 lines × 2) pyrefly/lib/lsp/non_wasm/lsp.rs:27— pyrefly/lib/lsp/non_wasm/lsp.rs:27-35 | pyrefly/lib/lsp/non_wasm/lsp.rs:42-50 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (9 lines × 2) pyrefly/lib/lsp/wasm/inlay_hints.rs:679— pyrefly/lib/lsp/wasm/inlay_hints.rs:679-687 | pyrefly/lib/state/lsp.rs:1256-1264 — 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 (9 lines × 2) pyrefly/lib/report/pysa.rs:641— pyrefly/lib/report/pysa.rs:641-649 | pyrefly/lib/report/pysa.rs:669-677 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (9 lines × 2) pyrefly/lib/report/pysa.rs:651— pyrefly/lib/report/pysa.rs:651-659 | pyrefly/lib/report/pysa.rs:663-671 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (9 lines × 2) pyrefly/lib/state/lsp/quick_fixes/convert_dict.rs:309— pyrefly/lib/state/lsp/quick_fixes/convert_dict.rs:309-317 | pyrefly/lib/state/lsp/quick_fixes/convert_dict.rs:343-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.
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.
Duplicated block (9 lines × 2) pyrefly/lib/state/semantic_tokens.rs:806— pyrefly/lib/state/semantic_tokens.rs:806-814 | pyrefly/lib/state/semantic_tokens.rs:815-823 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
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.
Duplicated block (9 lines × 2) crates/pyrefly_types/src/type_level_dsl.rs:3537— crates/pyrefly_types/src/type_level_dsl.rs:3537-3545 | crates/pyrefly_types/src/type_level_dsl.rs:3587-3595 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (9 lines × 2) crates/pyrefly_config/src/migration/mypy/pyproject.rs:193— crates/pyrefly_config/src/migration/mypy/pyproject.rs:193-201 | crates/pyrefly_config/src/migration/mypy/pyproject.rs:231-239 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (9 lines × 2) 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 (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.
Duplicated block (11 lines × 2) crates/pyrefly_types/src/shape_index.rs:100— crates/pyrefly_types/src/shape_index.rs:100-110 | crates/pyrefly_types/src/shape_index.rs:289-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 (11 lines × 2) pyrefly/lib/alt/shape_extension.rs:111— pyrefly/lib/alt/shape_extension.rs:111-121 | 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.
Duplicated block (11 lines × 2) pyrefly/lib/binding/stmt.rs:1011— pyrefly/lib/binding/stmt.rs:1011-1021 | pyrefly/lib/binding/stmt.rs:1035-1045 — both copies are in the same file, so extract the 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/export/exports.rs:361— pyrefly/lib/export/exports.rs:361-371 | pyrefly/lib/export/exports.rs:384-394 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (11 lines × 2) pyrefly/lib/lsp/non_wasm/server.rs:4369— pyrefly/lib/lsp/non_wasm/server.rs:4369-4379 | pyrefly/lib/lsp/non_wasm/server.rs:4445-4455 — both copies are in the same file, so extract the 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/lsp/non_wasm/workspace.rs:693— pyrefly/lib/lsp/non_wasm/workspace.rs:693-703 | pyrefly/lib/lsp/non_wasm/workspace.rs:708-718 — both copies are in the same file, so extract the 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/state/lsp.rs:3603— pyrefly/lib/state/lsp.rs:3603-3613 | pyrefly/lib/state/lsp.rs:3615-3625 — both copies are in the same file, so extract the 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:401— pyrefly/lib/state/lsp/quick_fixes/change_signature.rs:401-411 | pyrefly/lib/state/lsp/quick_fixes/introduce_parameter.rs:527-537 — 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 58 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (11 lines × 2) pyrefly/lib/stubgen/extract.rs:365— pyrefly/lib/stubgen/extract.rs:365-375 | pyrefly/lib/stubgen/extract.rs:394-404 — both copies are in the same file, so extract the 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 58 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (11 lines × 2) pyrefly/lib/alt/class/attrs.rs:70— pyrefly/lib/alt/class/attrs.rs:70-80 | pyrefly/lib/alt/class/attrs.rs:87-97 — both copies are in the same file, so extract the 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/bindings.rs:2291— pyrefly/lib/binding/bindings.rs:2291-2301 | pyrefly/lib/binding/bindings.rs:2302-2312 — both copies are in the same file, so extract the 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) crates/pyrefly_types/src/type_level_dsl.rs:2516— crates/pyrefly_types/src/type_level_dsl.rs:2516-2526 | crates/pyrefly_types/src/type_level_dsl.rs:5162-5172 — both copies are in the same file, so extract the 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) 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 17 separate duplicated blocks between them, totalling at least 201 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the 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:1297— crates/pyrefly_types/src/display.rs:1297-1308 | crates/pyrefly_types/src/display.rs:1513-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.
Duplicated block (12 lines × 2) crates/pyrefly_types/src/einsum.rs:240— crates/pyrefly_types/src/einsum.rs:240-251 | crates/pyrefly_types/src/einsum.rs:272-283 — both copies are in the same file, so extract the 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/type_level_dsl.rs:6757— crates/pyrefly_types/src/type_level_dsl.rs:6757-6768 | crates/pyrefly_types/src/type_level_dsl.rs:6780-6791 — both copies are in the same file, so extract the 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/type_level_dsl.rs:7371— crates/pyrefly_types/src/type_level_dsl.rs:7371-7382 | crates/pyrefly_types/src/type_level_dsl.rs:7448-7459 — both copies are in the same file, so extract the 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/lsp/non_wasm/workspace.rs:642— pyrefly/lib/lsp/non_wasm/workspace.rs:642-653 | pyrefly/lib/lsp/non_wasm/workspace.rs:677-688 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (12 lines × 2) pyrefly/lib/report/cinderx.rs:169— pyrefly/lib/report/cinderx.rs:169-180 | pyrefly/lib/report/cinderx.rs:201-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.
Duplicated block (12 lines × 2) pyrefly/lib/state/lsp.rs:1094— pyrefly/lib/state/lsp.rs:1094-1105 | pyrefly/lib/state/lsp.rs:1128-1139 — both copies are in the same file, so extract the 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/state/lsp.rs:3871— pyrefly/lib/state/lsp.rs:3871-3882 | pyrefly/lib/state/lsp.rs:3898-3909 — both copies are in the same file, so extract the 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:310— pyrefly/lib/commands/init.rs:310-321 | pyrefly/lib/commands/init.rs: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.
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 17 separate duplicated blocks between them, totalling at least 201 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the 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 173 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D30 · Dependency Vulnerabilities· Medium advisory (unsound) · ×12
Duplicated block (14 lines × 2) crates/pyrefly_types/src/meta_shape_dsl.rs:1655— crates/pyrefly_types/src/meta_shape_dsl.rs:1655-1668 | crates/pyrefly_types/src/meta_shape_dsl.rs:1726-1739 — both copies are in the same file, so extract the 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:2929— pyrefly/lib/alt/attr.rs:2929-2942 | pyrefly/lib/alt/attr.rs:2953-2966 — both copies are in the same file, so extract the 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/class/class_metadata.rs:1474— pyrefly/lib/alt/class/class_metadata.rs:1474-1487 | pyrefly/lib/alt/class/class_metadata.rs:1507-1520 — both copies are in the same file, so extract the 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/class/dataclass.rs:499— pyrefly/lib/alt/class/dataclass.rs:499-512 | pyrefly/lib/alt/functools.rs:58-72 — 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 (14 lines × 2) pyrefly/lib/alt/polars_specials.rs:3126— pyrefly/lib/alt/polars_specials.rs:3126-3139 | pyrefly/lib/alt/polars_specials.rs:3158-3171 — both copies are in the same file, so extract the 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/lsp/wasm/completion.rs:774— pyrefly/lib/lsp/wasm/completion.rs:774-787 | pyrefly/lib/lsp/wasm/completion.rs:806-819 — both copies are in the same file, so extract the 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/playground.rs:349— pyrefly/lib/playground.rs:349-362 | pyrefly/lib/playground.rs:377-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 (14 lines × 2) pyrefly/lib/solver/solver.rs:1172— pyrefly/lib/solver/solver.rs:1172-1185 | pyrefly/lib/solver/solver.rs:1236-1249 — both copies are in the same file, so extract the 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/report/cinderx/view_types.py:49— pyrefly/lib/report/cinderx/view_types.py:49-62 | pyrefly/lib/report/cinderx/view_types.py:68-81 — both copies are in the same file, so extract the 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 (14 lines × 2) pyrefly/lib/state/lsp/quick_fixes/pytest_fixture.rs:372— pyrefly/lib/state/lsp/quick_fixes/pytest_fixture.rs:372-385 | pyrefly/lib/state/lsp/quick_fixes/pytest_fixture.rs:470-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.
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.
Duplicated block (14 lines × 2) tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations_runnable.py:283— tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations_runnable.py:283-296 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var_runnable.py:287-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 17 separate duplicated blocks between them, totalling at least 201 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the 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.
DslValidator::validate_condition (cyclomatic 79) crates/pyrefly_types/src/type_level_dsl.rs:4651— 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:5136— 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:2530— 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:4102— 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:3159— 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:3357— 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:2194— 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:2867— 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:3973— 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:4509— 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:2749— 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.
Transaction::inlay_hints (cyclomatic 49) pyrefly/lib/lsp/wasm/inlay_hints.rs:234— 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::find_definition (cyclomatic 48) pyrefly/lib/state/lsp.rs:2888— Transaction::find_definition 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.
Transaction::completion_sorted_opt_with_incomplete (cyclomatic 47) pyrefly/lib/lsp/wasm/completion.rs:1073— Transaction::completion_sorted_opt_with_incomplete 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.
Transaction::local_quickfix_code_actions_sorted (cyclomatic 44) pyrefly/lib/state/lsp.rs:3553— Transaction::local_quickfix_code_actions_sorted 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.
Transaction::demand (cyclomatic 36) pyrefly/lib/state/state.rs:1480— Transaction::demand has cyclomatic complexity 36 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Transaction::find_operator_dunder (cyclomatic 25) pyrefly/lib/state/lsp.rs:2391— 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:1309— 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::dict_literal_string_literal_at (cyclomatic 20) pyrefly/lib/state/lsp/dict_completions.rs:635— Transaction::dict_literal_string_literal_at 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.
Transaction::dict_literal_value_string_literal_at (cyclomatic 19) pyrefly/lib/state/lsp/dict_completions.rs:693— Transaction::dict_literal_value_string_literal_at 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 17) pyrefly/lib/state/lsp/dict_completions.rs:951— Transaction::extend_dict_key_suggestions 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.
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.
Server::process_event (cognitive 266) pyrefly/lib/lsp/non_wasm/server.rs:2094— Server::process_event has cognitive complexity 266 (threshold 15). Drivers by points: if/else 86 (173 pts), match/switch 21 (81 pts), boolean chains 9, loops 1 (3 pts) (nesting depth added 149). 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 96) pyrefly/lib/lsp/non_wasm/server.rs:5216— Server::code_action has cognitive complexity 96 (threshold 15). Drivers by points: if/else 35 (84 pts), loops 4 (11 pts), boolean chains 1 (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 48) pyrefly/lib/lsp/non_wasm/server.rs:4421— Server::notebook_document_did_change has cognitive complexity 48 (threshold 15). Drivers by points: if/else 16 (32 pts), loops 5 (15 pts), match/switch 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.
Server::type_hierarchy_subtype_items (cognitive 31) pyrefly/lib/lsp/non_wasm/server.rs:7081— 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::publish_for_handles (cognitive 29) pyrefly/lib/lsp/non_wasm/server.rs:3476— Server::publish_for_handles has cognitive complexity 29 (threshold 15). Drivers by points: if/else 8 (15 pts), loops 7 (11 pts), match/switch 1 (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.
Server::prune_baselines (cognitive 28) pyrefly/lib/lsp/non_wasm/server.rs:4022— 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::get_diag_if_shown (cognitive 22) pyrefly/lib/lsp/non_wasm/server.rs:3273— 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::did_close (cognitive 18) pyrefly/lib/lsp/non_wasm/server.rs:4685— Server::did_close has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (8 pts), match/switch 3 (5 pts), loops 1 (3 pts), boolean chains 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Server::async_go_to_implementations (cognitive 18) pyrefly/lib/lsp/non_wasm/server.rs:5080— 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:5634— 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:6580— 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.
D4 · Code Duplication· Members sharing a duplicated core (5 members, 50+ identical tokens) · ×10
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:30-80 | 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: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.
Subset::is_subset_eq_no_recursive_check (cognitive 143) pyrefly/lib/solver/subset.rs:1926— Subset::is_subset_eq_no_recursive_check has cognitive complexity 143 (threshold 15). Drivers by points: if/else 42 (73 pts), boolean chains 47, 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:3881— 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:262— 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:3285— 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:3717— 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:837— 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:3019— 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:1613— 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:761— 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.
Duplicated block (15 lines × 2) crates/pyrefly_types/src/display.rs:948— crates/pyrefly_types/src/display.rs:948-962 | crates/pyrefly_types/src/display.rs:964-978 — both copies are in the same file, so extract the 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/alt/attr.rs:2137— pyrefly/lib/alt/attr.rs:2137-2151 | pyrefly/lib/alt/attr.rs:2259-2273 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (15 lines × 2) pyrefly/lib/alt/call.rs:2123— pyrefly/lib/alt/call.rs:2123-2137 | pyrefly/lib/alt/call.rs:2147-2161 — both copies are in the same file, so extract the 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/alt/class/pydantic.rs:658— pyrefly/lib/alt/class/pydantic.rs:658-672 | pyrefly/lib/alt/class/pydantic.rs:850-864 — both copies are in the same file, so extract the 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/binding/class.rs:777— pyrefly/lib/binding/class.rs:777-791 | pyrefly/lib/binding/class.rs:824-838 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
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.
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.
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 17 separate duplicated blocks between them, totalling at least 201 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the 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/unet.py:215— tensor-shapes/pyrefly-torch-stubs/examples/unet.py:215-229 | tensor-shapes/pyrefly-torch-stubs/examples/unet.py:275-289 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
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.
Duplicated block (8 lines × 3) pyrefly/lib/alt/solve.rs:224— pyrefly/lib/alt/solve.rs:224-231 | pyrefly/lib/alt/solve.rs:242-249 | pyrefly/lib/alt/solve.rs:264-271 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
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:26-33 — 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:3115— pyrefly/lib/alt/polars_specials.rs:3115-3122 | pyrefly/lib/alt/polars_specials.rs:3148-3155 | pyrefly/lib/alt/polars_specials.rs:3180-3187 — 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) pyrefly/lib/alt/narrow.rs:2129— pyrefly/lib/alt/narrow.rs:2129-2136 | pyrefly/lib/alt/narrow.rs:2157-2164 | pyrefly/lib/alt/narrow.rs:2189-2196 — 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:438— tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:438-445 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations.py:441-448 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var.py:455-462 — 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 20 separate duplicated blocks between them, totalling at least 218 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. 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:438` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8 lines × 3) tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:565— tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:565-572 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations.py:568-575 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var.py:572-579 — 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 20 separate duplicated blocks between them, totalling at least 218 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (8 lines × 3) tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:213— tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:213-220 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations.py:213-220 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var.py:210-217 — 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 22 separate duplicated blocks between them, totalling at least 371 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (8 lines × 3) 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 20 separate duplicated blocks between them, totalling at least 218 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. 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.
Subset::is_subset_eq_no_recursive_check (cyclomatic 249) pyrefly/lib/solver/subset.rs:1926— Subset::is_subset_eq_no_recursive_check has cyclomatic complexity 249 (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:262— 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:3881— 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:3285— 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:837— 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:3717— 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:3019— 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:4651— 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:5136— 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:2194— 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:3159— 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:3357— 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:4102— 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:2530— 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.
Duplicated block (6 lines × 3) crates/pyrefly_config/src/args.rs:507— crates/pyrefly_config/src/args.rs:507-512 | crates/pyrefly_config/src/args.rs:514-519 | crates/pyrefly_config/src/args.rs:521-526 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (6 lines × 3) crates/pyrefly_types/src/type_level_dsl.rs:2849— crates/pyrefly_types/src/type_level_dsl.rs:2849-2854 | crates/pyrefly_types/src/type_level_dsl.rs:3623-3628 | crates/pyrefly_types/src/type_level_dsl.rs:4794-4799 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (6 lines × 3) crates/pyrefly_types/src/type_level_dsl.rs:7105— crates/pyrefly_types/src/type_level_dsl.rs:7105-7110 | crates/pyrefly_types/src/type_level_dsl.rs:7783-7788 | crates/pyrefly_types/src/type_level_dsl.rs:7814-7819 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (6 lines × 3) pyrefly/lib/alt/attr.rs:2153— pyrefly/lib/alt/attr.rs:2153-2159 | pyrefly/lib/alt/attr.rs:2188-2193 | pyrefly/lib/alt/attr.rs:2275-2281 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (6 lines × 3) 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/gptfast.py:411— tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:411-416 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations.py:414-419 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var.py:428-433 — 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 20 separate duplicated blocks between them, totalling at least 218 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. 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.
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.
TooManyFields: Stdlib crates/pyrefly_types/src/stdlib.rs:51— 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:197— 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:1151— TooManyFields — 50 stored fields beside 113 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: 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: BindingsBuilder pyrefly/lib/binding/bindings.rs:299— TooManyFields — 38 stored fields beside 228 methods. The bar is 30 stored fields; this is 8 over it, 1.27× 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:580— TooManyFields — 34 stored fields beside 54 methods. The bar is 30 stored fields; this is 4 over it, 1.13× 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.
Duplicated block (7 lines × 3) pyrefly/lib/alt/narrow.rs:1261— pyrefly/lib/alt/narrow.rs:1261-1267 | pyrefly/lib/alt/narrow.rs:1277-1283 | pyrefly/lib/alt/narrow.rs:1320-1326 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (7 lines × 3) 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.
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.
Duplicated block (7 lines × 3) tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:388— tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:388-394 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations.py:391-397 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var.py:404-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 20 separate duplicated blocks between them, totalling at least 218 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. 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:388` it does not close everything it opens, so those exact lines 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) tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:200— tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:200-206 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations.py:200-206 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var.py:197-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 22 separate duplicated blocks between them, totalling at least 371 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 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 22 separate duplicated blocks between them, totalling at least 371 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.
Server::process_event (cyclomatic 132) pyrefly/lib/lsp/non_wasm/server.rs:2094— Server::process_event 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.
Server::code_action (cyclomatic 40) pyrefly/lib/lsp/non_wasm/server.rs:5216— Server::code_action 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.
Server::notebook_document_did_change (cyclomatic 22) pyrefly/lib/lsp/non_wasm/server.rs:4421— Server::notebook_document_did_change 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.
Server::publish_for_handles (cyclomatic 17) pyrefly/lib/lsp/non_wasm/server.rs:3476— Server::publish_for_handles 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.
Server::prune_baselines (cyclomatic 16) pyrefly/lib/lsp/non_wasm/server.rs:4022— 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:2208— 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:1263— 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:1362— 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:1844— 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:2020— 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.
Duplicated block (16 lines × 2) pyrefly/lib/binding/narrow.rs:803— pyrefly/lib/binding/narrow.rs:803-818 | pyrefly/lib/binding/narrow.rs:836-851 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (16 lines × 2) pyrefly/lib/state/lsp.rs:2137— pyrefly/lib/state/lsp.rs:2137-2152 | pyrefly/lib/state/lsp.rs:2168-2183 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (16 lines × 2) pyrefly/lib/alt/special_calls.rs:113— pyrefly/lib/alt/special_calls.rs:113-128 | pyrefly/lib/alt/special_calls.rs:216-231 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (16 lines × 2) 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.
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.
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:39-47 — 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 (9 lines × 3) pyrefly/lib/lsp/non_wasm/workspace.rs:661— pyrefly/lib/lsp/non_wasm/workspace.rs:661-669 | pyrefly/lib/lsp/non_wasm/workspace.rs:692-700 | pyrefly/lib/lsp/non_wasm/workspace.rs:707-715 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (9 lines × 3) 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.
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.
Duplicated block (9 lines × 3) pyrefly/lib/lsp/non_wasm/server.rs:6267— pyrefly/lib/lsp/non_wasm/server.rs:6267-6275 | pyrefly/lib/lsp/non_wasm/server.rs:6292-6300 | pyrefly/lib/lsp/non_wasm/server.rs:6320-6328 — 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 (5 lines × 3) pyrefly/lib/lsp/non_wasm/server.rs:6262— pyrefly/lib/lsp/non_wasm/server.rs:6262-6266 | pyrefly/lib/lsp/non_wasm/server.rs:6287-6291 | pyrefly/lib/lsp/non_wasm/server.rs:6315-6319 — 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 (5 lines × 3) tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:448— tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:448-452 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations.py:451-455 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var.py:465-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 20 separate duplicated blocks between them, totalling at least 218 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. 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 × 3) tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:75— tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:75-79 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations.py:75-79 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var.py:76-80 — 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 22 separate duplicated blocks between them, totalling at least 371 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 22 separate duplicated blocks between them, totalling at least 371 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.
StructurallyValidatedTypeShapeDslFunction::evaluate_expression (cyclomatic 279) crates/pyrefly_types/src/type_level_dsl.rs:6985— StructurallyValidatedTypeShapeDslFunction::evaluate_expression has cyclomatic complexity 279 (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:8131— 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:6725— 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:8000— 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.
HackComment pyrefly/lib/alt/call.rs:2020— // 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:129— // 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:2476— // 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:423— // 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 285) crates/pyrefly_types/src/type_level_dsl.rs:6985— StructurallyValidatedTypeShapeDslFunction::evaluate_expression has cognitive complexity 285 (threshold 15). Drivers by points: match/switch 68 (147 pts), if/else 60 (121 pts), loops 6 (12 pts), boolean chains 5 (nesting depth added 146). 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:8131— 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:6725— 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:8000— 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:827— 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:899— 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.
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:594— 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::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:503— 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.
D30 · Dependency Vulnerabilities· Medium vulnerability · ×4
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 92% of the time (24 of the 26 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 24 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 68% of the time (13 of the 19 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 13 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 59% of the time (13 of the 22 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 13 shared commits counted here, the most recent 3 are `364aa770` Capture named integer keyword arguments; `e916f286` Delete the CallableResidual type; `702f0d12` Add Type::Overloaded — 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 56% of the time (23 of the 41 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 23 shared commits counted here, the most recent 3 are `c0ac8823` Compact binding storage; `d461a1ce` Detect illegal legacy type parameter shadowing; `df1f1ba1` Chain module-keyed `PossibleLegacyTParam` bindings — run `git show` on any of them.
Duplicated block (13 lines × 2) pyrefly/lib/alt/polars_specials.rs:3147— pyrefly/lib/alt/polars_specials.rs:3147-3159 | pyrefly/lib/alt/polars_specials.rs:3179-3191 — both copies are in the same file, so extract the 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/alt/unwrap.rs:276— pyrefly/lib/alt/unwrap.rs:276-288 | pyrefly/lib/alt/unwrap.rs:296-308 — both copies are in the same file, so extract the 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/query/type_table.rs:285— pyrefly/lib/query/type_table.rs:285-297 | pyrefly/lib/query/type_table.rs:442-454 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (13 lines × 2) pyrefly/lib/state/lsp/quick_fixes/pytest_fixture.rs:437— pyrefly/lib/state/lsp/quick_fixes/pytest_fixture.rs:437-449 | pyrefly/lib/state/lsp/quick_fixes/pytest_fixture.rs:498-510 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (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.
Duplicated block (11 lines × 3) pyrefly/lib/query/type_table.rs:284— pyrefly/lib/query/type_table.rs:284-294 | pyrefly/lib/query/type_table.rs:441-451 | pyrefly/lib/query/type_table.rs:514-524 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (11 lines × 3) tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:377— tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:377-387 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations.py:380-390 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var.py:393-403 — 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 20 separate duplicated blocks between them, totalling at least 218 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. 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 (11 lines × 3) tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:534— tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:534-544 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations.py:537-547 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var.py:546-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 20 separate duplicated blocks between them, totalling at least 218 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. 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:534` it does not close everything it opens, so those 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 × 3) crates/pyrefly_types/src/type_level_dsl.rs:7128— crates/pyrefly_types/src/type_level_dsl.rs:7128-7137 | crates/pyrefly_types/src/type_level_dsl.rs:7189-7198 | crates/pyrefly_types/src/type_level_dsl.rs:7325-7334 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (10 lines × 3) pyrefly/lib/alt/polars_specials.rs:3125— pyrefly/lib/alt/polars_specials.rs:3125-3134 | pyrefly/lib/alt/polars_specials.rs:3157-3166 | pyrefly/lib/alt/polars_specials.rs:3189-3198 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (10 lines × 3) tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:259— tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:259-268 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations.py:262-271 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var.py:280-289 — 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 20 separate duplicated blocks between them, totalling at least 218 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. 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.
Duplicated block (10 lines × 3) tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:427— tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:427-436 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations.py:430-439 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var.py:444-453 — 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 20 separate duplicated blocks between them, totalling at least 218 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. 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:427` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Swallowed exception (empty catch) lsp/src/extension.ts:63— `.catch(() => {})` handles the rejection by doing nothing — the failure is discarded with no log and no rethrow, and the chain carries on as if the work succeeded. Log it through whatever this codebase already uses to report problems, hand it to a caller that can (`next(error)`, a returned rejection), or don't catch it.
Swallowed exception (empty catch) lsp/src/extension.ts:92— `.catch(() => {})` handles the rejection by doing nothing — the failure is discarded with no log and no rethrow, and the chain carries on as if the work succeeded. Log it through whatever this codebase already uses to report problems, hand it to a caller that can (`next(error)`, a returned rejection), or don't catch it.
Swallowed exception (empty catch) lsp/src/python-environment.ts:51— An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
Swallowed exception (empty catch) lsp/src/python-environment.ts:134— `.catch(() => {})` handles the rejection by doing nothing — the failure is discarded with no log and no rethrow, and the chain carries on as if the work succeeded. Log it through whatever this codebase already uses to report problems, hand it to a caller that can (`next(error)`, a returned rejection), or don't catch it.
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::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:594— 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.
SemanticTokenBuilder::process_stmt (cyclomatic 36) pyrefly/lib/state/semantic_tokens.rs:761— SemanticTokenBuilder::process_stmt has cyclomatic complexity 36 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
SemanticTokenBuilder::process_syntax_tokens (cyclomatic 22) pyrefly/lib/state/semantic_tokens.rs:508— 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 16) pyrefly/lib/state/semantic_tokens.rs:686— SemanticTokenBuilder::process_expr has cyclomatic complexity 16 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
Scopes::finish_class_and_get_field_definitions (cyclomatic 21) pyrefly/lib/binding/scope.rs:3208— Scopes::finish_class_and_get_field_definitions 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.
Scopes::look_up_name_for_read (cyclomatic 19) pyrefly/lib/binding/scope.rs:3573— 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.
TypeDisplayContext::fmt_helper_generic (cognitive 225) crates/pyrefly_types/src/display.rs:917— TypeDisplayContext::fmt_helper_generic has cognitive complexity 225 (threshold 15). Drivers by points: if/else 64 (157 pts), match/switch 16 (31 pts), loops 9 (24 pts), boolean chains 13 (nesting depth added 123). 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.
TypeDisplayContext::fmt_params_hover (cognitive 45) crates/pyrefly_types/src/display.rs:712— 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:504— 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:761— 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:508— 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 17) pyrefly/lib/state/semantic_tokens.rs:686— SemanticTokenBuilder::process_expr has cognitive complexity 17 (threshold 15). Drivers by points: loops 4 (8 pts), if/else 3 (6 pts), match/switch 2 (3 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.
ConfigFile::configure_at (cognitive 66) crates/pyrefly_config/src/config.rs:1635— ConfigFile::configure_at has cognitive complexity 66 (threshold 15). Drivers by points: if/else 46 (52 pts), match/switch 6 (8 pts), boolean chains 3, loops 2 (3 pts) (nesting depth added 9). 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::query_source_db (cognitive 19) crates/pyrefly_config/src/config.rs:1527— 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.
ConfigFile::from_file::f (cognitive 19) crates/pyrefly_config/src/config.rs:2008— ConfigFile::from_file::f has cognitive complexity 19 (threshold 15). Drivers by points: if/else 9 (13 pts), match/switch 3 (4 pts), boolean chains 1, loops 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D30 · Dependency Vulnerabilities· Medium advisory (unmaintained) · ×3
Duplicated block (20 lines × 2) crates/pyrefly_types/src/type_level_dsl.rs:4169— crates/pyrefly_types/src/type_level_dsl.rs:4169-4188 | crates/pyrefly_types/src/type_level_dsl.rs:4209-4228 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (20 lines × 2) pyrefly/lib/commands/check.rs:1349— pyrefly/lib/commands/check.rs:1349-1368 | 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 (19 lines × 2) pyrefly/lib/alt/solve.rs:6092— pyrefly/lib/alt/solve.rs:6092-6110 | pyrefly/lib/alt/solve.rs:6153-6171 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (19 lines × 2) 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.
Duplicated block (19 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-481 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var_runnable.py:440-458 — 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 16 separate duplicated blocks between them, totalling at least 282 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the 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 (17 lines × 3) pyrefly/lib/alt/narrow.rs:1769— pyrefly/lib/alt/narrow.rs:1769-1785 | pyrefly/lib/alt/narrow.rs:1796-1812 | pyrefly/lib/alt/narrow.rs:1828-1844 — 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 (17 lines × 3) tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:164— tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:164-180 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations.py:164-180 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var.py:163-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 22 separate duplicated blocks between them, totalling at least 371 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:164` it does not close everything it opens, so those 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 (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 22 separate duplicated blocks between them, totalling at least 371 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.
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 (17 lines × 2) scripts/github_utils.py:765— scripts/github_utils.py:765-781 | scripts/github_utils.py:909-925 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift 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:765` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8–9 lines × 2) crates/pyrefly_types/src/display.rs:434— crates/pyrefly_types/src/display.rs:434-441 | crates/pyrefly_types/src/display.rs:486-494 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (8–9 lines × 2) crates/pyrefly_types/src/type_level_dsl.rs:6600— crates/pyrefly_types/src/type_level_dsl.rs:6600-6608 | crates/pyrefly_types/src/type_level_dsl.rs:6612-6619 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (8–9 lines × 2) pyrefly/lib/binding/stmt.rs:436— pyrefly/lib/binding/stmt.rs:436-443 | pyrefly/lib/binding/stmt.rs:561-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.
TypeDisplayContext::fmt_helper_generic (cyclomatic 154) crates/pyrefly_types/src/display.rs:917— TypeDisplayContext::fmt_helper_generic has cyclomatic complexity 154 (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:712— 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.
ConfigFile::configure_at (cyclomatic 59) crates/pyrefly_config/src/config.rs:1635— ConfigFile::configure_at has cyclomatic complexity 59 (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 (cyclomatic 18) crates/pyrefly_config/src/config.rs:1972— ConfigFile::from_file has cyclomatic complexity 18 (threshold 15). Most of this is not in the body itself: 1 of the 18 points is its own statement and the rest belongs to 2 function items inside it that branch (f, read_path). 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.
Solver::finish_quantified_with_captures (cyclomatic 41) pyrefly/lib/solver/solver.rs:2208— 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:1263— 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.
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:827— 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:1772— 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:1899— 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.
FixmeComment pyrefly/lib/alt/attr.rs:2902— // FIXME: — 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:2834— // 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.
DefinitionsBuilder::stmt (cognitive 168) pyrefly/lib/export/definitions.rs:582— DefinitionsBuilder::stmt has cognitive complexity 168 (threshold 15). Drivers by points: if/else 36 (92 pts), match/switch 13 (38 pts), loops 13 (28 pts), boolean chains 10 (nesting depth added 96). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
DefinitionsBuilder::resolve_module_entries (cognitive 16) pyrefly/lib/export/definitions.rs:557— 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.
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:947— 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:1080— 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.
Scopes::finish_class_and_get_field_definitions (cognitive 34) pyrefly/lib/binding/scope.rs:3208— Scopes::finish_class_and_get_field_definitions has cognitive complexity 34 (threshold 15). Drivers by points: if/else 15 (26 pts), match/switch 2 (5 pts), boolean chains 3 (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.
Scopes::look_up_name_for_read (cognitive 27) pyrefly/lib/binding/scope.rs:3573— Scopes::look_up_name_for_read has cognitive complexity 27 (threshold 15). Drivers by points: if/else 12 (18 pts), boolean chains 6, 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.
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:1123— 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 21) pyrefly/lib/alt/types/class_metadata.rs:1015— Linearization::new has cognitive complexity 21 (threshold 15). Drivers by points: if/else 4 (11 pts), loops 2 (4 pts), boolean chains 3, match/switch 2 (3 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:47— 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 20) pyrefly/lib/state/import_tracker.rs:188— ImportTracker::resolve_annotation has cognitive complexity 20 (threshold 15). Drivers by points: if/else 9 (15 pts), boolean chains 2, match/switch 1 (2 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.
ArgsExpander::expand (cognitive 27) pyrefly/lib/alt/overload.rs:120— ArgsExpander::expand has cognitive complexity 27 (threshold 15). Drivers by points: match/switch 4 (12 pts), if/else 5 (10 pts), loops 2 (5 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.
ArgsExpander::expand_type (cognitive 19) pyrefly/lib/alt/overload.rs:191— 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:402— 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:201— 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:1137— 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:1530— 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:555— 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:909— 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:2656— 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:3180— 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.
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.
Change-coupling hub: query_source_db.rs → buck.rs, buck_check.rs, map_db.rs crates/pyrefly_build/src/source_db/query_source_db.rs— `crates/pyrefly_build/src/source_db/query_source_db.rs` changes together with 3 other files — `crates/pyrefly_build/src/query/buck.rs`, `crates/pyrefly_build/src/source_db/buck_check.rs`, `crates/pyrefly_build/src/source_db/map_db.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.
D4 · Code Duplication· Members sharing a duplicated core (4 members, 50+ identical tokens) · ×2
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.
Members sharing a duplicated core (4 members, 50+ identical tokens) pyrefly/lib/alt/class/class_field.rs:906— pyrefly/lib/alt/class/class_field.rs:906-916 | pyrefly/lib/alt/class/class_field.rs:918-928 | pyrefly/lib/alt/class/class_field.rs:1008-1020 | pyrefly/lib/alt/class/class_field.rs:1269-1281 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
Duplicated block (21 lines × 2) pyrefly/lib/alt/class/class_field.rs:960— pyrefly/lib/alt/class/class_field.rs:960-980 | pyrefly/lib/alt/class/class_field.rs:982-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.
Duplicated block (21 lines × 2) tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations_runnable.py:408— tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations_runnable.py:408-428 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var_runnable.py:408-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 17 separate duplicated blocks between them, totalling at least 201 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the 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 (14–15 lines × 2) pyrefly/lib/alt/expr.rs:2677— pyrefly/lib/alt/expr.rs:2677-2691 | pyrefly/lib/alt/expr.rs:2715-2728 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (14–15 lines × 2) pyrefly/lib/alt/polars_specials.rs:3091— pyrefly/lib/alt/polars_specials.rs:3091-3104 | pyrefly/lib/alt/polars_specials.rs:3209-3223 — both copies are in the same file, so extract the 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/alt/class/variance_inference.rs:741— pyrefly/lib/alt/class/variance_inference.rs:741-753 | pyrefly/lib/alt/class/variance_inference.rs:763-772 — both copies are in the same file, so extract the 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:332— pyrefly/lib/commands/infer.rs:332-341 | 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 (11–12 lines × 2) pyrefly/lib/alt/class/class_field.rs:1238— pyrefly/lib/alt/class/class_field.rs:1238-1249 | pyrefly/lib/alt/class/class_field.rs:1254-1264 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (11–12 lines × 2) conformance/conformance_output.py:234— conformance/conformance_output.py:234-244 | conformance/conformance_output.py:274-285 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift 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:234` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (9 lines × 5) pyrefly/lib/lsp/non_wasm/server.rs:2500— pyrefly/lib/lsp/non_wasm/server.rs:2500-2508 | pyrefly/lib/lsp/non_wasm/server.rs:2575-2583 | pyrefly/lib/lsp/non_wasm/server.rs:2871-2879 | pyrefly/lib/lsp/non_wasm/server.rs:2886-2894 | pyrefly/lib/lsp/non_wasm/server.rs:2916-2924 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (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 20 separate duplicated blocks between them, totalling at least 218 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. 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 (4–7 lines × 3) pyrefly/lib/playground.rs:473— pyrefly/lib/playground.rs:473-476 | pyrefly/lib/playground.rs:500-506 | pyrefly/lib/playground.rs:530-536 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (4–7 lines × 3) tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:484— tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:484-487 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations.py:488-494 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var.py:497-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 20 separate duplicated blocks between them, totalling at least 218 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. 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:484` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations.py:488` calls `assert_type` and `tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:484` does not — after which the two agree again for 5 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (15 lines × 3) pyrefly/lib/alt/special_calls.rs:116— pyrefly/lib/alt/special_calls.rs:116-130 | pyrefly/lib/alt/special_calls.rs:219-233 | pyrefly/lib/alt/special_calls.rs:341-355 — 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 (15 lines × 3) tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:283— tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:283-297 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations.py:286-300 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var.py:304-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 20 separate duplicated blocks between them, totalling at least 218 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. 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:283` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (14 lines × 3) tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:470— tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:470-483 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations.py:473-486 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var.py:482-495 — 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 20 separate duplicated blocks between them, totalling at least 218 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (14 lines × 3) tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:545— tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:545-558 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations.py:545-558 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var.py:526-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 22 separate duplicated blocks between them, totalling at least 371 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 × 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 22 separate duplicated blocks between them, totalling at least 371 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 22 separate duplicated blocks between them, totalling at least 371 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:571— 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.
R4 · Test Coverage· No test reaches this file · ×2
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.
X17 · Uncapped recursion over a caller-supplied document· Recursive walk over a caller-supplied document has no depth cap · ×2
Recursive walk over a caller-supplied document has no depth cap pyrefly/lib/report/cinderx/view_types.py:97— `format_type` is public and takes `ty: dict[str, Any]` from its caller, and it calls itself at line 97 (`format_type`) with a piece of `ty` (and at line 103, line 112, line 117, line 118, line 125, line 126, line 133) — and nowhere in `format_type` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `format_type` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack.
Recursive walk over a caller-supplied document has no depth cap crates/tsp_types/protocol_generator/generate_protocol.py:321— `convert_type_reference` is public and takes `type_def: Dict[str, Any]` from its caller, and it calls itself at line 321 (`convert_type_reference`) with a piece of `type_def` (and at line 324, line 327, line 334, line 349) — and nowhere in `convert_type_reference` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `convert_type_reference` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack.
DefinitionsBuilder::stmt (cyclomatic 91) pyrefly/lib/export/definitions.rs:582— DefinitionsBuilder::stmt has cyclomatic complexity 91 (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 76) pyrefly/lib/binding/binding.rs:2758— Binding::fmt has cyclomatic complexity 76 (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.
NarrowOps::from_expr_helper (cyclomatic 55) pyrefly/lib/binding/narrow.rs:899— NarrowOps::from_expr_helper has cyclomatic complexity 55 (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.
CheckArgs::finish_cli_run (cyclomatic 55) pyrefly/lib/commands/check.rs:1907— CheckArgs::finish_cli_run has cyclomatic complexity 55 (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.
TypeConverter::convert (cyclomatic 55) pyrefly/lib/tsp/type_conversion.rs:226— 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:947— 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.
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.
ConfigOverrideArgs::override_config_at (cyclomatic 33) crates/pyrefly_config/src/args.rs:547— ConfigOverrideArgs::override_config_at has cyclomatic complexity 33 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
TypeShapeDslHelperCall::argument_domains (cyclomatic 28) crates/pyrefly_types/src/type_level_dsl.rs:209— 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.
compare_typecheckers.check_project (cyclomatic 28) scripts/compare_typecheckers.py:548— compare_typecheckers.check_project has cyclomatic complexity 28 (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.
Errors::collect_unused_ignore_errors (cyclomatic 27) pyrefly/lib/state/errors.rs:540— Errors::collect_unused_ignore_errors 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.
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.
CalleesWithLocation::callee_from_type (cyclomatic 25) pyrefly/lib/query.rs:955— CalleesWithLocation::callee_from_type 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.
extension.activate (cyclomatic 25) lsp/src/extension.ts:234— extension.activate has cyclomatic complexity 25 (threshold 15). Most of this is not in the body itself: 6 of the 25 points are its own statements and the rest belongs to 8 function literals inside it that branch (lines 454, 384, 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.
InitArgs::create_config (cyclomatic 24) pyrefly/lib/commands/init.rs:236— 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:3180— 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.
DslExpr::fmt (cyclomatic 23) crates/pyrefly_types/src/meta_shape_dsl.rs:688— DslExpr::fmt has cyclomatic complexity 23 (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.
BindingExpect::fmt (cyclomatic 21) pyrefly/lib/binding/binding.rs:1351— BindingExpect::fmt 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. This is NOT this file's highest cyclomatic complexity: Key::range (cyclomatic 29) 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:184— 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.
github_utils.list_contributors_main (cyclomatic 21) scripts/github_utils.py:784— github_utils.list_contributors_main has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
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.
generate_release_notes._fix_bug_fix_count (cyclomatic 20) scripts/generate_release_notes.py:460— generate_release_notes._fix_bug_fix_count 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:666— 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.
Int::fmt_prec (cyclomatic 18) crates/pyrefly_types/src/dimension.rs:448— 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.
Bindings::new (cyclomatic 18) pyrefly/lib/binding/bindings.rs:709— Bindings::new 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.
PysaModuleIndex::build (cyclomatic 18) pyrefly/lib/report/pysa/module_index.rs:141— PysaModuleIndex::build 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.
CallArg::pre_eval (cyclomatic 17) pyrefly/lib/alt/callable.rs:328— CallArg::pre_eval 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.
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.
ResolvedTypeShapeDslProgram::evaluate_suite (cyclomatic 16) crates/pyrefly_types/src/type_level_dsl.rs:6468— 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.
CallArgPreEval::post_check (cyclomatic 16) pyrefly/lib/alt/callable.rs:508— CallArgPreEval::post_check 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.
InferArgs::run_inner (cyclomatic 16) pyrefly/lib/commands/infer.rs:326— InferArgs::run_inner 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.
ContextualTypeCollector::visit_stmt (cyclomatic 16) pyrefly/lib/report/cinderx/collect.rs:173— 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:279— 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:307— 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.
github_utils.load_env_file (cyclomatic 16) scripts/github_utils.py:87— github_utils.load_env_file 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* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
XxxComment pyrefly/lib/state/lsp.rs:1228— // 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.
CheckArgs::finish_cli_run (cognitive 89) pyrefly/lib/commands/check.rs:1907— CheckArgs::finish_cli_run has cognitive complexity 89 (threshold 15). Drivers by points: if/else 50 (66 pts), match/switch 3 (9 pts), loops 4 (8 pts), boolean chains 6 (nesting depth added 26). 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.
Errors::collect_unused_ignore_errors (cognitive 80) pyrefly/lib/state/errors.rs:540— Errors::collect_unused_ignore_errors has cognitive complexity 80 (threshold 15). Drivers by points: if/else 16 (53 pts), loops 7 (18 pts), boolean chains 5, match/switch 1 (4 pts) (nesting depth added 51). To reduce it, split the body into named stages: move each independent 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:899— 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.
PysaModuleIndex::build (cognitive 46) pyrefly/lib/report/pysa/module_index.rs:141— PysaModuleIndex::build has cognitive complexity 46 (threshold 15). Drivers by points: if/else 13 (40 pts), loops 4 (5 pts), boolean chains 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.
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.
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.
Binding::fmt (cognitive 40) pyrefly/lib/binding/binding.rs:2758— Binding::fmt has cognitive complexity 40 (threshold 15). Drivers by points: if/else 8 (19 pts), match/switch 8 (15 pts), loops 3 (6 pts) (nesting depth added 21). 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.
CallArg::pre_eval (cognitive 38) pyrefly/lib/alt/callable.rs:328— CallArg::pre_eval has cognitive complexity 38 (threshold 15). Drivers by points: if/else 8 (20 pts), loops 3 (10 pts), match/switch 3 (7 pts), boolean chains 1 (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.
TypeShapeDslHelperCall::argument_domains (cognitive 37) crates/pyrefly_types/src/type_level_dsl.rs:209— 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:236— 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.
ConfigOverrideArgs::override_config_at (cognitive 35) crates/pyrefly_config/src/args.rs:547— ConfigOverrideArgs::override_config_at has cognitive complexity 35 (threshold 15). Drivers by points: if/else 24 (27 pts), loops 5, boolean chains 2, match/switch 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.
InferArgs::run_inner (cognitive 35) pyrefly/lib/commands/infer.rs:326— InferArgs::run_inner has cognitive complexity 35 (threshold 15). Drivers by points: if/else 14 (28 pts), boolean chains 4, loops 2 (3 pts) (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
github_utils.list_contributors_main (cognitive 35) scripts/github_utils.py:784— github_utils.list_contributors_main has cognitive complexity 35 (threshold 15). Drivers by points: if/else 11 (18 pts), ternaries 2 (8 pts), boolean chains 7, error handling 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.
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.
compare_typecheckers.check_project (cognitive 34) scripts/compare_typecheckers.py:548— compare_typecheckers.check_project has cognitive complexity 34 (threshold 15). Drivers by points: if/else 17 (20 pts), boolean chains 9, ternaries 5 (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.
github_utils.fetch_bug_issues (cognitive 34) scripts/github_utils.py:562— github_utils.fetch_bug_issues has cognitive complexity 34 (threshold 15). Drivers by points: if/else 9 (24 pts), loops 3 (5 pts), error handling 1 (3 pts), boolean chains 2 (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.
ContextualTypeCollector::visit_stmt (cognitive 32) pyrefly/lib/report/cinderx/collect.rs:173— 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.
conformance_output.main (cognitive 31) conformance/conformance_output.py:307— 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.
ErrorCollector::collect_into (cognitive 30) pyrefly/lib/error/collector.rs:329— ErrorCollector::collect_into has cognitive complexity 30 (threshold 15). Drivers by points: if/else 8 (21 pts), match/switch 1 (4 pts), boolean chains 3, loops 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.
ContributorAnalyzer._extract_contributors (cognitive 30) scripts/github_utils.py:356— ContributorAnalyzer._extract_contributors has cognitive complexity 30 (threshold 15). Drivers by points: if/else 9 (27 pts), boolean chains 2, 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.
github_utils.load_env_file (cognitive 29) scripts/github_utils.py:87— github_utils.load_env_file has cognitive complexity 29 (threshold 15). Drivers by points: if/else 8 (20 pts), boolean chains 5, loops 2 (4 pts) (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
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.
generate_release_notes._fix_bug_fix_count (cognitive 26) scripts/generate_release_notes.py:460— generate_release_notes._fix_bug_fix_count has cognitive complexity 26 (threshold 15). Drivers by points: if/else 12 (19 pts), boolean chains 4, loops 3 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
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:666— 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.
Bindings::new (cognitive 25) pyrefly/lib/binding/bindings.rs:709— Bindings::new has cognitive complexity 25 (threshold 15). Drivers by points: if/else 12 (18 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.
ResolvedTypeShapeDslProgram::evaluate_suite (cognitive 24) crates/pyrefly_types/src/type_level_dsl.rs:6468— 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.
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.
extension.activate (cognitive 23) lsp/src/extension.ts:234— extension.activate has cognitive complexity 23 (threshold 15). Drivers by points: if/else 15, boolean chains 3, error handling 3, ternaries 1 (2 pts) (nesting depth added 1). Most of this is not in the body itself: 5 of the 23 points are its own statements and the rest belongs to 8 function literals inside it that branch (lines 454, 384, 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.
RenameUsageVisitor::visit_stmt (cognitive 22) pyrefly/lib/lsp/non_wasm/will_rename_files.rs:78— 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:167— 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.
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.
TspExtraConnection::run (cognitive 21) pyrefly/lib/tsp/server.rs:551— 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:739— 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.
BaselineIndex::apply (cognitive 20) pyrefly/lib/error/baseline.rs:351— 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:1772— 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:279— 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:193— 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:494— 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.
Answers::solve (cognitive 18) pyrefly/lib/alt/answers.rs:1357— Answers::solve has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (11 pts), loops 2 (3 pts), match/switch 1 (3 pts), boolean chains 1 (nesting depth added 8). Of this number, 15 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.
CallArgPreEval::post_check (cognitive 18) pyrefly/lib/alt/callable.rs:508— CallArgPreEval::post_check has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (11 pts), match/switch 3 (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.
PytestAliases::from_module (cognitive 18) pyrefly/lib/binding/pytest.rs:28— PytestAliases::from_module has cognitive complexity 18 (threshold 15). Drivers by points: if/else 2 (8 pts), loops 3 (7 pts), match/switch 1 (2 pts), boolean chains 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ModuleDeps::invalidated_by (cognitive 18) pyrefly/lib/state/state.rs:412— 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.
github_utils.display_contributors (cognitive 18) scripts/github_utils.py:413— github_utils.display_contributors has cognitive complexity 18 (threshold 15). Drivers by points: if/else 9 (13 pts), loops 2 (4 pts), ternaries 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
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.
DslExpr::fmt (cognitive 17) crates/pyrefly_types/src/meta_shape_dsl.rs:688— DslExpr::fmt has cognitive complexity 17 (threshold 15). Drivers by points: if/else 5 (12 pts), loops 2 (4 pts), match/switch 1 (nesting depth added 9). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
Solutions::changed_exports::check_table (cognitive 17) pyrefly/lib/alt/answers.rs:1047— 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.
Claims::visit_stmt (cognitive 17) pyrefly/lib/binding/shape_comments.rs:434— Claims::visit_stmt has cognitive complexity 17 (threshold 15). Drivers by points: if/else 3 (8 pts), match/switch 3 (7 pts), loops 1 (2 pts) (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.
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:1836— 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:134— 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.
Static::stmts (cognitive 16) pyrefly/lib/binding/scope.rs:508— 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.
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.
compare_typecheckers.main (cognitive 16) scripts/compare_typecheckers.py:822— compare_typecheckers.main has cognitive complexity 16 (threshold 15). Drivers by points: if/else 11 (14 pts), ternaries 2 (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.
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:36— TooManyFunctions — 32 free functions. The bar is 30 free functions; 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.
Near-duplicate member pair (26 shared lines) crates/pyrefly_types/src/type_level_dsl.rs:3641— crates/pyrefly_types/src/type_level_dsl.rs:3641-3701 | crates/pyrefly_types/src/type_level_dsl.rs:3776-3819 — 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.
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.
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 58 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the 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 (27–33 lines × 2) pyrefly/lib/lsp/non_wasm/server.rs:6996— pyrefly/lib/lsp/non_wasm/server.rs:6996-7028 | pyrefly/lib/lsp/non_wasm/server.rs:7153-7179 — both copies are in the same file, so extract the 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 (28–30 lines × 2) pyrefly/lib/alt/narrow.rs:1549— pyrefly/lib/alt/narrow.rs:1549-1576 | pyrefly/lib/alt/narrow.rs:1625-1654 — both copies are in the same file, so extract the 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 (28 lines × 2) pyrefly/lib/report/pysa/call_graph.rs:2316— pyrefly/lib/report/pysa/call_graph.rs:2316-2343 | pyrefly/lib/report/pysa/call_graph.rs:2347-2374 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (22–23 lines × 2) pyrefly/lib/alt/solve.rs:4624— pyrefly/lib/alt/solve.rs:4624-4645 | pyrefly/lib/alt/solve.rs:4663-4685 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (22 lines × 2) pyrefly/lib/report/cinderx/convert.rs:90— pyrefly/lib/report/cinderx/convert.rs:90-111 | pyrefly/lib/report/cinderx/convert.rs:381-402 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (20–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.
Duplicated block (18–19 lines × 3) pyrefly/lib/alt/solve.rs:6910— pyrefly/lib/alt/solve.rs:6910-6928 | pyrefly/lib/alt/solve.rs:6933-6951 | pyrefly/lib/alt/solve.rs:7150-7167 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (18–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.
Duplicated block (15–16 lines × 2) pyrefly/lib/alt/attr.rs:3363— pyrefly/lib/alt/attr.rs:3363-3377 | pyrefly/lib/alt/attr.rs:3380-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.
Duplicated block (12–14 lines × 2) pyrefly/lib/lsp/wasm/completion.rs:904— pyrefly/lib/lsp/wasm/completion.rs:904-915 | pyrefly/lib/state/lsp.rs:463-476 — 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 (9–13 lines × 3) pyrefly/lib/alt/function.rs:2810— pyrefly/lib/alt/function.rs:2810-2818 | pyrefly/lib/alt/function.rs:2862-2870 | pyrefly/lib/alt/function.rs:2907-2919 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (12–13 lines × 2) pyrefly/lib/lsp/wasm/signature_help.rs:358— pyrefly/lib/lsp/wasm/signature_help.rs:358-370 | pyrefly/lib/lsp/wasm/signature_help.rs:382-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 (9–11 lines × 2) crates/pyrefly_types/src/type_level_dsl.rs:2646— crates/pyrefly_types/src/type_level_dsl.rs:2646-2656 | crates/pyrefly_types/src/type_level_dsl.rs:3938-3946 — both copies are in the same file, so extract the 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–11 lines × 2) pyrefly/lib/alt/solve.rs:6076— pyrefly/lib/alt/solve.rs:6076-6086 | pyrefly/lib/alt/solve.rs:6140-6147 — both copies are in the same file, so extract the 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:3871— pyrefly/lib/lsp/non_wasm/server.rs:3871-3877 | pyrefly/lib/lsp/non_wasm/server.rs:3912-3922 — both copies are in the same file, so extract the 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–10 lines × 2) pyrefly/lib/binding/class.rs:1386— pyrefly/lib/binding/class.rs:1386-1395 | pyrefly/lib/binding/class.rs:1447-1452 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (9–10 lines × 2) pyrefly/lib/commands/infer.rs:344— pyrefly/lib/commands/infer.rs:344-352 | 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.
Duplicated block (5–9 lines × 2) pyrefly/lib/solver/subset.rs:2754— pyrefly/lib/solver/subset.rs:2754-2762 | pyrefly/lib/solver/subset.rs:2767-2771 — both copies are in the same file, so extract the 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 × 11) pyrefly/lib/lsp/non_wasm/server.rs:2454— pyrefly/lib/lsp/non_wasm/server.rs:2454-2461 | pyrefly/lib/lsp/non_wasm/server.rs:2486-2493 | pyrefly/lib/lsp/non_wasm/server.rs:2561-2568 | pyrefly/lib/lsp/non_wasm/server.rs:2646-2653 | pyrefly/lib/lsp/non_wasm/server.rs:2681-2688 | pyrefly/lib/lsp/non_wasm/server.rs:2708-2715 | pyrefly/lib/lsp/non_wasm/server.rs:2723-2730 | pyrefly/lib/lsp/non_wasm/server.rs:2738-2745 | pyrefly/lib/lsp/non_wasm/server.rs:2842-2849 | pyrefly/lib/lsp/non_wasm/server.rs:2857-2864 | pyrefly/lib/lsp/non_wasm/server.rs:2902-2909 — all 11 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (8 lines × 6) pyrefly/lib/alt/narrow.rs:1424— pyrefly/lib/alt/narrow.rs:1424-1431 | pyrefly/lib/alt/narrow.rs:1446-1453 | pyrefly/lib/alt/narrow.rs:1468-1475 | pyrefly/lib/alt/narrow.rs:1481-1488 | pyrefly/lib/alt/narrow.rs:1497-1504 | pyrefly/lib/alt/narrow.rs:1513-1520 — all 6 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (7–8 lines × 2) pyrefly/lib/alt/shape_extension.rs:220— pyrefly/lib/alt/shape_extension.rs:220-226 | 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.
Duplicated block (7 lines × 4) pyrefly/lib/state/semantic_tokens.rs:724— pyrefly/lib/state/semantic_tokens.rs:724-730 | pyrefly/lib/state/semantic_tokens.rs:732-738 | pyrefly/lib/state/semantic_tokens.rs:740-746 | pyrefly/lib/state/semantic_tokens.rs:748-754 — 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–7 lines × 2) pyrefly/lib/solver/subset.rs:2129— pyrefly/lib/solver/subset.rs:2129-2134 | pyrefly/lib/solver/subset.rs:2155-2161 — both copies are in the same file, so extract the 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 × 4) pyrefly/lib/alt/class/class_field.rs:907— pyrefly/lib/alt/class/class_field.rs:907-912 | pyrefly/lib/alt/class/class_field.rs:919-924 | pyrefly/lib/alt/class/class_field.rs:1009-1014 | pyrefly/lib/alt/class/class_field.rs:1270-1275 — 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 (13 lines × 3) crates/pyrefly_config/src/migration/mypy/pyproject.rs:203— crates/pyrefly_config/src/migration/mypy/pyproject.rs:203-215 | crates/pyrefly_config/src/migration/mypy/pyproject.rs:217-229 | crates/pyrefly_config/src/migration/mypy/pyproject.rs:241-253 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (10 lines × 4) crates/pyrefly_lsp_test/src/object_model.rs:1009— crates/pyrefly_lsp_test/src/object_model.rs:1009-1018 | crates/pyrefly_lsp_test/src/object_model.rs:1039-1048 | crates/pyrefly_lsp_test/src/object_model.rs:1071-1080 | crates/pyrefly_lsp_test/src/object_model.rs:1112-1121 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (9 lines × 4) pyrefly/lib/report/pysa/call_graph.rs:3263— pyrefly/lib/report/pysa/call_graph.rs:3263-3271 | pyrefly/lib/report/pysa/call_graph.rs:3276-3284 | pyrefly/lib/report/pysa/call_graph.rs:3289-3297 | pyrefly/lib/report/pysa/call_graph.rs:3302-3310 — 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 (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:30-74 | 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:64-77 | 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.
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 (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.
D4 · Code Duplication· Near-duplicate member family (5 members, 26 shared lines) · ×1
Near-duplicate member family (5 members, 26 shared lines) 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 are variants of one another: a block of 26 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
D4 · Code Duplication· Near-duplicate member family (5 members, 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.
D4 · Code Duplication· Near-duplicate member family (3 members, 69 shared lines) · ×1
Near-duplicate member family (3 members, 69 shared lines) 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 — These 3 members are variants of one another: a block of 69 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 3 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 3 times.
D4 · Code Duplication· Near-duplicate member family (3 members, 29 shared lines) · ×1
Near-duplicate member family (3 members, 29 shared lines) 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 — These 3 members are variants of one another: a block of 29 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 3 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 3 times.
D4 · Code Duplication· Near-duplicate member family (3 members, 10 shared lines) · ×1
Near-duplicate member family (3 members, 10 shared lines) 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 — These 3 members are variants of one another: a block of 10 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 3 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 3 times.
Near-duplicate member pair (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.
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 22 separate duplicated blocks between them, totalling at least 371 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 16 separate duplicated blocks between them, totalling at least 282 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the 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 22 separate duplicated blocks between them, totalling at least 371 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 (32 lines × 3) tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:106— tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:106-137 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations.py:106-137 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var.py:105-136 — 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 22 separate duplicated blocks between them, totalling at least 371 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.
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 16 separate duplicated blocks between them, totalling at least 282 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the 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 (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 20 separate duplicated blocks between them, totalling at least 218 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. 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 (26 lines × 5) tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:472— tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:472-497 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations.py:472-497 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations_runnable.py:412-437 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var.py:453-478 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var_runnable.py:389-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 22 separate duplicated blocks between them, totalling at least 371 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 (22 lines × 3) tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:523— tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:523-544 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations.py:523-544 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var.py:504-525 — 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 22 separate duplicated blocks between them, totalling at least 371 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 (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 20 separate duplicated blocks between them, totalling at least 218 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. 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 (20 lines × 3) tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:139— tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:139-158 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations.py:139-158 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var.py:138-157 — 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 22 separate duplicated blocks between them, totalling at least 371 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:139` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
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 20 separate duplicated blocks between them, totalling at least 218 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. 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 22 separate duplicated blocks between them, totalling at least 371 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 22 separate duplicated blocks between them, totalling at least 371 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (14 lines × 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 22 separate duplicated blocks between them, totalling at least 371 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–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 (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 22 separate duplicated blocks between them, totalling at least 371 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 × 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 20 separate duplicated blocks between them, totalling at least 218 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. 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 20 separate duplicated blocks between them, totalling at least 218 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. 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 (5 lines × 5) tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:334— tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:334-338 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations.py:334-338 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations_runnable.py:286-290 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var.py:315-319 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_sym_int_var_runnable.py:263-267 — 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 22 separate duplicated blocks between them, totalling at least 371 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 20 separate duplicated blocks between them, totalling at least 218 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. 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 22 separate duplicated blocks between them, totalling at least 371 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:141— lsp/src/extension.ts:141 · lsp/src/extension.ts:409 — 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 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: 534 lines of code lsp/src/extension.ts:1— lsp/src/extension.ts has 534 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.
Interpolated log message defeats structured logging scripts/compare_typecheckers.py:69— `warning` at line 69 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.warning("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.warning("order moved", order_id=order_id, status=status)` with structlog.
Interpolated log message defeats structured logging scripts/compare_typecheckers.py: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 scripts/compare_typecheckers.py:100— `info` at line 100 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 scripts/compare_typecheckers.py:102— `info` at line 102 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 scripts/compare_typecheckers.py:150— `warning` at line 150 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.warning("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.warning("order moved", order_id=order_id, status=status)` with structlog.
Interpolated log message defeats structured logging scripts/compare_typecheckers.py:177— `debug` at line 177 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.debug("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.debug("order moved", order_id=order_id, status=status)` with structlog.
Interpolated log message defeats structured logging scripts/compare_typecheckers.py:189— `debug` at line 189 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.debug("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.debug("order moved", order_id=order_id, status=status)` with structlog.
Interpolated log message defeats structured logging scripts/compare_typecheckers.py:196— `debug` at line 196 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.debug("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.debug("order moved", order_id=order_id, status=status)` with structlog.
Interpolated log message defeats structured logging scripts/compare_typecheckers.py:423— `info` at line 423 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 scripts/compare_typecheckers.py:441— `info` at line 441 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 scripts/compare_typecheckers.py:490— `info` at line 490 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 scripts/compare_typecheckers.py:574— `warning` at line 574 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.warning("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.warning("order moved", order_id=order_id, status=status)` with structlog.
Interpolated log message defeats structured logging scripts/compare_typecheckers.py:702— `info` at line 702 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 scripts/compare_typecheckers.py:771— `info` at line 771 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 scripts/compare_typecheckers.py:788— `info` at line 788 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 scripts/compare_typecheckers.py:803— `error` at line 803 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 scripts/compare_typecheckers.py:884— `info` at line 884 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 scripts/compare_typecheckers.py:886— `info` at line 886 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 scripts/compare_typecheckers.py:894— `info` at line 894 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 scripts/setup_primer_deps.py:37— `warning` at line 37 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.warning("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.warning("order moved", order_id=order_id, status=status)` with structlog.
Interpolated log message defeats structured logging scripts/setup_primer_deps.py:40— `info` at line 40 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 scripts/setup_primer_deps.py:42— `info` at line 42 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: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:326— `error` at line 326 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.
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:1380— `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:1412— `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:409— `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:404— `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:2311— `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:395— `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:345— `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:351— `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:368— `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:331— `!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:708— `!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:2771— `!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:107— `base.has_toplevel_qname("torch.nn", "Module") || base.has_toplevel_qname("torch.nn.modules.module", "Module")` 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:2849— `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:2612— `cls.is_builtin("_NotImplementedType") || cls.has_qname("types", "NotImplementedType")` appears character-identically in 2 files — pyrefly/lib/alt/call.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:185— `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:3236— `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:524— `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:676— `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.
Silent fallback default on Err pyrefly/lib/binding/narrow.rs:698— `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:42— `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, 18 significant file(s) lose their only recent owner: crates/pyrefly_types/src/type_level_dsl.rs, pyrefly/lib/alt/type_level_dsl.rs, pyrefly/lib/binding/shape_type.rs, crates/pyrefly_types/src/gufunc.rs, crates/pyrefly_types/src/einops.rs, crates/pyrefly_types/src/map_int_tuples.rs, crates/pyrefly_types/src/einsum.rs, tensor-shapes/pyrefly-shape-extensions/shape_extensions/__init__.py (+10 more). Pair on, review, or document these before any departure.
Off-boarding risk: anonymized user #2 — If anonymized user #2 becomes unavailable, 8 significant file(s) lose their only recent owner: pyrefly/lib/lsp/non_wasm/connection.rs, pyrefly/lib/export/symbols.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, crates/pyrefly_python/src/deprecated_aliases.rs. Pair on, review, or document these before any departure.
Off-boarding risk: anonymized user #3 — If anonymized user #3 becomes unavailable, 6 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_util/src/with_hash.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 pyrefly/lib/error/code_climate.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) — 11 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 (48 single-owned of 391 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; 391 of the 504 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)) (+5 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 (+8 more).
No ADRs found — No ADRs found. No recognised ADR directory (`docs/adr/`, `docs/decisions/`, `adr/`, `docs/rfcs/`, an `ADR0001/` folder, or their siblings) exists anywhere in this tree. What was searched, so you can tell an empty log from a search that missed one: every directory under the tree (build output, dependencies and VCS metadata excepted), for a document that is either any non-index page inside a recognised ADR directory, whatever its name and however deeply nested (`docs/adr/use-postgres.md`, `docs/adr/2024/0001-x.md`); or a file anywhere whose name is ADR-shaped (`0001-use-postgres.md`, `adr-012-caching.md`); or, when neither turned anything up, a document carrying the decision-record signature (an "Architecture Decision Record" heading, or Status / Context / Decision / Consequences as section headings). A decision log that clears none of these — unnumbered files outside any recognised directory, without those headings — is not seen by this check and this row is then wrong. If that is your case, say so rather than renaming anything; otherwise, consider recording architectural decisions in `docs/adr/`.
D26 · Project Cohesion· Projects may be oversized for their cohesion · ×1
Projects may be oversized for their cohesion — 3 of 10 project(s) overshoot their size bounds, lowering Project Cohesion to 4.0/10. The most over is `pyrefly` (204196 LoC, 1105 module-visible types across 30 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.
D28 · Secrets (history)· Rotate the exposed credentials · ×1
D34 · Knowledge Freshness· Orphaned files with no living knowledge · ×1
Orphaned files with no living knowledge — 3 of 391 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; 391 of the 504 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, pyrefly/lib/error/code_climate.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.
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.
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: similar — `similar` is locked at 3.2.0 but 3.2.1 is the current stable release on crates.io, and it already satisfies the `"3.2.0"` requirement declared in pyrefly/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p similar` and commit the updated REDACTED.
Outdated: thin-vec — `thin-vec` is locked at 0.2.20 but 0.2.21 is the current stable release on crates.io, and it already satisfies the `"0.2.20"` requirement declared in pyrefly/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p thin-vec` and commit the updated REDACTED.
Outdated: tokio — `tokio` is locked at 1.53.2 but 1.54.1 is the current stable release on crates.io, and it already satisfies the `"1.53.2"` requirement declared in pyrefly/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p tokio` and commit the updated REDACTED.
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 55 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`, … (+50 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 01a17e32-b040-702d-8327-7116555acdf0 · every finding is also locatable in findings.md, and the complete scoring record (with exit codes + durations) in sidecar.json.
Issues: 121 · Warnings: 1747 · Recommendations: 88 · Info: 3 — Appendix A · all findings · full markdown report.
Generated by Watchdog — deterministic code-health analysis. 27-10-2026 @ 16:30 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.