Public report — pyrefly, published 29 Sep 2026. Concrete security findings (which rule fired, in which file, on which line; CVE IDs, secret matches, dependency versions) are REDACTED in this version; ask the repo owner for the full report.
Public
Codebase survey Measured under the Code Assurance Index · rubric rubric-2026.09.18 (frozen) · verify this survey Filed cd_de642cc237bf4220bada598c19d8a440 Filed 29 September 2026, 15:56 UTC Public

Facebook/pyrefly

Measured 29 September 2026, 15:29 UTC

70% Strong
CriticalWeakAdequateStrongExemplary

Large · 327,949 LoC · 7 projects · rebuild ~4.8 person-years · weakest lens: Maturity (66%)

Findings by grade

156 critical 1733 serious 17 minor 41 could not be resolved — could be critical — see Limitations

This survey was produced by

Watchdog
Producer
Canine Development
Analyzer
Watchdog engine 1.0.0
Measured
29 September 2026, 15:29 UTC

A measurement, not a certificate. The Code Assurance Index does not certify, approve or guarantee this codebase; it records a reproducible number and the evidence it was computed from. The standard is authored by Canine Development, who also build Watchdog — its only implementation today. That is said here so the number is checked rather than believed.

Grounded in facts. Every number here is computed, not narrated — reproducible, tool-backed, and traceable to a line of code. How to trust this ▸

51/56dimensions tool-verifieddeterministic · confidence 1.0 · 5 LLM-assisted, advisory
1881findings with an exact file:lineof 1906 — the remainder are repo-wide signals (a dimension-level measurement, not a single line); open any file:line and verify
56/133dimensions across the health lenses327949 LoC · 7 projects — wide & deep
Chapters

Executive summary

The platform holds a strong overall standing with a health score of 70%, indicating a robust system that is largely reliable but carries hidden costs in delivery speed. This is a substantial asset, comprising nearly 330,000 lines of production code and 200,000 lines of tests, representing a significant investment. Rebuilding this logic from scratch would require approximately 4.8 person-years and cost around €700,000, underscoring the value of maintaining and optimizing the existing foundation rather than replacing it.

The primary risk is a persistent velocity tax on every change. Code quality signals suggest that modifications in weaker areas cost 4–9% more effort than in clean code. This inefficiency compounds as the codebase grows, creating a silent drag on the team’s ability to deliver new features quickly. While the architecture is sound and performance is excellent, this maintainability gap means the business pays a premium in engineering time for routine updates, slowing time-to-market.

A secondary concern is the lack of documented decision-making context. With no recorded architectural decisions, new team members or returning engineers struggle to understand why specific paths were chosen. This knowledge gap increases the risk of repeating past mistakes or introducing conflicts, effectively raising the cost of onboarding and increasing the likelihood of defects. Without clear records, the system’s maturity suffers, making it fragile to personnel changes.

What is genuinely good is the system’s structural integrity and operational readiness. The architecture is highly cohesive, and performance metrics are strong, ensuring the platform is stable and secure for users. The high test coverage provides confidence in refactoring efforts. To maximize leverage, the team should immediately document key architectural decisions in a centralized, discoverable format. This low-effort action pays for itself within months by reducing future confusion and accelerating development, offering the highest return on investment for the organization.

How the score is built — each lens's share of the headline Width is the lens's weight in the worst-heaviest fold (the weakest area pulls hardest); colour is that lens's own band. A lens fixes the score in proportion to its width.
Maturity 66% · 46% weightSecurity 67% · 25% weightReadiness 74% · 14% weightCode Health 75% · 8% weightArchitecture 93% · 4% weightPerformance 94% · 2% weightEvent Sourcing 100% · 1% weight

Raise Maturity 66 → 70 (the Healthy floor) ⇒ headline 70 → ~72.

Code composition — where the lines go
Tests 100%
New since the last scan (100+)

274 finding(s) are new versus the previous scan (2026-09-13) — surfaced by this scheduled scan itself, no pull request required. Showing the first 100; the full set is in the report.

  • D1 · BindingsBuilder::stmt_impl (cyclomatic 157) pyrefly/lib/binding/stmt.rs
  • D1 · Solver::finish_quantified_with_captures (cyclomatic 37) pyrefly/lib/solver/solver.rs
  • D1 · pyrefly_types::einops::evaluate_einops_pattern (cyclomatic 30) crates/pyrefly_types/src/einops.rs
  • D1 · pyrefly_types::einops::parse_expression (cyclomatic 27) crates/pyrefly_types/src/einops.rs
  • D1 · pyrefly::lib::module::finder::find_import_with_mode (cyclomatic 24) pyrefly/lib/module/finder.rs
  • D1 · BindingExpect::fmt (cyclomatic 21) pyrefly/lib/binding/binding.rs
  • D1 · pyrefly_types::einsum::parse_einops_einsum_equation (cyclomatic 20) crates/pyrefly_types/src/einsum.rs
  • D1 · AnswersSolver::resolve_class_attr_setter (cyclomatic 19) pyrefly/lib/alt/class/class_field.rs
  • D1 · AnswersSolver::polars_output_count (cyclomatic 19) pyrefly/lib/alt/polars_specials.rs
  • D1 · AnswersSolver::project_regular_nested_list (cyclomatic 18) pyrefly/lib/alt/regular_nested_list.rs
  • D1 · Int::fmt_prec (cyclomatic 17) crates/pyrefly_types/src/dimension.rs
  • D1 · AnswersSolver::check_except_clause_reachability (cyclomatic 17) pyrefly/lib/alt/solve.rs
  • D1 · BindingsBuilder::stmts (cyclomatic 17) pyrefly/lib/binding/bindings.rs
  • D1 · DslValidator::validate_int_tuple_expression (cyclomatic 16) crates/pyrefly_types/src/type_level_dsl.rs
  • D1 · AnswersSolver::compare_types (cyclomatic 16) pyrefly/lib/alt/operators.rs
  • D1 · pyrefly::lib::lsp::non_wasm::document_symbols::recurse_stmt_adding_symbols (cyclomatic 16) pyrefly/lib/lsp/non_wasm/document_symbols.rs
  • D1 · pyrefly::lib::lsp::wasm::hover::get_hover_with_verbosity (cyclomatic 16) pyrefly/lib/lsp/wasm/hover.rs
  • D2 · BindingsBuilder::stmt_impl (cognitive 322) pyrefly/lib/binding/stmt.rs
  • D2 · Solver::finish_quantified_with_captures (cognitive 70) pyrefly/lib/solver/solver.rs
  • D2 · pyrefly_types::einops::parse_expression (cognitive 42) crates/pyrefly_types/src/einops.rs
  • D2 · pyrefly_types::einops::evaluate_einops_pattern (cognitive 41) crates/pyrefly_types/src/einops.rs
  • D2 · pyrefly_types::einsum::parse_einops_einsum_equation (cognitive 38) crates/pyrefly_types/src/einsum.rs
  • D2 · pyrefly::lib::module::finder::find_import_with_mode (cognitive 25) pyrefly/lib/module/finder.rs
  • D2 · AnswersSolver::project_regular_nested_list (cognitive 24) pyrefly/lib/alt/regular_nested_list.rs
  • D2 · AnswersSolver::resolve_class_attr_setter (cognitive 23) pyrefly/lib/alt/class/class_field.rs
  • D2 · AnswersSolver::check_except_clause_reachability (cognitive 23) pyrefly/lib/alt/solve.rs
  • D2 · BindingsBuilder::stmts (cognitive 21) pyrefly/lib/binding/bindings.rs
  • D2 · pyrefly::lib::alt::jaxtyping::parse_shape_string (cognitive 21) pyrefly/lib/alt/jaxtyping.rs
  • D2 · pyrefly::lib::alt::functools::partial_params (cognitive 21) pyrefly/lib/alt/functools.rs
  • D2 · AnswersSolver::polars_output_count (cognitive 20) pyrefly/lib/alt/polars_specials.rs
  • D2 · BaselineIndex::apply (cognitive 20) pyrefly/lib/error/baseline.rs
  • D2 · pyrefly_types::einsum::evaluate_einops_einsum (cognitive 19) crates/pyrefly_types/src/einsum.rs
  • D2 · Ignore::parse (cognitive 18) crates/pyrefly_python/src/ignore.rs
  • D2 · Solver::build_overload_rows (cognitive 18) pyrefly/lib/solver/solver.rs
  • D2 · pyrefly::lib::module::finder::combine_normal_and_stub_results (cognitive 18) pyrefly/lib/module/finder.rs
  • D2 · AnswersSolver::parse_int_tuple_shape_args (cognitive 17) pyrefly/lib/alt/expr.rs
  • D2 · code-lens.runTestAtLocation (cognitive 17) lsp/src/code-lens.ts
  • D2 · pyrefly_bundled::extract_files_from_archive (cognitive 16) crates/pyrefly_bundled/src/lib.rs
  • D2 · AnswersSolver::resolve_attr_setters (cognitive 16) pyrefly/lib/alt/attr.rs
  • D2 · AnswersSolver::check_bool_expr_and_get_value (cognitive 16) pyrefly/lib/alt/solve.rs
  • D2 · Server::setup_file_watcher_if_necessary (cognitive 16) pyrefly/lib/lsp/non_wasm/server.rs
  • D2 · Workspaces::update_workspace_config (cognitive 16) pyrefly/lib/lsp/non_wasm/workspace.rs
  • D3 · MethodTooLong: BindingsBuilder.stmt_impl pyrefly/lib/binding/stmt.rs
  • D3 · MethodTooLong: Solver.finish_quantified_with_captures pyrefly/lib/solver/solver.rs
  • D3 · MethodTooLong: AnswersSolver.compare_types pyrefly/lib/alt/operators.rs
  • D3 · FunctionTooLong: pyrefly_types::einops::parse_expression crates/pyrefly_types/src/einops.rs
  • D3 · MethodTooLong: AnswersSolver.resolve_class_attr_setter pyrefly/lib/alt/class/class_field.rs
  • D3 · FunctionTooLong: pyrefly_types::einops::evaluate_einops_pattern crates/pyrefly_types/src/einops.rs
  • D3 · FunctionTooLong: pyrefly::lib::module::finder::find_import_with_mode pyrefly/lib/module/finder.rs
  • D3 · FileTooLong: binding/shape_type.rs pyrefly/lib/binding/shape_type.rs
  • D4 · Near-duplicate member pair (26 shared lines) crates/pyrefly_types/src/type_level_dsl.rs
  • D4 · Members sharing a duplicated core (5 members, 50+ identical tokens) tensor-shapes/microtorch/run_pyrefly.py
  • D4 · Members sharing a duplicated core (4 members, 50+ identical tokens) crates/pyrefly_lsp_test/src/object_model.rs
  • D4 · Duplicated block (14 lines × 2) pyrefly/lib/lsp/wasm/completion.rs
  • D4 · Duplicated block (10–13 lines × 2) pyrefly/lib/commands/infer.rs
  • D4 · Duplicated block (12 lines × 2) crates/pyrefly_types/src/einsum.rs
  • D4 · Duplicated block (11 lines × 3) crates/pyrefly_lsp_test/src/object_model.rs
  • D4 · Duplicated block (11 lines × 2) pyrefly/lib/lsp/non_wasm/server.rs
  • D4 · Duplicated block (10 lines × 3) crates/pyrefly_types/src/type_level_dsl.rs
  • D4 · Duplicated block (10 lines × 2) pyrefly/lib/lsp/non_wasm/server.rs
  • D4 · Duplicated block (10 lines × 2) pyrefly/lib/stubgen/extract.rs
  • D4 · Duplicated block (9 lines × 2) crates/pyrefly_types/src/type_level_dsl.rs
  • D4 · Duplicated block (9 lines × 2) pyrefly/lib/alt/call.rs
  • D4 · Duplicated block (9 lines × 2) pyrefly/lib/state/semantic_tokens.rs
  • D4 · Duplicated block (9 lines × 2) pyrefly/lib/lsp/non_wasm/lsp.rs
  • D4 · Duplicated block (9 lines × 2) pyrefly/lib/state/lsp/quick_fixes/pyrefly_ignore.rs
  • D4 · Duplicated block (8 lines × 11) pyrefly/lib/lsp/non_wasm/server.rs
  • D4 · Duplicated block (8 lines × 3) crates/pyrefly_lsp_test/src/object_model.rs
  • D4 · Duplicated block (8 lines × 2) pyrefly/lib/lsp/non_wasm/server.rs
  • D4 · Duplicated block (7 lines × 2) crates/pyrefly_types/src/type_level_dsl.rs
  • D4 · Duplicated block (7 lines × 2) pyrefly/lib/lsp/non_wasm/server.rs
  • D4 · Duplicated block (7 lines × 2) pyrefly/lib/lsp/non_wasm/server.rs
  • D4 · Duplicated block (6 lines × 2) crates/pyrefly_types/src/type_level_dsl.rs
  • D4 · Duplicated block (5 lines × 2) crates/pyrefly_python/src/ignore.rs
  • D4 · Duplicated block (5 lines × 2) pyrefly/lib/alt/int_list_literal.rs
  • D4 · Duplicated block (7 lines × 2) pyrefly/lib/binding/bindings.rs
  • D4 · Duplicated block (8 lines × 2) pyrefly/lib/lsp/non_wasm/convert_module_package.rs
  • D4 · Duplicated block (9 lines × 3) pyrefly/lib/lsp/non_wasm/server.rs
  • D4 · Duplicated block (7 lines × 2) pyrefly/lib/alt/class/variance_inference.rs
  • D4 · Duplicated block (7 lines × 2) pyrefly/lib/binding/binding.rs
  • D4 · Duplicated block (6 lines × 2) crates/pyrefly_types/src/type_level_dsl.rs
  • D4 · Duplicated block (5 lines × 3) pyrefly/lib/lsp/non_wasm/server.rs
  • D4 · Duplicated block (5 lines × 2) crates/pyrefly_types/src/einops.rs
  • D4 · Duplicated block (45–46 lines × 4) tensor-shapes/pyrefly-einops-stubs/run_pyrefly.py
  • D4 · Duplicated block (27–28 lines × 2) tensor-shapes/pyrefly-jax-stubs/suites.py
  • D4 · Duplicated block (20 lines × 2) crates/tsp_types/protocol_generator/generate_protocol.py
  • D4 · Duplicated block (17 lines × 2) crates/tsp_types/protocol_generator/generate_protocol.py
  • D4 · Duplicated block (17 lines × 2) scripts/github_utils.py
  • D4 · Duplicated block (14–16 lines × 3) crates/tsp_types/protocol_generator/generate_protocol.py
  • D4 · Duplicated block (14–15 lines × 5) tensor-shapes/microtorch/run_pyrefly.py
  • D4 · Duplicated block (13–15 lines × 2) scripts/github_utils.py
  • D4 · Duplicated block (14 lines × 3) scripts/issue_ranker/v1_analysis.py
  • D4 · Duplicated block (12–14 lines × 3) scripts/primer_classifier/llm_client.py
  • D4 · Duplicated block (14 lines × 2) pyrefly/lib/report/cinderx/view_types.py
  • D4 · Duplicated block (14 lines × 2) scripts/issue_ranker/passes/primer_impact.py
  • D4 · Duplicated block (13–14 lines × 2) scripts/primer_classifier/classifier.py
  • D4 · Duplicated block (11–12 lines × 2) conformance/conformance_output.py
  • D4 · Duplicated block (12 lines × 2) crates/tsp_types/protocol_generator/generate_protocol.py
  • D4 · Duplicated block (12 lines × 2) crates/tsp_types/protocol_generator/generate_protocol.py
  • D4 · Duplicated block (11 lines × 2) scripts/github_utils.py

A full-fidelity diff against the previous run's complete recorded findings — line-move tolerant: a finding that only shifted line counts as unchanged, only genuinely new titles/files surface here.

Rebuild cost & value ~ Modeled — €230,000–€1,200,000
Cost to rebuild€230,000–€1,200,000 (2.3–7.3 person-years (3,889–12,336 h), ~2–10 engineers)
Domain complexityStandard — harder problems cost more per line
Quality factor1.0× (at 70% quality) — the last 20% of quality is most of the work
Size & shapeLarge · effort split not classified (source measured from disk; the effort-tier breakdown is a C#-only syntax walk)

This codebase represents roughly ~4.8 person-years of build effort (about ~€700,000 to rebuild). Its weakest lens is Maturity at 66% — the part of that asset most exposed by the findings below.

How we model this: boilerplate at a scaffolding rate + logic × domain Standard (×1.0) — standard service × a 1.0× quality factor, at €60–95/h; indicative, ±~30% · size measured directly from source · effort from total production LoC as straight-line logic (the tier split is a C#-only syntax walk), a conservative lower bound. Indicative only — most sensitive to the hourly rate and the domain tier (both tunable in config).

Top priorities

The highest-leverage moves; the full ranked list is in the Roadmap below.

1
Resolve the 1 No ADRs found finding(s) in ADR Quality.
+4.1 pts · Low effort · ADR Quality
2
Record significant decisions one document per decision — dated, stating the context, the decision and its consequences — and keep them together wherever your design docs already live (a conventional `docs/adr/` tree, with each file named `NNNN-title` in whatever markup those docs already use, is the most discoverable form).
+4.1 pts · Medium effort · Architecture documentation
3
Add a 'Testing' section to the root README — how to run the test suite.
+3.7 pts · Medium effort · Documentation (README)

Diagnosis — what's actually going on

The top fix pays for itself · High · Economics
The top-ranked fix costs roughly 1–3 engineer-days once. Not doing it costs about 125.7–754.5 engineer-days every year, paid as drag on the ~1,298,978 lines this team changes annually — a bill that arrives whether or not anyone books it. On those figures the fix breaks even in roughly 1–2 months and is free after that. Method, stated so this is not read as a quotation: debt from the ranked task's effort band; interest = annual changed lines (measured, annualised from the 90-day window) ÷ an ASSUMED 150–400 lines per engineer-day × the 4–9% drag implied by the code-quality signals; breaking point = debt ÷ annual interest. A modelled planning range built from measured inputs and one named assumption — not a quotation, a valuation, or a certified figure.
Evidence: D15 churn: 320,296 line(s) changed over a 90-day window ⇒ ~1,298,978/year · D1/D2/D4/D6 code quality: averaging 6.5/10 ⇒ a 4–9% drag on each change · top-ranked remediation: Low effort ⇒ about 1–3 engineer-day(s)
→ Do the top-ranked fix now if this code will still be yours in 2 months.
Highest-leverage move · Medium · Leverage
Of everything flagged, the best return on effort is: Record significant decisions one document per decision — dated, stating the context, the decision and its consequences — and keep them together wherever your design docs already live (a conventional `docs/adr/` tree, with each file named `NNNN-title` in whatever markup those docs already use, is the most discoverable form). The rest can wait behind it.
Evidence: priority ranking: top of 5 ranked by impact/effort
→ Record significant decisions one document per decision — dated, stating the context, the decision and its consequences — and keep them together wherever your design docs already live (a conventional `docs/adr/` tree, with each file named `NNNN-title` in whatever markup those docs already use, is the most discoverable form).
A velocity tax on every change · Medium · Economics
The code-quality signals (complexity, duplication, cohesion) average 6.5/10, which acts as a tax on every change in the weaker areas: modifications there plausibly cost on the order of 4–9% more than in clean code, and the tax compounds as the codebase grows. (A modelled estimate, not a measured fact.)
Evidence: D1/D2/D4/D6 code quality: averaging 6.5/10 across the code-quality signals actually measured
→ Pay it down where churn is highest — the hotspots — not everywhere; that's where the tax is actually paid.

Architecture — module dependency matrix

Rows and columns are the same modules, ordered so that a module only depends on ones above it. A cell means the row depends on the column, and its number is how many type pairs create that dependency. Read one thing: is anything above the diagonal? A mark there is a dependency cycle. (A cycle is all this shows — an unusual but cycle-free dependency sits below the diagonal like any other.)

1038 modules, 2124 dependencies. 2 dependency cycles across 174 modules, marked above the diagonal.

Showing the 40 most-connected modules; 998 more are not drawn.

Module dependency matrix. The row depends on the column; the number is how many type pairs create the dependency. A cell above the diagonal is part of a dependency cycle.
depends on →1 conformance.third_party2 pyrefly_python.sys_info3 pyrefly_types.equality4 pyrefly_util.visit5 pyrefly_glean_schema.report.glean.schema.python6 pyrefly_python.module_name7 pyrefly_python.module_path8 pyrefly_build.handle9 pyrefly_python.qname10 pyrefly_build.source_db11 pyrefly_config.config12 pyrefly_types.class13 pyrefly.lib.binding.scope14 pyrefly_config.migration.pyright15 pyrefly_types.function16 pyrefly_config.error_kind17 pyrefly_types.heap18 pyrefly_types.stdlib19 pyrefly_types.quantified20 pyrefly_types.callable21 pyrefly_types.types22 pyrefly.lib.state.lsp23 pyrefly.lib.error.error24 pyrefly.lib.error.collector25 pyrefly.lib.alt.types.class_metadata26 pyrefly.lib.solver.solver27 pyrefly.lib.binding.bindings28 pyrefly.lib.binding.binding29 pyrefly.lib.alt.answers_solver30 pyrefly.lib.state.state31 pyrefly.lib.lsp.non_wasm.server32 pyrefly.lib.report.pysa.context33 pyrefly.lib.test.util34 pyrefly.lib.report.pysa.class35 pyrefly.lib.report.pysa.call_graph36 pyrefly.lib.report.pysa.function37 pyrefly.lib.report.pysa.pysa_report_capnp.source_path38 pyrefly.lib.report.pysa39 pyrefly.lib.alt.answers40 pyrefly.lib.query
1 conformance.third_party
2 pyrefly_python.sys_info
3 pyrefly_types.equality
4 pyrefly_util.visit
5 pyrefly_glean_schema.report.glean.schema.python12
6 pyrefly_python.module_name121
7 pyrefly_python.module_path241
8 pyrefly_build.handle121
9 pyrefly_python.qname2211
10 pyrefly_build.source_db1132
11 pyrefly_config.config311111
12 pyrefly_types.class1251143
13 pyrefly.lib.binding.scope21042410
14 pyrefly_config.migration.pyright113
15 pyrefly_types.function24611141
16 pyrefly_config.error_kind2
17 pyrefly_types.heap221148
18 pyrefly_types.stdlib11121
19 pyrefly_types.quantified2631212
20 pyrefly_types.callable22511
21 pyrefly_types.types261411162122
22 pyrefly.lib.state.lsp111141
23 pyrefly.lib.error.error1151
24 pyrefly.lib.error.collector24
25 pyrefly.lib.alt.types.class_metadata3591222
26 pyrefly.lib.solver.solver14111531121
27 pyrefly.lib.binding.bindings64151821121219
28 pyrefly.lib.binding.binding11711432612252515425
29 pyrefly.lib.alt.answers_solver1411471112612514824719
30 pyrefly.lib.state.state252364211111614738
31 pyrefly.lib.lsp.non_wasm.server3323511416
32 pyrefly.lib.report.pysa.context32121211
33 pyrefly.lib.test.util31111
34 pyrefly.lib.report.pysa.class25124
35 pyrefly.lib.report.pysa.call_graph7122141111523
36 pyrefly.lib.report.pysa.function5122311511
37 pyrefly.lib.report.pysa.pysa_report_capnp.source_path113
38 pyrefly.lib.report.pysa256212212
39 pyrefly.lib.alt.answers2121222111111217111
40 pyrefly.lib.query14113223142
Dependency, pointing down the layeringAbove the diagonal — part of a cycleThe module itself
…nformance.third_party…refly_python.sys_infopyrefly_types.equalitypyrefly_util.visit…t.glean.schema.python…ly_python.module_name…ly_python.module_pathpyrefly_build.handlepyrefly_python.qname…refly_build.source_dbpyrefly_config.configpyrefly_types.class…fly.lib.binding.scope…fig.migration.pyrightpyrefly_types.function…fly_config.error_kindpyrefly_types.heappyrefly_types.stdlib…efly_types.quantifiedpyrefly_types.callablepyrefly_types.typespyrefly.lib.state.lsp…refly.lib.error.error…y.lib.error.collector….types.class_metadata…fly.lib.solver.solver….lib.binding.bindings…y.lib.binding.binding…ib.alt.answers_solver…refly.lib.state.state…b.lsp.non_wasm.server…b.report.pysa.contextpyrefly.lib.test.util…lib.report.pysa.class…eport.pysa.call_graph….report.pysa.function…ort_capnp.source_path…refly.lib.report.pysa…refly.lib.alt.answerspyrefly.lib.query…nformance.third_party1…refly_python.sys_info2pyrefly_types.equality3pyrefly_util.visit4…t.glean.schema.python5…ly_python.module_name6…ly_python.module_path7pyrefly_build.handle8pyrefly_python.qname9…refly_build.source_db10pyrefly_config.config11pyrefly_types.class12…fly.lib.binding.scope13…fig.migration.pyright14pyrefly_types.function15…fly_config.error_kind16pyrefly_types.heap17pyrefly_types.stdlib18…efly_types.quantified19pyrefly_types.callable20pyrefly_types.types21pyrefly.lib.state.lsp22…refly.lib.error.error23…y.lib.error.collector24….types.class_metadata25…fly.lib.solver.solver26….lib.binding.bindings27…y.lib.binding.binding28…ib.alt.answers_solver29…refly.lib.state.state30…b.lsp.non_wasm.server31…b.report.pysa.context32pyrefly.lib.test.util33…lib.report.pysa.class34…eport.pysa.call_graph35….report.pysa.function36…ort_capnp.source_path37…refly.lib.report.pysa38…refly.lib.alt.answers39pyrefly.lib.query4012121241121221111323111111251143210424101132461114122211481112126312122251126141116212211114111512435912221411153112164151821121219117114326122525154251411471112612514824719252364211111614738332351141632121211311112512471221411115235122311511113256212212212122211111121711114113223142+998 more modules (most-connected shown)

At a glance — Code Health · 75% · Adequate · gated by D2 ·

At a glance — Architecture · 93% · Adequate · gated by D26 ·

At a glance — Maturity · 66% · Adequate · gated by M2 ·

At a glance — Readiness · 74% · Strong ·

At a glance — Security · 67% · Adequate · gated by D29 ·

At a glance — Event Sourcing · 100% · Exemplary ·

At a glance — Performance · 94% · Exemplary ·

Security & Compliance — OWASP Top-10 mapping

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

OWASP categoryFindingsSeverity
A03:2021 — Injection151High / Critical
A06:2021 — Vulnerable & Outdated Components11High / Critical
A02:2021 — Cryptographic Failures2High / Critical

Roadmap

Begin by establishing a formal architecture decision record process to document significant design choices and resolve the current gap in ADR quality. Simultaneously, address the 87 high-churn complexity hotspots, prioritizing function.rs, type_level_dsl.rs, and expr.rs to stabilize the codebase. Finally, enhance project onboarding by adding a testing section to the root README, while maintaining the high quality of existing documentation.

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

Do thisHelpsEffortDimension
Resolve the 1 No ADRs found finding(s) in ADR Quality.+4.1 ptsLowADR Quality
Record significant decisions one document per decision — dated, stating the context, the decision and its consequences — and keep them together wherever your design docs already live (a conventional `docs/adr/` tree, with each file named `NNNN-title` in whatever markup those docs already use, is the most discoverable form).+4.1 ptsMediumArchitecture documentation
Add a 'Testing' section to the root README — how to run the test suite.+3.7 ptsMediumDocumentation (README)
Resolve the 9 REDACTED finding(s) in Static Analysis (SAST) — start with REDACTED (2), REDACTED, REDACTED.+1.5 ptsLowStatic Analysis (SAST)
Resolve the 8 REDACTED finding(s) in Static Analysis (SAST) — start with REDACTED (5), REDACTED (3).+1.3 ptsLowStatic Analysis (SAST)
Resolve the 4 Off-boarding risk finding(s) in Bus Factor.+1.2 ptsLowBus Factor
Resolve the 87 Hotspot finding(s) in Churn × Complexity Hotspots — start with function.rs (3), type_level_dsl.rs (2), expr.rs (2).+2.2 ptsHighChurn × Complexity Hotspots
Improve Documentation Quality — currently 8.0/10.+2.1 ptsMediumDocumentation Quality

File quality

Per-file score 0–10 — a quality signature. Of 326 files carrying findings, judged against the Production bar: 0% slop · 70% mixed · 30% near-clean.

FileScoreBandWorst signal
REDACTED0.9SlopDependency Vulnerabilities: High CVE: REDACTED
REDACTED4.4MixedStatic Analysis (SAST): High: REDACTED
REDACTED4.4MixedStatic Analysis (SAST): High: REDACTED
REDACTED4.4MixedStatic Analysis (SAST): High: REDACTED
REDACTED4.4MixedStatic Analysis (SAST): High: REDACTED
REDACTED4.4MixedStatic Analysis (SAST): High: REDACTED
REDACTED4.4MixedStatic Analysis (SAST): High: REDACTED
REDACTED4.4MixedStatic Analysis (SAST): High: REDACTED
REDACTED4.5MixedStatic Analysis (SAST): High: REDACTED
REDACTED4.5MixedStatic Analysis (SAST): High: REDACTED
REDACTED4.5MixedStatic Analysis (SAST): High: REDACTED
REDACTED4.6MixedStatic Analysis (SAST): High: REDACTED
REDACTED4.8MixedStatic Analysis (SAST): High: REDACTED
REDACTED4.8MixedStatic Analysis (SAST): High: REDACTED
REDACTED4.8MixedStatic Analysis (SAST): High: REDACTED
REDACTED5.1MixedStatic Analysis (SAST): High: REDACTED
pyrefly/lib/query/type_table.rs5.7MixedGod Classes: FunctionTooLong: pyrefly::lib::query::type_table::type_to_indexed_shape
REDACTED5.8MixedStatic Analysis (SAST): High: REDACTED
REDACTED5.8MixedStatic Analysis (SAST): High: REDACTED
REDACTED5.8MixedStatic 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 — 156

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

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

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

Could not be resolved — 41

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. 51 of 56 evaluated dimensions are computed purely by tools and static analysis (confidence 1.0); 5 documentation/naming judgement(s) are LLM-assisted and labelled advisory. 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 — 56 dimensions across the health lenses
D1D2D3D4D5D6D9D10D12D13D14D15D16D17D19D20D21D22D26D28D29D30D34D35D36D43D44AX10AX3AX4AX8AX9ES1ES2M1M2M3M4P1P10P2P3P4P6PF1PF3R1R10R2R3R4R5R6R7R8R9

Each chip is a dimension scored from real signals across architecture, testing, dependencies, security & compliance, documentation, git-history and code quality — in one coherent pass. A surface report typically covers a handful.

How to trust any code-health report — three questions
  1. Can you open the finding? Real findings cite a repo-relative file and line you can open at the cited line — never an absolute scratch path. Here, 1881 of 1906 do; the remainder are repo-wide signals — a dimension-level measurement, not a single line. (Every path in this report is repo-relative by construction: paths are normalized at the producer and the report is rejected if any rooted path leaks through.)
  2. Is there a tool behind the number? Every score below names the method that produced it — Roslyn, git, a scanner, or (for a handful of documentation/naming dimensions) an LLM labelled sampled · advisory — not a narrative.
  3. Does re-running give the same result? Run it again on the same commit and the score — and this report, byte for byte — is identical. A report whose numbers move between runs is describing the run, not the code.

This report answers yes to all three. That's the bar to hold any assessment to.

Tools & methods

The actual versions used this run (captured at analysis time) — re-run on the same commit for the identical score.

MethodBacksVersionEvaluator
Roslyn static analysisComplexity, cohesion, coupling, dead code, API surface, layering5.3.0✓ deterministic
Native secret scannerHardcoded secrets / credentials1.0.0✓ deterministic
Watchdog duplication detector (in-process)Code duplication1.0.0✓ deterministic
Coverage (coverlet / dotnet-coverage)Line & branch coverage10.0.400✓ deterministic
NuGet / dotnetOutdated, vulnerable & deprecated dependencies10.0.400✓ deterministic
git / LibGit2SharpChurn hotspots, knowledge concentration, history2.43.0 · 0.31.0✓ deterministic
gitleaks · semgrep · trivySecrets in history, SAST, CVEs, IaC & container, PII / GDPR1.86.0 · 0.69.3✓ deterministic
LLM (sampled · advisory)Documentation quality, ADR conformance, naming — sampled over a bounded sample; advisory, never a deterministic measurementLocal LLM◐ LLM · sampled · advisory

Every finding is locatable in findings.md. Run 01a0edc8-9e4c-787e-bd6c-cff8050637b3.

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

Run transparency — what happened this run

What ran differently this time — a tool absent, degraded, or that fell back to an estimate. Named openly, not folded silently into the scores. A degraded run also records its exact cause in diagnostics.md.

  • D8 Code Coverage — not measured this run — 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/ failed in the analyzer sandbox (error Error: https://registry.facebook.net/@types/react/-/react-19.2.14.tgz: tunneling socket could not be established, statusCode=403), 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 90 test(s) behind this row are the ones the JavaScript/TypeScript census could read, and this repository also carries at least 792 test source file(s) (.rs, .py) 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/ failed in the analyzer sandbox (error Error: https://registry.facebook.net/@types/react/-/react-19.2.14.tgz: tunneling socket could not be established, statusCode=403), 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/ failed in the analyzer sandbox (error Error: https://registry.facebook.net/@types/react/-/react-19.2.14.tgz: tunneling socket could not be established, statusCode=403), 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.
  • 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`, … (+43 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.
  • AX1 Captive dependencies — 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 Microsoft.Extensions.DependencyInjection registrations in C# and Spring beans in Java/Kotlin only, and no container it models, or knows cannot hold a captive, was found in this repository's source, 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.
  • AX2 Stateful singletons — 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 Microsoft.Extensions.DependencyInjection singletons in C# and Spring/JSR-330/CDI singletons in Java and Kotlin only, and this repository's product is written in Python, which was left unread, so it had nothing of this repository's product to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
  • AX6 Interface segregation — not measured this run — 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 is computed over the public interfaces this run's compilations declare, and none was loaded, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
  • C1 Data Protection — not measured this run — 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. These personal data controls are read from declarative annotations, request middleware, entity/column names and guard methods in a C# source model, and none was loaded on this run, so there was nothing to gather. That is a gap in this analyzer's language reach — not a finding that the repository lacks personal data controls.
  • C2 Access Controls — not measured this run — 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. These authorization controls are read from declarative annotations, request middleware, entity/column names and guard methods in a C# source model, and none was loaded on this run, so there was nothing to gather. That is a gap in this analyzer's language reach — not a finding that the repository lacks authorization controls.
  • C3 Audit Trail — not measured this run — 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. These audit controls are read from declarative annotations, request middleware, entity/column names and guard methods in a C# source model, and none was loaded on this run, so there was nothing to gather. That is a gap in this analyzer's language reach — not a finding that the repository lacks audit controls.
  • C4 Data Retention — 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. These retention controls are read from declarative annotations, request middleware, entity/column names and guard methods in a C# source model, and none was loaded on this run, so there was nothing to gather. That is a gap in this analyzer's language reach — not a finding that the repository lacks retention controls.
  • C5 Data-Subject Rights — 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. These data-subject rights controls are read from declarative annotations, request middleware, entity/column names and guard methods in a C# source model, and none was loaded on this run, so there was nothing to gather. That is a gap in this analyzer's language reach — not a finding that the repository lacks data-subject rights controls.
  • ED5 Idempotency — 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 finds retry-prone mutations by walking the repository's declared types, and NONE was loaded on this run, so it had nothing to look at. That is a limit of the analyzer's reach — it reads .NET projects — not a finding that this repository has no command handlers or message consumers.
  • 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 is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
  • 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 is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
  • P5 DR & Backup — not measured this run — This is a true statement about the repository that carries nothing for its owner to act on, so it is reported here rather than as a defect in their code. No backup/snapshot/replication config, RTO/RPO or restore-procedure documentation was found — and no production persistence was detected either (no data-access packages, no data-store services, no database resources), so there is nothing in this repository whose loss a DR control would recover. If this system's data lives in a platform or ops repo we can't see, that's where the DR evidence belongs.
  • S1 Web-Security Posture — not measured this run — 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. These web-security controls are read from declarative annotations, request middleware, entity/column names and guard methods in a C# source model, and none was loaded on this run, so there was nothing to gather. That is a gap in this analyzer's language reach — not a finding that the repository lacks web-security controls.
  • X1 Async correctness — not measured this run — 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 is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
  • X12 Unreachable branch — not measured this run — 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 is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
  • X13 Undrained process stream — not measured this run — 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 is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
  • X14 Bypassable address classification — not measured this run — 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 is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
  • X15 Unvalidated length from an untrusted reader — not measured this run — 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 is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
  • X16 Unfloored truncation loop — not measured this run — 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 is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
  • X17 Uncapped recursion over a caller-supplied document — not measured this run — 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 is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
  • X18 Disposal-pattern correctness — not measured this run — 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 is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
  • X19 Unrestored process-global state — not measured this run — 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 is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
  • X2 Cancellation propagation — not measured this run — 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 is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
  • X20 Mistyped argument guard — 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 is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
  • X21 Side-effecting pattern guard — not measured this run — 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 is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
  • X22 Contradicted release guard — not measured this run — 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 is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
  • X23 Unguarded diagnostic materialisation — 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 is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
  • X24 Document value interpolated into markup unescaped — not measured this run — 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 is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
  • X25 Inert configuration knob — not measured this run — 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 is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
  • X26 Unsynchronised callback handoff — not measured this run — 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 is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
  • X27 Collection changed while being enumerated — 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 is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
  • X28 Index access outside its own emptiness guard — 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 is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
  • X29 Per-element action decided by a fixed element — not measured this run — 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 is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
  • X3 Exception handling — not measured this run — 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 is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
  • X30 Support guard that admits what it rejects — not measured this run — 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 is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
  • X32 Type resolved by simple name across every loaded assembly — not measured this run — 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 is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
  • X4 Structured logging — not measured this run — 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 is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
  • X5 Nullable reference types — not measured this run — 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 is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
  • X7 Silent fallback defaults — 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. X7 measured this repository's Python, and its Rust, TypeScript/JavaScript source is outside the check's reach, so the card covers only part of the product. That is a gap in this analyzer's language reach — not a finding that the unread source is free of silent defaults.

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 is judged by an LLM over a bounded sample of docs — it reads what is written, not whether the docs match the running system, and it is advisory, not a measurement. Its critique rows are drawn from a closed category vocabulary and each row means the same thing in every run, so two scans can be compared row by row; the SET that fires is still a sample, and does not repeat exactly. Measured on one frozen input, six scans at one engine SHA: 2-5 critique rows per scan, 8 distinct rows across the six, 3 of those 8 seen in only one scan. So a D19 row is evidence about the documentation, but a COUNT of D19 rows is not a quantity — never read a change in it as an improvement or a regression.
  • 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.
  • D21 Naming Consistency: Naming quality is an LLM judgement over a bounded sample — it assesses clarity/consistency of the names it sees, not domain-correctness, and is advisory.
  • D22 Internal API Consistency: API-surface coherence is an LLM judgement over a sample of the public surface — consistency of intent across the whole API is approximated, not exhaustively verified.
  • 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.

The LLM boundary

LLM-set scores this run (5): D19, D21, D22, D26, M4 (model: Local LLM). For these, a model reads a bounded sample and sets the numeric score; each names its own sample and method on its card. They are sampled and advisory by design: they vary at the margins between runs and are never a deterministic measurement. Every other score in this report is tool-computed at confidence 1.0.

Dimensions

D1 · Cyclomatic Complexity4.4 / 10Weak✓ Tool-verified

What it measures: How tangled the control flow is — methods with many branches are hard to test and change.

Method: Cyclomatic complexity per method (1 + decision points), computed exhaustively across production source; test projects separated by convention. Deterministic.

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

263 method(s) exceeded the cyclomatic complexity threshold of 15; the worst was StructurallyValidatedTypeShapeDslFunction::evaluate_expression at 247. 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 78 — they are counted neither in the figure above nor in this dimension's score. 11 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 78), crates/pyrefly_config/src/error_kind.rs (ErrorKind::default_severity at 68), crates/pyrefly_types/src/types.rs (Type::recurse at 53), pyrefly/lib/query/type_table.rs (pyrefly::lib::query::type_table::type_to_indexed_shape at 51), crates/pyrefly_types/src/function.rs (FunctionKind::module_name at 36), and 6 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.

AnswersSolver::callable_infer_params (cyclomatic 136) · ×90pyrefly/lib/alt/callable.rs:894
pyrefly_types::meta_shape_dsl::eval_dsl_expr (cyclomatic 54) · ×23crates/pyrefly_types/src/meta_shape_dsl.rs:2373
pyrefly::lib::report::cinderx::convert::type_to_structured (cyclomatic 47) · ×22pyrefly/lib/report/cinderx/convert.rs:177
BindingsBuilder::stmt_impl (cyclomatic 157) · ×17pyrefly/lib/binding/stmt.rs:847
Transaction::inlay_hints (cyclomatic 49) · ×11pyrefly/lib/lsp/wasm/inlay_hints.rs:234

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

What to do

  1. Resolve the 90 AnswersSolver finding(s) in Cyclomatic Complexity — start with solve.rs (12), polars_specials.rs (11), class_field.rs (9). — One of this dimension's main actionable groups (90 warning-level).
  2. Resolve the 23 pyrefly_types finding(s) in Cyclomatic Complexity — start with meta_shape_dsl.rs (9), dimension.rs (3), shape_index.rs (2). — One of this dimension's main actionable groups (23 warning-level).
  3. Resolve the 22 pyrefly finding(s) in Cyclomatic Complexity — start with collect.rs (5), suppress.rs (2), convert.rs. — One of this dimension's main actionable groups (22 warning-level).
  4. 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.

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

What it measures: How hard the code is for a person to follow, beyond raw branching.

Method: Cognitive complexity per method (Sonar-style nesting-penalized score), computed exhaustively over production code, excluding test projects. Deterministic.

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

438 method(s) exceeded the cognitive complexity threshold of 15; the worst was AnswersSolver::callable_infer_params at 340.

AnswersSolver::callable_infer_params (cognitive 340) · ×138pyrefly/lib/alt/callable.rs:894
pyrefly::lib::error::suppress::remove_unused_ignores_from_serialized (cognitive 91) · ×51pyrefly/lib/error/suppress.rs:636
BindingsBuilder::stmt_impl (cognitive 322) · ×28pyrefly/lib/binding/stmt.rs:847
Transaction::completion_sorted_opt_with_incomplete (cognitive 95) · ×27pyrefly/lib/lsp/wasm/completion.rs:1068
pyrefly_types::meta_shape_dsl::eval_dsl_expr (cognitive 76) · ×24crates/pyrefly_types/src/meta_shape_dsl.rs:2373

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

What to do

  1. Resolve the 138 AnswersSolver finding(s) in Cognitive Complexity — start with solve.rs (21), expr.rs (14), class_field.rs (11). — One of this dimension's main actionable groups (138 warning-level).
  2. Resolve the 51 pyrefly finding(s) in Cognitive Complexity — start with collect.rs (8), finder.rs (4), move_module.rs (3). — One of this dimension's main actionable groups (51 warning-level).
  3. Resolve the 28 BindingsBuilder finding(s) in Cognitive Complexity — start with stmt.rs (5), class.rs (5), expr.rs (4). — One of this dimension's main actionable groups (28 warning-level).
  4. 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.

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

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

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

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

265 god class(es) detected.

MethodTooLong: BindingsBuilder.stmt_impl · ×115pyrefly/lib/binding/stmt.rs:847
FileTooLong: src/type_level_dsl.rs · ×80crates/pyrefly_types/src/type_level_dsl.rs
TooManyMethods: AnswersSolver · ×22pyrefly/lib/alt/answers_solver.rs:2070
FunctionTooLong: pyrefly::lib::report::cinderx::convert::type_to_structured · ×22pyrefly/lib/report/cinderx/convert.rs:177
ClassTooLong: Server · ×19pyrefly/lib/lsp/non_wasm/server.rs:1112

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

What to do

  1. Resolve the 115 MethodTooLong finding(s) in God Classes — start with type_level_dsl.rs (11), expr.rs (10), solve.rs (7). — One of this dimension's main actionable groups (115 warning-level).
  2. Resolve the 80 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 (80 warning-level).
  3. Resolve the 22 TooManyMethods finding(s) in God Classes — start with answers_solver.rs (2), bindings.rs (2), solver.rs (2). — One of this dimension's main actionable groups (22 warning-level).
  4. 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.

D4 · Code Duplication9.5 / 10Stronggated by 352 serious findings✓ Tool-verified

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.

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

332 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 352 are in trees this repository does not ship — vendored, example/demo, 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.

Duplicated block (5 lines × 2) · ×33crates/pyrefly_python/src/ignore.rs:658
Duplicated block (7 lines × 2) · ×28crates/pyrefly_config/src/migration/run.rs:394
Duplicated block (8 lines × 2) · ×24crates/pyrefly_types/src/callable.rs:680
Duplicated block (6 lines × 2) · ×23crates/pyrefly_types/src/meta_shape_dsl.rs:905
Duplicated block (9 lines × 2) · ×19crates/pyrefly_types/src/type_level_dsl.rs:3599

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

What to do

  1. Resolve the 33 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 (33 warning-level).
  2. 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).
  3. Resolve the 24 Duplicated block (8 lines × 2) finding(s) in Code Duplication — start with narrow.rs (3), server.rs (3), dimension.rs (2). — One of this dimension's main actionable groups (24 warning-level).
  4. 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.

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.

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

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.

✓ On the Gold path — maintain.

Detailed fixes: d5_recommendation.md.

D6 · Cohesion (LCOM4)9.9 / 10Stronggated by 2 serious findings✓ Tool-verified

What it measures: Whether a class's methods are focused on a single responsibility.

Method: LCOM4 cohesion per production class with at least two methods: connected components of methods sharing state or calls, computed syntactically. Deterministic, not a proxy.

Coverage: Exhaustive · type-level: LCOM4 cohesion computed over every production class — the population is all types, not a name convention.

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

2 of 292 classes have LCOM4 above 3.

Low cohesion: NestingContext (LCOM4 5) · ×2crates/pyrefly_python/src/nesting_context.rs:24

What to do

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

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.

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

4852 test methods: 4815 unit, 37 integration, 0 BDD, 0 e2e. The JavaScript/TypeScript suite contributes 90 `it`/`test` case(s) across 14 test file(s) declaring at least one; its tier split is read from package names and paths only. The Rust suite contributes 3430 `#[test]` function(s) across 282 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 1332 test function(s) across 146 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.

D10 · Test Quality10.0 / 10Exemplary✓ Tool-verified

What it measures: Whether the tests truly assert behaviour rather than just running the code.

Method: Per-test assertions, skips, and mock references analyzed via Roslyn; structured skip-reason tags (BUG:/ENV:) separate documented deferrals from debt. Deterministic.

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

0 skipped, 0 zero-assertion, no mocking-framework packages referenced (hand-written doubles or no mocking) across 90 tests. Measured on the JavaScript/TypeScript suite only — at least 792 test source file(s) (.rs, .py) went unread, so its test quality is unmeasured and is not in these counts.

✓ On the Gold path — maintain.

Detailed fixes: d10_recommendation.md.

D12 · Dependency Hygiene9.9 9.5 / 10Exemplary✓ Tool-verified

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.

Maturity: Documented → Verified → Prevented · effective 9.5 / 10 · rule-coverage 96% · ceiling Verified

1 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: xxhash-rust

✓ On the Gold path — maintain.

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

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

What it measures: Whether any secrets (keys, tokens, passwords) have leaked into the code.

Method: In-process native secret scanner (entropy plus signature patterns) across all tracked files; no external tool. A clean result is a measured 10, not no-data zero. Deterministic.

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

REDACTED scan ran and found no leaked secrets.

✓ On the Gold path — maintain.

Detailed fixes: d13_recommendation.md.

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

What it measures: Whether the licenses of third-party packages are compatible with your policy.

Method: Third-party package licenses resolved from declared package metadata and checked against the configured policy (allow/deny/copyleft). Deterministic; clean = no incompatible license found at metadata depth.

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

0 of 441 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.

✓ On the Gold path — maintain.

Detailed fixes: d14_recommendation.md.

D15 · Churn × Complexity Hotspots7.8 / 10Strong✓ Tool-verified

What it measures: Files that change often and are also complex — the riskiest hotspots.

Method: Per production file churn times cyclomatic complexity over a rolling window, computed from git and Roslyn/JS/Razor analysis. Exhaustive, deterministic per commit date.

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

Top hotspots: pyrefly/lib/solver/subset.rs (85×240=20400); crates/pyrefly_types/src/type_level_dsl.rs (82×247=20254); pyrefly/lib/alt/expr.rs (150×84=12600) Repeated repair below the complexity floor: crates/pyrefly_python/src/module_name.rs (4 of 6 changes were fixes)

Hotspot: pyrefly/lib/solver/subset.rs · ×87pyrefly/lib/solver/subset.rs:1877
Repeated repair: crates/pyrefly_python/src/module_name.rscrates/pyrefly_python/src/module_name.rs:488

What to do

  1. Resolve the 87 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 (87 warning-level).
  2. Resolve the 1 Repeated repair finding(s) in Churn × Complexity Hotspots — start with module_name.rs. — One of this dimension's main actionable groups (1 warning-level).

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

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.

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

49 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 407 of the 520 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 · ×4
Further sole-owners (lower concentration)

What to do

  1. Resolve the 4 Off-boarding risk finding(s) in Bus Factor. — One of this dimension's main actionable groups (4 recommendation-level).
  2. 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.

D17 · Explicit Debt9.8 / 10Stronggated by 291 serious findings✓ Tool-verified

What it measures: Acknowledged debt left in the code — TODOs, dead code, suppressed warnings.

Method: Roslyn syntactic debt markers (suppressions/TODO/FIXME/HACK/empty-catch/commented-code/Obsolete) plus SymbolFinder dead-code analysis; weighted-debt-per-KLoC density deducted 2.0x per unit. Deterministic, exhaustive.

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

291 deducted task-comment markers across 327949 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.

TodoComment · ×284crates/pyrefly_build/src/lib.rs:114
HackComment · ×4pyrefly/lib/alt/callable.rs:126
FixmeComment · ×2pyrefly/lib/alt/function.rs:2794
XxxCommentpyrefly/lib/state/lsp.rs:1163

What to do

  1. Resolve the 284 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 (284 warning-level).
  2. 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).
  3. Resolve the 2 FixmeComment finding(s) in Explicit Debt — start with function.rs, attr.rs. — One of this dimension's main actionable groups (2 warning-level).
  4. 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.

D19 · Documentation QualityStrong◐ Sampled · advisory

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

Method: Judged by language model at low temperature (0.0-0.1) on a deterministic doc sample (READMEs plus first 25 architecture docs), with two-pass stability filtering. Advisory, sampled.

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

The repository's root README is excellent: it states what the project does (a fast type checker and language server for Python with powerful IDE features), shows a multi-asset badge wall, links to the Pyrefly website, conveys production scale (Instagram at Meta, adopted by PyTorch/JAX), lists key features, and ends with an outline. The conformance/README documents its own directory (the typing test suite) without claiming anything about the repository's root; similarly lsp/README is a VS Code extension README for its own directory. All visible documents are well-structured per their scope. (15 of 25 sampled documents could not be assessed: 1 of 2 evaluation groups failed.)

What to do

  1. Improve Documentation Quality — currently 8.0/10. — The repository's root README is excellent: it states what the project does (a fast type checker and language server for Python with powerful IDE features), shows a multi-asset badge wall, links to the Pyrefly website, conveys production scale (Instagram at Meta, adopted by PyTorch/JAX), lists key features, and ends with an outline. The conformance/README documents its own directory (the typing test suite) without claiming anything about the repository's root; similarly lsp/README is a VS Code extension README for its own directory. All visible documents are well-structured per their scope. (15 of 25 sampled documents could not be assessed: 1 of 2 evaluation groups failed.)

Detailed fixes: d19_recommendation.md.

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.

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

No architecture decision records were found.

No ADRs found

What to do

  1. Resolve the 1 No ADRs found finding(s) in ADR Quality. — One of this dimension's main actionable groups (1 recommendation-level).

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

D21 · Naming ConsistencyExemplary◐ Sampled · advisory

What it measures: Whether names — types, methods, variables — are clear and consistent.

Method: Judged by language model at low temperature (0.0-0.1) on a deterministic random symbol sample (fixed size, not exhaustive), with disclosed confidence band. Advisory, sampled.

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

0 naming inconsistencies across 0 sampled symbols.

✓ On the Gold path — maintain.

Detailed fixes: d21_recommendation.md.

D22 · Internal API ConsistencyAdequate◐ Sampled · advisory

What it measures: Whether the internal API surface is consistent and coherent.

Method: Judged by language model at low temperature over a sample of the public API surface (IsPackable or .Contracts types). Sampled, advisory; confidence discounted by model uncertainty.

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

3 API inconsistencies across a 400-member sample of 641 exposed types.

Redundant methods with unclear distinction. `override_config` and `override_config_at` have nearly identical signatures and return types. It is unclear why one requires a `project_root` and the other does not, or if they represent different scoping contexts that should be unified via a single method with an optional or explicit scope parameter.
Duplicate method signatures. Two methods named `get_env_from_interpreter` exist with identical parameter types. The underscore in the second parameter name (`_interpreter`) suggests one might be a placeholder or deprecated, but both are exposed in the public API surface.
Ambiguous overlap in intent. `includes` returns `Globs` for a scope, while `get_filtered_globs` returns `FilteredGlobs` and takes `custom_excludes`. It is unclear if `includes` is a simplified version of `get_filtered_globs` with no custom excludes, or if they serve distinct filtering logic. The naming convention (`includes` vs `get_filtered_globs`) is inconsistent.

What to do

  1. Resolve the 1 Redundant methods with unclear distinction. `override_config` and… finding(s) in Internal API Consistency. — One of this dimension's main actionable groups (1 warning-level).
  2. Resolve the 1 Duplicate method signatures. Two methods named… finding(s) in Internal API Consistency. — One of this dimension's main actionable groups (1 warning-level).
  3. Resolve the 1 Ambiguous overlap in intent. `includes` returns `Globs` for a scope,… finding(s) in Internal API Consistency. — One of this dimension's main actionable groups (1 warning-level).

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

D26 · Project Cohesion0.0 / 10Critical✓ Tool-verified

What it measures: Whether each project is a focused, coherent unit rather than an oversized grab-bag.

Method: Project size overshoot penalties (LoC / public-type count / namespace count, 2-of-3 flag) weighted by log magnitude. Exhaustive across projects, deterministic, LLM-independent.

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

2 of 3 build units (Cargo, Python) flagged as possibly oversized/incoherent.

Split pyrefly

What to do

  1. Resolve the 1 Split pyrefly 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.

D28 · Secrets (history)9.0 / 10Adequategated by 1 critical finding✓ Tool-verified

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.

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

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

  1. Resolve the 1 REDACTED finding(s) in Secrets (history) — start with REDACTED. — One of this dimension's main actionable groups (1 issue-level).
  2. 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.

D29 · Static Analysis (SAST)0.2 / 10Critical✓ Tool-verified

What it measures: Real static-analysis (SAST) findings — likely security bugs in the code, any language.

Method: Polyglot static analysis via semgrep across the repo using the pinned, image-baked p/security-audit + p/owasp-top-ten rulesets (no scan-time registry fetch); severity rules (ERROR/WARNING/INFO) map to a full-band severity-weighted score. Exhaustive, deterministic; degrades on parse failure.

Coverage: semgrep pattern rules over all files — exhaustive for the rule set, blind to classes of bug without a rule (clean = no rule matched).

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

151 finding(s): 0 critical, 149 high, 1 medium, 1 low. 126 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 89 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), … (+84 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 9 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

  1. Resolve the 9 REDACTED finding(s) in Static Analysis (SAST) — start with REDACTED (2), REDACTED, REDACTED. — One of this dimension's main actionable groups (9 issue-level).
  2. Resolve the 8 REDACTED finding(s) in Static Analysis (SAST) — start with REDACTED (5), REDACTED (3). — One of this dimension's main actionable groups (8 issue-level).
  3. Resolve the 1 REDACTED finding(s) charged to Static Analysis (SAST) — the other 126 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 (127 issue-level, 1 of them charged here).

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

D30 · Dependency Vulnerabilities6.3 / 10Adequate✓ Tool-verified

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.

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

11 finding(s): 0 critical, 4 high, 6 medium, 1 low.

REDACTED
REDACTED
REDACTED
REDACTED
REDACTED

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

What to do

  1. Resolve the 3 High CVE finding(s) in Dependency Vulnerabilities — start with REDACTED (3). — One of this dimension's main actionable groups (3 issue-level).
  2. Resolve the 1 High vulnerability finding(s) in Dependency Vulnerabilities — start with REDACTED. — One of this dimension's main actionable groups (1 issue-level).
  3. Resolve the 3 Medium advisory (unmaintained) finding(s) in Dependency Vulnerabilities — start with REDACTED (3). — One of this dimension's main actionable groups (3 warning-level).

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

D34 · Knowledge Freshness9.6 / 10Exemplary✓ Tool-verified

What it measures: Whether anyone still has living knowledge of each file, or it has been orphaned — last understood long ago by someone now gone quiet. The sibling of the bus factor: D16 asks who owns it, D34 asks whether anyone still knows it.

Method: File orphaning as total living-knowledge decay below one focused-commit's worth within a year, computed per-file from the D16 decay model. Exhaustive, deterministic over fixed history.

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

15 of 407 significant source file(s) are orphaned — their living knowledge has decayed to nothing, so no one currently understands them. The largest is scripts/primer_classifier/cross_checker.py. Counted over 407 of the 520 production source files in this repository: the rest are under the ~2,400-byte size floor this dimension measures over.

Orphaned files with no living knowledge

✓ On the Gold path — maintain.

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

D35 · Change Coupling9.5 / 10Stronggated by 8 serious findings✓ Tool-verified

What it measures: Whether files that change together actually belong together — pairs that repeatedly co-change in git history despite having no explicit code dependency, surfacing the hidden/logical coupling (and boundaries in the wrong place) a static scan can't see.

Method: Pairwise co-occurrence over the per-commit file sets in git history (production source only — tests and generated dropped): Degree-of-Coupling = shared ÷ min individual revisions, reported above noise floors (each file ≥10 revisions, ≥5 shared commits, ≥50% strength); sweeping commits excluded. Deterministic over fixed history.

Coverage: Population: PRODUCTION source files only — test and generated files are dropped before pairing, so a class co-changing with its own test (trivially ~100%) can't drown the real production↔production coupling. Pairs ranked by Degree-of-Coupling. A non-source file is never a coupling PARTICIPANT either: documentation, schemas, config and data files are dropped with the rest, so a code↔docs pair — a command and the reference page that restates it — is not reported however strongly the two co-change; nor is coupling that runs THROUGH a build step or config file.

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

Strongest change-coupling: traits.rs↔table.rs 100%; solve.rs↔binding_memory.rs 93%; buck_check.rs↔map_db.rs 92%

Change coupling: traits.rs ↔ table.rs · ×6pyrefly/lib/alt/traits.rs
Change-coupling hub: binding_memory.rs → class_metadata.rs, solve.rs, class_metadata.rs · ×2pyrefly/lib/report/binding_memory.rs

What to do

  1. Resolve the 6 Change coupling finding(s) in Change Coupling — start with traits.rs, buck_check.rs, subset.rs. — One of this dimension's main actionable groups (6 warning-level).
  2. 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.

D36 · Supply-chain Provenance & Signing5.0 / 10Adequate✓ Tool-verified

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.

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

2/4 supply-chain integrity signals present (provenance, signing, SBOM, pinned actions).

REDACTED
REDACTED
REDACTED
REDACTED
REDACTED

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

What to do

  1. Resolve the 1 REDACTED finding(s) in Supply-chain Provenance & Signing. — One of this dimension's main actionable groups (1 warning-level).
  2. Resolve the 1 REDACTED finding(s) in Supply-chain Provenance & Signing. — One of this dimension's main actionable groups (1 warning-level).
  3. Resolve the 1 REDACTED finding(s) in Supply-chain Provenance & Signing. — One of this dimension's main actionable groups (1 warning-level).

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

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

What it measures: Whether any dependency the repository declares is published as MALICIOUS rather than merely vulnerable — a package that is an attacker's work, in any ecosystem osv-scanner reads. 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.

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

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

✓ On the Gold path — maintain.

Detailed fixes: d43_recommendation.md.

D44 · Platform End-of-Life10.0 / 10Exemplary✓ Tool-verified

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.

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

0 end-of-life runtime(s) and 0 end-of-life framework(s), read from 1 platform declaration(s) and 2 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.

✓ On the Gold path — maintain.

Detailed fixes: d44_recommendation.md.

Frontend & cross-cutting dimensions

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

AX10 · Code composition9.8 / 10Exemplary✓ Tool-verified

Other · Architecture — How the codebase splits by code ROLE — domain, application, infrastructure, test, generated. The significance map behind the knowledge/coupling weighting, and a DDD signal in its own right: a thin domain core under fat infrastructure is the anemic-domain smell, quantified. How each file's role is decided, because the split is only as good as that: a generated name or a build-output tree makes it Generated, a test project makes it Test, and otherwise the file's NAMESPACE and PATH words are matched against fixed vocabularies in a fixed ORDER — domain, then infrastructure, then application — so a file whose words hit two layers is counted under the earlier one. A production file matching none of them counts as application, so that share reads 'application or unclassified' rather than a measured application layer. Roles come from naming convention, never from what the code does. On this repository the split was taken from the source tree on disk rather than from a loaded .NET workspace, so a file's role is decided by its PATH segments alone — no declared namespace was available to add to the evidence — and generated output is excluded from the census entirely rather than counted as a generated share.

Method: Roslyn line-count by code ROLE: every source file classified Domain/Application/Infrastructure/Test/Generated by namespace + path convention (the shared CodeRoleClassifier), then significant lines summed per role. Deterministic; the advisory score is the business-logic (domain+application) share of production code.

Coverage: Population: ALL source files, each bucketed into ONE of five roles (Domain/Application/Infrastructure/Test/Generated) by namespace + path convention — a file whose layer isn't named in the convention falls to Application (the neutral default), and the split is line-count, not semantic depth or business value.

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.
AX3 · Project dependency cycles10.0 / 10Exemplary✓ Tool-verified

Other · Architecture — Whether the project-reference graph is acyclic (cycles block independent build/deploy and signal eroding boundaries).

Method: Project reference cycles via elementary-DFS over real .csproj references, using the engine shared with D5/D7; cyclic versus acyclic. Exhaustive, deterministic.

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

Other · Architecture — Whether dependencies point inward (Domain ← Application ← Infrastructure/Web) — the clean-architecture dependency rule, checked across the project graph.

Method: Layer violations by name-segment inference (Domain/Core to Application to Infrastructure/Web) over the project-reference graph. Exhaustive over all projects, deterministic.

AX8 · Test isolation10.0 / 10Exemplary✓ Tool-verified

Other · Architecture — Whether production projects stay free of references to test projects — tests may depend on production, never the reverse.

Method: Csproj graph: each production project checked for references to test projects (identified by test-framework presence, not name). Zero violations is clean. Deterministic.

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

Other · Architecture — Whether read (query) handlers stay side-effect-free — a query that writes persistent state or raises events breaks CQS and makes reads unsafe to retry, cache, or route to a read replica.

Method: Roslyn scan: CQRS handlers classified query-vs-command by interface (IQueryHandler/ICommandHandler/IRequestHandler<TQuery,TResult>) and name convention (*Query/Get*/Find* vs *Command); each query handler's body checked for persistent-state writes (SaveChanges/repository Add-Update) or event publishes by resolved invocation. Deterministic, type-level, exhaustive over the detected handlers.

Coverage: Population: CQRS handlers identified by IQueryHandler/ICommandHandler/IRequestHandler interface + *Query/Get*/Find*/*Command NAME convention; query purity then checked exhaustively within that set — a query handler using neither convention is invisible, and mutation is a resolved persistence/publish CALL, not full dataflow.

  • `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:1419
  • `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:1470

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.
ES1 · Fold determinism10.0 / 10Exemplary✓ Tool-verified

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.

ES2 · Immutable events10.0 / 10Exemplary✓ Tool-verified

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.

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

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

  • Add a 'Testing' section to the root README — 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.
M2 · Architecture documentation2.0 / 10Critical✓ Tool-verified

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

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

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

What to do

  • Record significant decisions one document per decision — dated, stating the context, the decision and its consequences — and keep them together wherever your design docs already live (a conventional `docs/adr/` tree, with each file named `NNNN-title` in whatever markup those docs already use, is the most discoverable form).
M3 · Folder & project structure10.0 / 10Exemplary✓ Tool-verified

Maturity · Maturity — Whether the repo is organised deliberately — src/test separation and consistent project naming.

Method: Filesystem scan: src/test folder separation and namespace-prefix consistency (majority RootNamespace agreement). Exhaustive across projects, deterministic.

M4 · Documentation accuracy10.0 / 10Exemplary◐ Sampled · advisory

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.

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

Readiness · Readiness — Whether an automated pipeline builds and tests every change.

Method: Filesystem scan: CI workflow files (.github/workflows, .gitlab-ci.yml, etc.) for build and test stages. Exhaustive, deterministic.

P10 · Library API & versioning10.0 / 10Exemplary○ Nothing flagged

Readiness · Readiness — For a library: a deliberate (small) public API surface and explicit semantic versioning so consumers can depend on it safely.

Method: Roslyn scan: public API surface area and semantic-versioning markers (SemVer attributes, changelog entries) for libraries; off .NET, a library is the ecosystem's publication act (an npm package that is not private and names an entry point, a PyPI distribution with a build system, a Rust library crate, a Maven/Gradle module that publishes, a Go module with no package main, a gemspec, a Composer library, a SwiftPM library product, a pub.dev or Hex package), its surface is the share of types the language 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.

P2 · Observability5.5 / 10Adequate✓ Tool-verified

Readiness · Readiness — Whether the code is diagnosable in production — structured logging, tracing/metrics, health checks.

Method: Filesystem/Roslyn scan: structured-logging frameworks (Serilog, NLog), OpenTelemetry, and health-check endpoint patterns. Exhaustive, deterministic.

  • Only 5/10 runnable modules use logging (modules with no entry point or server are excluded — they are libraries a runnable module hosts). Silent: `pyrefly`, `tensor-shapes/pyrefly-einops-stubs`, `tensor-shapes/pyrefly-jax-stubs`, `tensor-shapes/pyrefly-numpy-stubs`, `tensor-shapes/pyrefly-torch-stubs`.

What to do

  • Extend structured logging to the remaining runnable modules so everything you run is diagnosable in production.
P3 · Security & performance tooling5.0 / 10Adequate✓ Tool-verified

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

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

What to do

  • Enable Dependabot/Renovate or a dependency-review gate.
  • Add gitleaks/trufflehog in CI to block PRs that introduce committed secrets.
P4 · Deployment & Rollback10.0 / 10Exemplary✓ Tool-verified

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.

P6 · Release Hygiene10.0 / 10Exemplary✓ Tool-verified

Readiness · Readiness — Whether releases are traceable — a maintained changelog and explicit version stamping.

Method: Filesystem scan: changelog file presence and version tags in csproj or git tags. Exhaustive, deterministic.

PF1 · Benchmark discipline9.0 / 10Exemplary✓ Tool-verified

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.

PF3 · Async & latency hygiene10.0 / 10Exemplary✓ Tool-verified

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) or inside a Java method returning a Reactor Mono/Flux — and, for a .NET library with ≥5 awaits, the share of awaits using ConfigureAwait(false). Deterministic, syntax/text detection.

R1 · Type Safety8.9 / 10Strong✓ Tool-verified

React / JS · Code Health — How much of the frontend is typed TypeScript vs untyped JavaScript.

Method: Frontend file inventory: the share of typed TypeScript vs untyped JavaScript across the source tree. Deterministic, exhaustive over frontend files.

What to do

  • Migrate the remaining .js/.jsx files to TypeScript.
R10 · Code Duplication9.2 / 10Exemplary✓ Tool-verified

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.
R2 · Cyclomatic Complexity8.0 / 10Strong✓ Tool-verified

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

  • 1 file(s) over 400 lines (counted as significant lines — blank lines excluded — over production source only, tests excluded), largest first: lsp/src/extension.ts (534).

What to do

  • Split each oversized file along the responsibilities already in it, into smaller focused modules in the same package.
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, lsp/build-pyrefly.js

What to do

  • Add tests that import the unreached modules (directly or through their public entry).
R5 · Dependency Freshness10.0 / 10Exemplary✓ Tool-verified

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.

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.

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
R8 · Dependency Hygiene8.5 / 10Strong✓ Tool-verified

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.
R9 · Circular Imports10.0 / 10Exemplary✓ Tool-verified

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.

Reference — by lens

The score is the rank-weighted fold of these lenses (worst-heaviest), each including its meta-dimensions; a lens with a Critical contributor is capped at Fair (its band reads "gated by …") and is never the strongest area however high its average.

LensScoreRatingImpact
Code Health75%Adequate — gated by D2Capped at Fair by a Critical contributor — resolve it before relying on this lens.
Architecture93%Adequate — gated by D26Capped at Fair by a Critical contributor — resolve it before relying on this lens.
Maturity66%Adequate — gated by M2Capped at Fair by a Critical contributor — resolve it before relying on this lens.
Readiness74%StrongSolid.
Security67%Adequate — gated by D29Capped at Fair by a Critical contributor — resolve it before relying on this lens.
Event Sourcing100%ExemplaryStrongest area.
Performance94%ExemplarySolid.
Not evidenced — 4 control(s) we could not find positive evidence for

These checks grade a working control, and the repository shows no evidence of one. That is deliberately not scored as a zero: a repository cannot show an ops runbook, a database TTL or an infrastructure-side audit log, so absence of evidence here is not evidence the control is missing. It is also not a statement that the check is irrelevant to this codebase — the thing it grades applies; we just could not see it. Excluded from the score either way.

  • C3 Audit Trail — Not assessed: these audit controls are read from a source model (declarative annotations, request middleware, entity/column names, guard methods) that was not loaded for this repository — because the repository is written in a language this check does not yet model, or because its projects failed to load. Absence of an idiom this check recognises is NOT evidence that this repository lacks audit controls: it may implement them entirely in its own ecosystem. This is a gap in the analyzer's language coverage, not a finding about this repository.
  • C4 Data Retention — Not assessed: these retention controls are read from a source model (declarative annotations, request middleware, entity/column names, guard methods) that was not loaded for this repository — because the repository is written in a language this check does not yet model, or because its projects failed to load. Absence of an idiom this check recognises is NOT evidence that this repository lacks retention controls: it may implement them entirely in its own ecosystem. This is a gap in the analyzer's language coverage, not a finding about this repository.
  • C5 Data-Subject Rights — Not assessed: these data-subject rights controls are read from a source model (declarative annotations, request middleware, entity/column names, guard methods) that was not loaded for this repository — because the repository is written in a language this check does not yet model, or because its projects failed to load. Absence of an idiom this check recognises is NOT evidence that this repository lacks data-subject rights controls: it may implement them entirely in its own ecosystem. This is a gap in the analyzer's language coverage, not a finding about this repository.
  • P5 DR & Backup — not evidenced — repo shows no backup/RTO/RPO controls; absence of evidence is not evidence of a working control
Not included — 73 check(s) not relevant to this codebase

These checks had nothing to measure here (no tests, no git history, the codebase is small, or the architecture style doesn't apply), so they're omitted above rather than scored low.

  • AC1 Text alternatives — 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 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
  • AX2 Stateful singletons — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
  • AX5 Architecture & structure — not assessed — architecture style/structure is computed from a project graph (projects, types, module namespaces) that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
  • AX6 Interface segregation — not assessed — interface segregation is computed over a type surface that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
  • AX7 Slice cohesion — not applicable — not a vertical-slice architecture
  • 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 — Not assessed: these personal data controls are read from a source model (declarative annotations, request middleware, entity/column names, guard methods) that was not loaded for this repository — because the repository is written in a language this check does not yet model, or because its projects failed to load. Absence of an idiom this check recognises is NOT evidence that this repository lacks personal data controls: it may implement them entirely in its own ecosystem. This is a gap in the analyzer's language coverage, not a finding about this repository.
  • C2 Access Controls — Not assessed: these authorization controls are read from a source model (declarative annotations, request middleware, entity/column names, guard methods) that was not loaded for this repository — because the repository is written in a language this check does not yet model, or because its projects failed to load. Absence of an idiom this check recognises is NOT evidence that this repository lacks authorization controls: it may implement them entirely in its own ecosystem. This is a gap in the analyzer's language coverage, not a finding about this repository.
  • 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.
  • 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. 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 — No inline comments to assess — comment value is not applicable here.
  • D25 ADR Conformance — no ADRs to check
  • D27 Navigability — symbol resolution incomplete — navigability not assessed
  • D31 IaC & Container Security — No Infrastructure-as-Code or container manifests found (Dockerfile, Docker Compose, Terraform, Kubernetes/Helm, CloudFormation, ARM, Bicep, Ansible); nothing to scan.
  • D32 Data Compliance (PII/GDPR) — 48 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): 426 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 — This check finds retry-prone mutations (command handlers and message/event consumers) by walking the repository's declared types, and none was loaded here, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
  • GD1 Unfinished & placeholder code — no source files were read — this check reads C# syntax, and none was loaded for this repository. 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. Python runs on a garbage-collected runtime that gives a program no allocation-control idiom to choose on a hot path — no pools, stack allocation or value types — so allocation awareness is not something this code can be rated on.
  • R11 Import Boundaries — No recognizable feature-sliced/layered src layout — boundary rules not applicable.
  • S1 Web-Security Posture — Not assessed: these web-security controls are read from a source model (declarative annotations, request middleware, entity/column names, guard methods) that was not loaded for this repository — because the repository is written in a language this check does not yet model, or because its projects failed to load. Absence of an idiom this check recognises is NOT evidence that this repository lacks web-security controls: it may implement them entirely in its own ecosystem. This is a gap in the analyzer's language coverage, not a finding about this repository.
  • SC1 Supply-chain hygiene — Advisory — this card reports evidence and never carries a score, so there is nothing missing here.
  • X1 Async correctness — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
  • X10 Duplicated predicate — Advisory — this card reports evidence and never carries a score, so there is nothing missing here.
  • X12 Unreachable branch — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
  • X13 Undrained process stream — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
  • X14 Bypassable address classification — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
  • X15 Unvalidated length from an untrusted reader — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
  • X16 Unfloored truncation loop — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
  • X17 Uncapped recursion over a caller-supplied document — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
  • X18 Disposal-pattern correctness — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
  • X19 Unrestored process-global state — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
  • X2 Cancellation propagation — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
  • X20 Mistyped argument guard — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
  • X21 Side-effecting pattern guard — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
  • X22 Contradicted release guard — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
  • X23 Unguarded diagnostic materialisation — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
  • X24 Document value interpolated into markup unescaped — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
  • X25 Inert configuration knob — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
  • X26 Unsynchronised callback handoff — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
  • X27 Collection changed while being enumerated — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
  • X28 Index access outside its own emptiness guard — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
  • X29 Per-element action decided by a fixed element — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
  • X3 Exception handling — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
  • X30 Support guard that admits what it rejects — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
  • X32 Type resolved by simple name across every loaded assembly — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
  • X4 Structured logging — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
  • X5 Nullable reference types — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
  • X6 Hand-rolled structured-format parsing — Advisory — this card reports evidence and never carries a score, so there is nothing missing here.
  • X7 Silent fallback defaults — Advisory — this card reports evidence and never carries a score.
  • X9 Subsumed condition operand — Advisory — this card reports evidence and never carries a score, so there is nothing missing here.

Appendix A — Findings (grouped)

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

Critical — 156 finding(s)
D29 · Static Analysis (SAST) · REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • + 102 more in this group — see findings.md.
D29 · Static Analysis (SAST) · REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
D29 · Static Analysis (SAST) · REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
D29 · Static Analysis (SAST) · REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
D30 · Dependency Vulnerabilities · High CVE · ×3
  • REDACTED
  • REDACTED
  • REDACTED
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:1419 — `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:1470 — `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.
D28 · Secrets (history) · REDACTED · ×1
  • REDACTED
D29 · Static Analysis (SAST) · REDACTED · ×1
  • REDACTED
D30 · Dependency Vulnerabilities · High vulnerability · ×1
  • REDACTED
Serious — 1733 finding(s)
D17 · Explicit Debt · TodoComment · ×284
  • TodoComment crates/pyrefly_build/src/lib.rs:114 — // TODO(connernilsen): remove once internal stubs are deprecated — 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 crates/pyrefly_build/src/lib.rs:118 — // TODO(connernilsen): pull this out into per-config lookup, so build system can be shared with — 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 REDACTED:217 — # TODO(grievejia): Only docify stdlib for now — 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 crates/pyrefly_config/src/config.rs:592 — // TODO(connernilsen): DON'T COPY THIS TO NEW FIELDS. This is a temporary — 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 crates/pyrefly_config/src/config.rs:605 — // TODO(connernilsen): DON'T COPY THIS TO NEW FIELDS. This is a temporary — 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 crates/pyrefly_config/src/config.rs:626 — // TODO(connernilsen): DON'T COPY THIS TO NEW FIELDS. This is a temporary — 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 crates/pyrefly_config/src/config.rs:703 — // TODO(connernilsen): DON'T COPY THIS TO NEW FIELDS. This is a temporary — 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 crates/pyrefly_config/src/base.rs:279 — // TODO(connernilsen): DON'T COPY THIS TO NEW FIELDS. This is a temporary — 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 crates/pyrefly_config/src/base.rs:298 — // TODO(connernilsen): DON'T COPY THIS TO NEW FIELDS. This is a temporary — 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 crates/pyrefly_config/src/base.rs:322 — // TODO(connernilsen): DON'T COPY THIS TO NEW FIELDS. This is a temporary — 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 crates/pyrefly_config/src/environment/interpreters.rs:77 — // TODO(connernilsen): DON'T COPY THIS TO NEW FIELDS. This is a temporary — 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 crates/pyrefly_config/src/environment/environment.rs:45 — // TODO(connernilsen): DON'T COPY THIS TO NEW FIELDS. This is a temporary — 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 crates/pyrefly_config/src/environment/environment.rs:53 — // TODO(connernilsen): DON'T COPY THIS TO NEW FIELDS. This is a temporary — 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 crates/pyrefly_config/src/environment/environment.rs:62 — // TODO(connernilsen): DON'T COPY THIS TO NEW FIELDS. This is a temporary — 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 crates/pyrefly_config/src/migration/type_checking_mode.rs:33 — // TODO: "recommended" in basedpyright does enable all rules, but sets the severity to warning — 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 crates/pyrefly_config/src/migration/run.rs:228 — // TODO: This code is written in a fairly weird style. Give it a nicer interface — 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 crates/pyrefly_python/src/symbol_kind.rs:91 — // todo(samzhou19815): modifier for async — 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 crates/pyrefly_python/src/module_name.rs:623 — // TODO: This is wrong. The relative level 4 should be invalid — 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 crates/pyrefly_types/src/types.rs:2165 — // TODO: Should mostly be forcing these before printing — 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 crates/pyrefly_types/src/type_var_tuple.rs:55 — // TODO: properly take parent from caller of new() — 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 crates/pyrefly_types/src/type_var.rs:211 — // TODO: properly take parent from caller of new() — 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 crates/pyrefly_types/src/param_spec.rs:55 — // TODO: properly take parent from caller of new() — 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 crates/pyrefly_types/src/type_level_dsl.rs:1934 — // TODO(stroxler): Isolate deferred integer union-find state and AST revalidation behind a — 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 crates/pyrefly_types/src/type_level_dsl.rs:6423 — // TODO(stroxler): Compile validated expressions into a small IR so evaluation does not need — 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 crates/pyrefly_types/src/type_level_dsl.rs:7273 — // TODO(stroxler): Preserve a gradual product as a gradual dimension once — 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.
  • + 259 more in this group — see findings.md.
D2 · Cognitive Complexity · AnswersSolver · ×138
  • AnswersSolver::callable_infer_params (cognitive 340) pyrefly/lib/alt/callable.rs:894 — AnswersSolver::callable_infer_params has cognitive complexity 340 (threshold 15). Drivers by points: if/else 87 (227 pts), match/switch 23 (71 pts), loops 14 (28 pts), boolean chains 14 (nesting depth added 202). Of this number, 339 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 200) pyrefly/lib/alt/class/class_field.rs:1524 — AnswersSolver::calculate_class_field has cognitive complexity 200 (threshold 15). Drivers by points: if/else 75 (137 pts), boolean chains 35, match/switch 9 (19 pts), loops 3 (9 pts) (nesting depth added 78). To reduce it, split the body into named stages: move each independent 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 166) pyrefly/lib/alt/narrow.rs:1352 — AnswersSolver::atomic_narrow has cognitive complexity 166 (threshold 15). Drivers by points: if/else 59 (126 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::lookup_attr_static1 (cognitive 113) pyrefly/lib/alt/attr.rs:1737 — AnswersSolver::lookup_attr_static1 has cognitive complexity 113 (threshold 15). Drivers by points: if/else 29 (55 pts), match/switch 17 (40 pts), loops 4 (10 pts), boolean chains 8 (nesting depth added 55). 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 109) pyrefly/lib/alt/class/class_field.rs:4060 — AnswersSolver::check_consistent_override_for_field has cognitive complexity 109 (threshold 15). Drivers by points: if/else 39 (73 pts), boolean chains 22, match/switch 5 (10 pts), loops 2 (4 pts) (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::validate_type_shape_dsl_declaration (cognitive 108) pyrefly/lib/alt/type_level_dsl.rs:289 — AnswersSolver::validate_type_shape_dsl_declaration has cognitive complexity 108 (threshold 15). Drivers by points: match/switch 15 (49 pts), if/else 22 (42 pts), boolean chains 10, loops 4 (7 pts) (nesting depth added 57). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • AnswersSolver::subscript_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::subscript_infer_for_type_with_key_present_inner (cognitive 91) pyrefly/lib/alt/expr.rs:3367 — 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::call_functools_partial (cognitive 87) pyrefly/lib/alt/functools.rs:44 — AnswersSolver::call_functools_partial has cognitive complexity 87 (threshold 15). Drivers by points: if/else 28 (49 pts), match/switch 12 (24 pts), loops 4 (11 pts), boolean chains 3 (nesting depth added 40). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • AnswersSolver::check_type_is_class_object (cognitive 82) pyrefly/lib/alt/special_calls.rs:531 — 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::expr_infer_impl_helper (cognitive 77) pyrefly/lib/alt/expr.rs:574 — AnswersSolver::expr_infer_impl_helper has cognitive complexity 77 (threshold 15). Drivers by points: if/else 29 (49 pts), match/switch 13 (26 pts), boolean chains 2 (nesting depth added 33). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • AnswersSolver::tuple_infer (cognitive 71) pyrefly/lib/alt/expr.rs:1602 — 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:117 — 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::dict_items_infer_inner (cognitive 69) pyrefly/lib/alt/expr.rs:1885 — 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 66) pyrefly/lib/alt/attr.rs:2530 — AnswersSolver::as_attribute_base1 has cognitive complexity 66 (threshold 15). Drivers by points: if/else 15 (37 pts), loops 8 (25 pts), match/switch 2 (3 pts), boolean chains 1 (nesting depth added 40). 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 66) pyrefly/lib/alt/narrow.rs:2031 — AnswersSolver::narrow has cognitive complexity 66 (threshold 15). Drivers by points: if/else 19 (37 pts), match/switch 10 (21 pts), boolean chains 5, loops 1 (3 pts) (nesting depth added 31). 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::find_closest_overload (cognitive 66) pyrefly/lib/alt/overload.rs:840 — AnswersSolver::find_closest_overload has cognitive complexity 66 (threshold 15). Drivers by points: if/else 24 (55 pts), match/switch 2 (6 pts), loops 2 (4 pts), boolean chains 1 (nesting depth added 37). 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::solve_expectation (cognitive 62) pyrefly/lib/alt/solve.rs:2579 — AnswersSolver::solve_expectation has cognitive complexity 62 (threshold 15). Drivers by points: if/else 13 (30 pts), match/switch 7 (18 pts), boolean chains 10, loops 2 (4 pts) (nesting depth added 30). Of this number, 56 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:2814 — 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:182 — 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:4523 — 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::binding_to_type_unpacked_value (cognitive 56) pyrefly/lib/alt/solve.rs:4820 — 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:1759 — 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.
  • AnswersSolver::get_dataclass_init (cognitive 52) pyrefly/lib/alt/class/dataclass.rs:1266 — AnswersSolver::get_dataclass_init has cognitive complexity 52 (threshold 15). Drivers by points: if/else 15 (41 pts), boolean chains 6, match/switch 1 (4 pts), loops 1 (nesting depth added 29). 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.
  • + 113 more in this group — see findings.md.
D3 · God Classes · MethodTooLong · ×115
  • MethodTooLong: BindingsBuilder.stmt_impl pyrefly/lib/binding/stmt.rs:847 — MethodTooLong — stmt_impl runs 799 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 699 over it, 7.99× 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:894 — MethodTooLong — callable_infer_params runs 758 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 658 over it, 7.58× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: Subset.is_subset_eq_no_recursive_check pyrefly/lib/solver/subset.rs:1877 — MethodTooLong — is_subset_eq_no_recursive_check runs 701 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 601 over it, 7.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.
  • MethodTooLong: AnswersSolver.calculate_class_field pyrefly/lib/alt/class/class_field.rs:1524 — MethodTooLong — calculate_class_field runs 662 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 562 over it, 6.62× 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:6770 — MethodTooLong — evaluate_expression runs 620 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 520 over it, 6.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: Server.process_event pyrefly/lib/lsp/non_wasm/server.rs:2054 — MethodTooLong — process_event runs 598 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 498 over it, 5.98× 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 581 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 481 over it, 5.81× 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:289 — MethodTooLong — validate_type_shape_dsl_declaration runs 493 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 393 over it, 4.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.subscript_infer_for_type_with_key_present_inner pyrefly/lib/alt/expr.rs:3367 — 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 407 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 307 over it, 4.07× 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:574 — MethodTooLong — expr_infer_impl_helper runs 363 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 263 over it, 3.63× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: DslValidator.validate_condition crates/pyrefly_types/src/type_level_dsl.rs:4461 — 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:1352 — MethodTooLong — atomic_narrow runs 340 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 240 over it, 3.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: 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: BindingsBuilder.ensure_expr pyrefly/lib/binding/expr.rs:712 — MethodTooLong — ensure_expr runs 331 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 231 over it, 3.31× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: Subset.is_subset_eq_var pyrefly/lib/solver/solver.rs:3727 — MethodTooLong — is_subset_eq_var 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:182 — 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: StructurallyValidatedTypeShapeDslFunction.evaluate_condition crates/pyrefly_types/src/type_level_dsl.rs:7795 — MethodTooLong — evaluate_condition runs 321 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 221 over it, 3.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: Transaction.find_definition pyrefly/lib/state/lsp.rs:2676 — MethodTooLong — find_definition runs 318 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 218 over it, 3.18× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: AnswersSolver.check_consistent_override_for_field pyrefly/lib/alt/class/class_field.rs:4060 — MethodTooLong — check_consistent_override_for_field runs 305 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 205 over it, 3.05× 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:1893 — MethodTooLong — finish_cli_run 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: DefinitionsBuilder.stmt pyrefly/lib/export/definitions.rs:559 — MethodTooLong — stmt runs 283 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 183 over it, 2.83× 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.lookup_attr_static1 pyrefly/lib/alt/attr.rs:1737 — MethodTooLong — lookup_attr_static1 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: Binding.fmt pyrefly/lib/binding/binding.rs:2699 — MethodTooLong — fmt runs 271 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 171 over it, 2.71× 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:1759 — MethodTooLong — call_infer_with_callee_range runs 266 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 166 over it, 2.66× 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.
  • + 90 more in this group — see findings.md.
D1 · Cyclomatic Complexity · AnswersSolver · ×90
  • AnswersSolver::callable_infer_params (cyclomatic 136) pyrefly/lib/alt/callable.rs:894 — AnswersSolver::callable_infer_params has cyclomatic complexity 136 (threshold 15). Of this number, 134 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 119) pyrefly/lib/alt/class/class_field.rs:1524 — AnswersSolver::calculate_class_field has cyclomatic complexity 119 (threshold 15). To reduce it, separate the cases: extract each independent 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 119) pyrefly/lib/alt/narrow.rs:1352 — AnswersSolver::atomic_narrow has cyclomatic complexity 119 (threshold 15). To reduce it, separate the cases: extract each independent 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:3367 — 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::lookup_attr_static1 (cyclomatic 77) pyrefly/lib/alt/attr.rs:1737 — AnswersSolver::lookup_attr_static1 has cyclomatic complexity 77 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • AnswersSolver::as_attribute_base1 (cyclomatic 75) pyrefly/lib/alt/attr.rs:2530 — AnswersSolver::as_attribute_base1 has cyclomatic complexity 75 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • AnswersSolver::validate_type_shape_dsl_declaration (cyclomatic 75) pyrefly/lib/alt/type_level_dsl.rs:289 — AnswersSolver::validate_type_shape_dsl_declaration has cyclomatic complexity 75 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • AnswersSolver::expr_infer_impl_helper (cyclomatic 66) pyrefly/lib/alt/expr.rs:574 — AnswersSolver::expr_infer_impl_helper has cyclomatic complexity 66 (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 64) pyrefly/lib/alt/class/class_field.rs:4060 — AnswersSolver::check_consistent_override_for_field has cyclomatic complexity 64 (threshold 15). To reduce it, separate the cases: extract each independent 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 62) pyrefly/lib/alt/solve.rs:6303 — AnswersSolver::binding_to_type has cyclomatic complexity 62 (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 53) pyrefly/lib/alt/solve.rs:2579 — AnswersSolver::solve_expectation has cyclomatic complexity 53 (threshold 15). Of this number, 48 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::as_attribute_base1_of_type (cyclomatic 49) pyrefly/lib/alt/attr.rs:2814 — 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::call_functools_partial (cyclomatic 48) pyrefly/lib/alt/functools.rs:44 — AnswersSolver::call_functools_partial has cyclomatic complexity 48 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • AnswersSolver::class_metadata_of (cyclomatic 47) pyrefly/lib/alt/class/class_metadata.rs:182 — 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::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::narrow (cyclomatic 42) pyrefly/lib/alt/narrow.rs:2031 — AnswersSolver::narrow has cyclomatic complexity 42 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • AnswersSolver::expr_call_infer (cyclomatic 39) pyrefly/lib/alt/call.rs:2543 — AnswersSolver::expr_call_infer has cyclomatic complexity 39 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • AnswersSolver::decorated_function_type (cyclomatic 39) pyrefly/lib/alt/function.rs:765 — AnswersSolver::decorated_function_type 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:1759 — 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::parse_dimension_expr_with_context (cyclomatic 36) pyrefly/lib/alt/expr.rs:4342 — AnswersSolver::parse_dimension_expr_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::untype_opt_with_context (cyclomatic 36) pyrefly/lib/alt/solve.rs:6962 — 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::try_int_binop (cyclomatic 35) pyrefly/lib/alt/operators.rs:94 — AnswersSolver::try_int_binop has cyclomatic complexity 35 (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::apply_special_form (cyclomatic 34) pyrefly/lib/alt/specials.rs:343 — AnswersSolver::apply_special_form has cyclomatic complexity 34 (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 34) pyrefly/lib/alt/type_level_dsl.rs:915 — AnswersSolver::resolve_type_shape_dsl_intrinsic has cyclomatic complexity 34 (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.
  • + 65 more in this group — see findings.md.
D15 · Churn × Complexity Hotspots · Hotspot · ×87
  • Hotspot: pyrefly/lib/solver/subset.rs pyrefly/lib/solver/subset.rs:1877 — pyrefly/lib/solver/subset.rs changed 85 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 240 in Subset::is_subset_eq_no_recursive_check at line 1877. 9 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-01..2026-09-29, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-01 01:37:31 -07:00' --until='2026-09-29 01:37:31 -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: crates/pyrefly_types/src/type_level_dsl.rs crates/pyrefly_types/src/type_level_dsl.rs:6770 — crates/pyrefly_types/src/type_level_dsl.rs changed 82 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 247 in StructurallyValidatedTypeShapeDslFunction::evaluate_expression at line 6770. 2 of those changes were fix/bug commits, and the other 80 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-01..2026-09-29, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-01 01:37:31 -07:00' --until='2026-09-29 01:37:31 -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/alt/expr.rs pyrefly/lib/alt/expr.rs:3367 — pyrefly/lib/alt/expr.rs changed 150 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 3367. 7 of those changes were fix/bug commits, and the other 143 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-01..2026-09-29, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-01 01:37:31 -07:00' --until='2026-09-29 01:37:31 -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: crates/pyrefly_types/src/display.rs crates/pyrefly_types/src/display.rs:917 — crates/pyrefly_types/src/display.rs changed 67 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 148 in TypeDisplayContext::fmt_helper_generic at line 917. 7 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-01..2026-09-29, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-01 01:37:31 -07:00' --until='2026-09-29 01:37:31 -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/solve.rs pyrefly/lib/alt/solve.rs:6303 — pyrefly/lib/alt/solve.rs changed 156 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 62 in AnswersSolver::binding_to_type at line 6303. 10 of those changes were fix/bug commits, and the other 146 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-01..2026-09-29, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-01 01:37:31 -07:00' --until='2026-09-29 01:37:31 -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/lsp/non_wasm/server.rs pyrefly/lib/lsp/non_wasm/server.rs:2054 — pyrefly/lib/lsp/non_wasm/server.rs changed 75 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 128 in Server::process_event at line 2054. 12 of those changes were fix/bug commits, and the other 63 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-01..2026-09-29, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-01 01:37:31 -07:00' --until='2026-09-29 01:37:31 -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/class/class_field.rs pyrefly/lib/alt/class/class_field.rs:1524 — pyrefly/lib/alt/class/class_field.rs changed 77 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 119 in AnswersSolver::calculate_class_field at line 1524. 18 of those changes were fix/bug commits, and the other 59 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-01..2026-09-29, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-01 01:37:31 -07:00' --until='2026-09-29 01:37:31 -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/callable.rs pyrefly/lib/alt/callable.rs:894 — pyrefly/lib/alt/callable.rs changed 55 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 136 in AnswersSolver::callable_infer_params at line 894. 6 of those changes were fix/bug commits, and the other 49 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-01..2026-09-29, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-01 01:37:31 -07:00' --until='2026-09-29 01:37:31 -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/call.rs pyrefly/lib/alt/call.rs:378 — pyrefly/lib/alt/call.rs changed 83 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. 11 of those changes were fix/bug commits, and the other 72 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-01..2026-09-29, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-01 01:37:31 -07:00' --until='2026-09-29 01:37:31 -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/alt/type_level_dsl.rs pyrefly/lib/alt/type_level_dsl.rs:289 — pyrefly/lib/alt/type_level_dsl.rs changed 72 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 75 in AnswersSolver::validate_type_shape_dsl_declaration at line 289. 1 of those changes was a fix/bug commit, and the other 71 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-01..2026-09-29, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-01 01:37:31 -07:00' --until='2026-09-29 01:37:31 -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:847 — pyrefly/lib/binding/stmt.rs changed 34 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 157 in BindingsBuilder::stmt_impl at line 847. 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-01..2026-09-29, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-01 01:37:31 -07:00' --until='2026-09-29 01:37:31 -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: pyrefly/lib/solver/solver.rs pyrefly/lib/solver/solver.rs:3727 — pyrefly/lib/solver/solver.rs changed 97 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 54 in Subset::is_subset_eq_var at line 3727. 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-01..2026-09-29, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-01 01:37:31 -07:00' --until='2026-09-29 01:37:31 -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/binding/binding.rs pyrefly/lib/binding/binding.rs:2699 — pyrefly/lib/binding/binding.rs changed 70 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 74 in Binding::fmt at line 2699. 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-01..2026-09-29, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-01 01:37:31 -07:00' --until='2026-09-29 01:37:31 -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/attr.rs pyrefly/lib/alt/attr.rs:1737 — pyrefly/lib/alt/attr.rs changed 61 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 77 in AnswersSolver::lookup_attr_static1 at line 1737. 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-01..2026-09-29, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-01 01:37:31 -07:00' --until='2026-09-29 01:37:31 -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: pyrefly/lib/alt/narrow.rs pyrefly/lib/alt/narrow.rs:1352 — pyrefly/lib/alt/narrow.rs changed 39 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 119 in AnswersSolver::atomic_narrow at line 1352. 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-01..2026-09-29, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-01 01:37:31 -07:00' --until='2026-09-29 01:37:31 -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: crates/pyrefly_config/src/error_kind.rs crates/pyrefly_config/src/error_kind.rs:567 — crates/pyrefly_config/src/error_kind.rs changed 47 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 68 in ErrorKind::default_severity at line 567. 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-01..2026-09-29, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-01 01:37:31 -07:00' --until='2026-09-29 01:37:31 -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: pyrefly/lib/alt/polars_specials.rs pyrefly/lib/alt/polars_specials.rs:3225 — pyrefly/lib/alt/polars_specials.rs changed 97 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 31 in AnswersSolver::polars_join at line 3225. 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-01..2026-09-29, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-01 01:37:31 -07:00' --until='2026-09-29 01:37:31 -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: crates/pyrefly_config/src/config.rs crates/pyrefly_config/src/config.rs:1578 — crates/pyrefly_config/src/config.rs changed 49 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 59 in ConfigFile::configure_at at line 1578. 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-01..2026-09-29, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-01 01:37:31 -07:00' --until='2026-09-29 01:37:31 -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/state/lsp.rs pyrefly/lib/state/lsp.rs:2676 — pyrefly/lib/state/lsp.rs changed 62 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 46 in Transaction::find_definition at line 2676. 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-01..2026-09-29, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-01 01:37:31 -07:00' --until='2026-09-29 01:37:31 -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:1053 — crates/pyrefly_types/src/types.rs changed 49 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 53 in Type::recurse at line 1053. 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-01..2026-09-29, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-01 01:37:31 -07:00' --until='2026-09-29 01:37:31 -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:765 — pyrefly/lib/alt/function.rs changed 66 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 39 in AnswersSolver::decorated_function_type at line 765. 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-01..2026-09-29, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-01 01:37:31 -07:00' --until='2026-09-29 01:37:31 -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:1893 — pyrefly/lib/commands/check.rs changed 46 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 54 in CheckArgs::finish_cli_run at line 1893. 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-01..2026-09-29, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-01 01:37:31 -07:00' --until='2026-09-29 01:37:31 -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:1457 — pyrefly/lib/state/state.rs changed 56 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 36 in Transaction::demand at line 1457. 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-01..2026-09-29, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-01 01:37:31 -07:00' --until='2026-09-29 01:37:31 -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/tsp/type_conversion.rs pyrefly/lib/tsp/type_conversion.rs:225 — pyrefly/lib/tsp/type_conversion.rs changed 32 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 54 in TypeConverter::convert at line 225. 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-01..2026-09-29, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-01 01:37:31 -07:00' --until='2026-09-29 01:37:31 -07:00' --full-history --no-merges -- pyrefly/lib/tsp/type_conversion.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/pattern.rs pyrefly/lib/binding/pattern.rs:284 — pyrefly/lib/binding/pattern.rs changed 22 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 76 in BindingsBuilder::bind_pattern at line 284. 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-01..2026-09-29, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-01 01:37:31 -07:00' --until='2026-09-29 01:37:31 -07:00' --full-history --no-merges -- pyrefly/lib/binding/pattern.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.
  • + 62 more in this group — see findings.md.
D3 · God Classes · FileTooLong · ×80
  • FileTooLong: src/type_level_dsl.rs crates/pyrefly_types/src/type_level_dsl.rs — FileTooLong — 5941 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 5441 over it, 11.88× 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 — 5146 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 (324-7574). The bar is 500 significant lines; this is 4646 over it, 10.29× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
  • FileTooLong: non_wasm/server.rs pyrefly/lib/lsp/non_wasm/server.rs — FileTooLong — 4963 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: Server (3 blocks, 1112-7419). The bar is 500 significant lines; this is 4463 over it, 9.93× 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 — 4063 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 (1425-6045). The bar is 500 significant lines; this is 3563 over it, 8.13× 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 — 3844 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 (429-5472). The bar is 500 significant lines; this is 3344 over it, 7.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: state/lsp.rs pyrefly/lib/state/lsp.rs — FileTooLong — 3634 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, 829-5316). The bar is 500 significant lines; this is 3134 over it, 7.27× 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 — 3018 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), about 68% of them inside a single declaration: CallGraphVisitor (3 blocks, 1497-4459). The bar is 500 significant lines; this is 2518 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 — 2654 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 2154 over it, 5.31× 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 — 2457 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 1957 over it, 4.91× 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 — 2448 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 (1025-3506), declaring 35 free functions. The bar is 500 significant lines; this is 1948 over it, 4.90× 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: state/state.rs pyrefly/lib/state/state.rs — FileTooLong — 2304 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 1804 over it, 4.61× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: binding/binding.rs pyrefly/lib/binding/binding.rs — FileTooLong — 2296 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 1796 over it, 4.59× 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 — 2292 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 (209-3476). The bar is 500 significant lines; this is 1792 over it, 4.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: alt/attr.rs pyrefly/lib/alt/attr.rs — FileTooLong — 2268 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), about 83% of them inside a single declaration: AnswersSolver (2 blocks, 619-3507). The bar is 500 significant lines; this is 1768 over it, 4.54× 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 — 2203 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-3016). The bar is 500 significant lines; this is 1703 over it, 4.41× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
  • FileTooLong: alt/answers_solver.rs pyrefly/lib/alt/answers_solver.rs — FileTooLong — 2120 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 1620 over it, 4.24× 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 — 2021 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-2899). The bar is 500 significant lines; this is 1521 over it, 4.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: alt/callable.rs pyrefly/lib/alt/callable.rs — FileTooLong — 1828 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 (790-2663). The bar is 500 significant lines; this is 1328 over it, 3.66× 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 — 1770 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-2659). The bar is 500 significant lines; this is 1270 over it, 3.54× 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 — 1759 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, 286-2925). The bar is 500 significant lines; this is 1259 over it, 3.52× 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 — 1649 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 (145-2362). The bar is 500 significant lines; this is 1149 over it, 3.30× 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 — 1631 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), declaring 42 free functions. The bar is 500 significant lines; this is 1131 over it, 3.26× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: 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.
  • FileTooLong: binding/stmt.rs pyrefly/lib/binding/stmt.rs — FileTooLong — 1402 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: BindingsBuilder (184-2170). The bar is 500 significant lines; this is 902 over it, 2.80× 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.
  • + 55 more in this group — see findings.md.
D2 · Cognitive Complexity · pyrefly · ×51
  • pyrefly::lib::error::suppress::remove_unused_ignores_from_serialized (cognitive 91) pyrefly/lib/error/suppress.rs:636 — pyrefly::lib::error::suppress::remove_unused_ignores_from_serialized has cognitive complexity 91 (threshold 15). Drivers by points: if/else 17 (74 pts), loops 5 (12 pts), boolean chains 5 (nesting depth added 64). 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::commands::coverage::collect::parse_functions (cognitive 90) pyrefly/lib/commands/coverage/collect.rs:755 — pyrefly::lib::commands::coverage::collect::parse_functions has cognitive complexity 90 (threshold 15). Drivers by points: if/else 25 (67 pts), boolean chains 11, match/switch 2 (7 pts), loops 3 (5 pts) (nesting depth added 49). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • 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::error::suppress::add_suppressions (cognitive 52) pyrefly/lib/error/suppress.rs:342 — pyrefly::lib::error::suppress::add_suppressions has cognitive complexity 52 (threshold 15). Drivers by points: if/else 13 (34 pts), match/switch 3 (8 pts), loops 4 (7 pts), boolean chains 3 (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.
  • 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::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::binding::function::function_last_expressions::f (cognitive 42) pyrefly/lib/binding/function.rs:980 — 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::collect_module_reports (cognitive 35) pyrefly/lib/commands/coverage/collect.rs:1613 — 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:1436 — 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::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 31) pyrefly/lib/stubgen/extract.rs:173 — pyrefly::lib::stubgen::extract::extract_stmts has cognitive complexity 31 (threshold 15). Drivers by points: if/else 8 (22 pts), loops 2 (5 pts), boolean chains 2, match/switch 1 (2 pts) (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • pyrefly::lib::commands::coverage::collect::parse_variables (cognitive 29) pyrefly/lib/commands/coverage/collect.rs:462 — pyrefly::lib::commands::coverage::collect::parse_variables has cognitive complexity 29 (threshold 15). Drivers by points: if/else 8 (12 pts), match/switch 5 (12 pts), boolean chains 4, loops 1 (nesting depth added 11). Of this number, 22 points are the body's own statements and 7 belong to 2 function items inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • pyrefly::lib::state::lsp::quick_fixes::extract_function::extract_function_code_actions (cognitive 27) pyrefly/lib/state/lsp/quick_fixes/extract_function.rs:39 — pyrefly::lib::state::lsp::quick_fixes::extract_function::extract_function_code_actions has cognitive complexity 27 (threshold 15). Drivers by points: if/else 12 (21 pts), boolean chains 4, loops 2 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • pyrefly::lib::report::pysa::ast_visitor::visit_statement (cognitive 26) pyrefly/lib/report/pysa/ast_visitor.rs:264 — pyrefly::lib::report::pysa::ast_visitor::visit_statement has cognitive complexity 26 (threshold 15). Drivers by points: if/else 12 (21 pts), loops 2 (4 pts), match/switch 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • pyrefly::lib::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::module::finder::find_import_with_mode (cognitive 25) pyrefly/lib/module/finder.rs:592 — pyrefly::lib::module::finder::find_import_with_mode has cognitive complexity 25 (threshold 15). Drivers by points: if/else 15, boolean chains 10. 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::module::finder::resolve_third_party_stub (cognitive 24) pyrefly/lib/module/finder.rs:84 — 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:347 — 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::commands::coverage::collect::parse_instance_attrs (cognitive 24) pyrefly/lib/commands/coverage/collect.rs:657 — pyrefly::lib::commands::coverage::collect::parse_instance_attrs has cognitive complexity 24 (threshold 15). Drivers by points: if/else 8 (16 pts), match/switch 2 (4 pts), boolean chains 3, loops 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • 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::export::symbols::build (cognitive 23) pyrefly/lib/export/symbols.rs:165 — pyrefly::lib::export::symbols::build has cognitive complexity 23 (threshold 15). Drivers by points: if/else 7 (16 pts), loops 2 (4 pts), match/switch 1 (2 pts), boolean chains 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • 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::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::alt::class::variance_inference::on_type (cognitive 22) pyrefly/lib/alt/class/variance_inference.rs:374 — 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.
  • + 26 more in this group — see findings.md.
D4 · Code Duplication · Duplicated block (5 lines × 2) · ×33
  • Duplicated block (5 lines × 2) crates/pyrefly_python/src/ignore.rs:658 — crates/pyrefly_python/src/ignore.rs:658-662 | crates/pyrefly_python/src/ignore.rs:800-804 — both copies are in the same file, so extract the block into 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:6779 — crates/pyrefly_types/src/type_level_dsl.rs:6779-6783 | crates/pyrefly_types/src/type_level_dsl.rs:6805-6809 — both copies are in the same file, so extract the block into 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:7275 — crates/pyrefly_types/src/type_level_dsl.rs:7275-7279 | crates/pyrefly_types/src/type_level_dsl.rs:7294-7298 — both copies are in the same file, so extract the block into 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:2370 — pyrefly/lib/alt/call.rs:2370-2374 | pyrefly/lib/alt/call.rs:2395-2399 — both copies are in the same file, so extract the block into 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:902 — pyrefly/lib/alt/overload.rs:902-906 | pyrefly/lib/alt/overload.rs:915-919 — both copies are in the same file, so extract the block into 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:700 — pyrefly/lib/binding/class.rs:700-704 | pyrefly/lib/binding/class.rs:1159-1166 — both copies are in the same file, so extract the block into 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:216 — pyrefly/lib/stubgen/extract.rs:216-220 | pyrefly/lib/stubgen/extract.rs:230-234 — both copies are in the same file, so extract the block into 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:5455-5459 — 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:7268 — crates/pyrefly_types/src/type_level_dsl.rs:7268-7272 | crates/pyrefly_types/src/type_level_dsl.rs:7289-7293 — both copies are in the same file, so extract the block into 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) crates/pyrefly_types/src/type_level_dsl.rs:7483 — crates/pyrefly_types/src/type_level_dsl.rs:7483-7487 | crates/pyrefly_types/src/type_level_dsl.rs:7514-7518 — both copies are in the same file, so extract the block into 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/einops.rs:467 — crates/pyrefly_types/src/einops.rs:467-471 | crates/pyrefly_types/src/einops.rs:486-490 — both copies are in the same file, so extract the block into 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:6694 — pyrefly/lib/alt/solve.rs:6694-6698 | pyrefly/lib/alt/solve.rs:6819-6823 — both copies are in the same file, so extract the block into 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:1167 — pyrefly/lib/solver/subset.rs:1167-1171 | pyrefly/lib/solver/subset.rs:1180-1184 — both copies are in the same file, so extract the block into 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:532 — tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations_runnable.py:532-536 | 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:165 — tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations_runnable.py:165-169 | 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.
  • + 8 more in this group — see findings.md.
D2 · Cognitive Complexity · BindingsBuilder · ×28
  • BindingsBuilder::stmt_impl (cognitive 322) pyrefly/lib/binding/stmt.rs:847 — BindingsBuilder::stmt_impl has cognitive complexity 322 (threshold 15). Drivers by points: if/else 99 (242 pts), match/switch 14 (42 pts), boolean chains 20, loops 8 (18 pts) (nesting depth added 181). 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::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 144) pyrefly/lib/binding/expr.rs:712 — BindingsBuilder::ensure_expr has cognitive complexity 144 (threshold 15). Drivers by points: if/else 32 (73 pts), loops 14 (45 pts), match/switch 8 (16 pts), boolean chains 10 (nesting depth added 80). Of this number, 142 points are the body's own statements and 2 belong to one function item inside it that branches. The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • BindingsBuilder::type_params_with_owner (cognitive 45) pyrefly/lib/binding/bindings.rs:2231 — 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:871 — 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::extract_shaped_array_metadata (cognitive 43) pyrefly/lib/binding/shape_type.rs:543 — 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::merged_flow_info (cognitive 42) pyrefly/lib/binding/scope.rs:3903 — BindingsBuilder::merged_flow_info has cognitive complexity 42 (threshold 15). Drivers by points: if/else 17 (35 pts), boolean chains 4, 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_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 33) pyrefly/lib/binding/stmt.rs:2076 — BindingsBuilder::bind_module_exports has cognitive complexity 33 (threshold 15). Drivers by points: if/else 12 (29 pts), loops 2 (4 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.
  • BindingsBuilder::class_def_inner (cognitive 32) pyrefly/lib/binding/class.rs:245 — 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:580 — 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:166 — 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 28) pyrefly/lib/binding/expr.rs:359 — BindingsBuilder::ensure_name_impl has cognitive complexity 28 (threshold 15). Drivers by points: if/else 13 (21 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::ensure_type_impl (cognitive 27) pyrefly/lib/binding/expr.rs:1282 — BindingsBuilder::ensure_type_impl has cognitive complexity 27 (threshold 15). Drivers by points: boolean chains 10, if/else 6 (9 pts), match/switch 4 (6 pts), loops 1 (2 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::bind_single_name_assign (cognitive 27) pyrefly/lib/binding/target.rs:651 — BindingsBuilder::bind_single_name_assign has cognitive complexity 27 (threshold 15). Drivers by points: if/else 16 (18 pts), boolean chains 8, match/switch 1 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
  • 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:420 — 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::synthesize_collections_named_tuple_def (cognitive 24) pyrefly/lib/binding/class.rs:1262 — 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:692 — 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 22) pyrefly/lib/binding/stmt.rs:262 — BindingsBuilder::handle_special_import_call has cognitive complexity 22 (threshold 15). Drivers by points: if/else 7 (14 pts), loops 2 (5 pts), match/switch 2, 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.
  • BindingsBuilder::stmts (cognitive 21) pyrefly/lib/binding/bindings.rs:1321 — BindingsBuilder::stmts has cognitive complexity 21 (threshold 15). Drivers by points: if/else 10 (14 pts), boolean chains 6, loops 1 (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.
  • BindingsBuilder::bind_lambda (cognitive 19) pyrefly/lib/binding/expr.rs:541 — 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.
  • BindingsBuilder::insert_synthesized_fields (cognitive 18) pyrefly/lib/binding/class.rs:910 — BindingsBuilder::insert_synthesized_fields has cognitive complexity 18 (threshold 15). Drivers by points: match/switch 4 (9 pts), if/else 3 (6 pts), boolean chains 2, loops 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.
  • BindingsBuilder::merge_flow (cognitive 18) pyrefly/lib/binding/scope.rs:4118 — BindingsBuilder::merge_flow has cognitive complexity 18 (threshold 15). Drivers by points: boolean chains 6, if/else 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::record_shape_function_metadata (cognitive 18) pyrefly/lib/binding/shape_type.rs:241 — BindingsBuilder::record_shape_function_metadata has cognitive complexity 18 (threshold 15). Drivers by points: if/else 10 (11 pts), match/switch 2 (4 pts), boolean chains 3 (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.
  • + 3 more in this group — see findings.md.
D4 · Code Duplication · Duplicated block (7 lines × 2) · ×28
  • 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:728 — crates/pyrefly_types/src/dimension.rs:728-734 | crates/pyrefly_types/src/dimension.rs:921-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 (7 lines × 2) crates/pyrefly_types/src/display.rs:1377 — crates/pyrefly_types/src/display.rs:1377-1383 | crates/pyrefly_types/src/display.rs:1393-1399 — both copies are in the same file, so extract the block into 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:3591 — crates/pyrefly_types/src/type_level_dsl.rs:3591-3597 | crates/pyrefly_types/src/type_level_dsl.rs:3692-3698 — both copies are in the same file, so extract the block into 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:7489 — crates/pyrefly_types/src/type_level_dsl.rs:7489-7495 | crates/pyrefly_types/src/type_level_dsl.rs:7520-7526 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (7 lines × 2) pyrefly/lib/alt/narrow.rs:1131 — pyrefly/lib/alt/narrow.rs:1131-1137 | pyrefly/lib/alt/narrow.rs:1154-1160 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (7 lines × 2) pyrefly/lib/alt/solve.rs:3628 — pyrefly/lib/alt/solve.rs:3628-3634 | pyrefly/lib/alt/solve.rs:3636-3642 — both copies are in the same file, so extract the block into 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:2402 — pyrefly/lib/binding/scope.rs:2402-2408 | pyrefly/lib/binding/scope.rs:2464-2470 — both copies are in the same file, so extract the block into 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:4784 — pyrefly/lib/lsp/non_wasm/server.rs:4784-4790 | pyrefly/lib/lsp/non_wasm/server.rs:4813-4819 — both copies are in the same file, so extract the block into 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:6002 — pyrefly/lib/lsp/non_wasm/server.rs:6002-6008 | 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:6055 — pyrefly/lib/lsp/non_wasm/server.rs:6055-6061 | 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/solver/subset.rs:860 — pyrefly/lib/solver/subset.rs:860-866 | pyrefly/lib/solver/subset.rs:893-899 — both copies are in the same file, so extract the block into 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:668 — pyrefly/lib/state/lsp/dict_completions.rs:668-674 | pyrefly/lib/state/lsp/dict_completions.rs:704-710 — both copies are in the same file, so extract the block into 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: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/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:495 — pyrefly/lib/alt/polars_specials.rs:495-501 | 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:482 — pyrefly/lib/binding/bindings.rs:482-488 | pyrefly/lib/binding/shape_type.rs:106-115 — 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:3449 — crates/pyrefly_types/src/type_level_dsl.rs:3449-3455 | crates/pyrefly_types/src/type_level_dsl.rs:3499-3505 — both copies are in the same file, so extract the block into 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:854 — pyrefly/lib/alt/class/variance_inference.rs:854-860 | pyrefly/lib/alt/class/variance_inference.rs:866-872 — both copies are in the same file, so extract the block into 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:1459 — pyrefly/lib/binding/binding.rs:1459-1465 | pyrefly/lib/binding/binding.rs:2771-2777 — both copies are in the same file, so extract the block into 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.
  • Duplicated block (7 lines × 2) scripts/llm_transport.py:119 — scripts/llm_transport.py:119-125 | scripts/llm_transport.py:187-193 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • + 3 more in this group — see findings.md.
D2 · Cognitive Complexity · Transaction · ×27
  • Transaction::completion_sorted_opt_with_incomplete (cognitive 95) pyrefly/lib/lsp/wasm/completion.rs:1068 — 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 84) pyrefly/lib/state/lsp.rs:3328 — Transaction::local_quickfix_code_actions_sorted has cognitive complexity 84 (threshold 15). Drivers by points: if/else 20 (62 pts), loops 6 (12 pts), boolean chains 8, match/switch 1 (2 pts) (nesting depth added 49). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Transaction::find_definition (cognitive 69) pyrefly/lib/state/lsp.rs:2676 — Transaction::find_definition has cognitive complexity 69 (threshold 15). Drivers by points: if/else 22 (45 pts), match/switch 8 (19 pts), boolean chains 5 (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.
  • Transaction::demand (cognitive 56) pyrefly/lib/state/state.rs:1457 — 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:942 — 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:626 — 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:684 — 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 33) pyrefly/lib/state/state.rs:1292 — Transaction::clean has cognitive complexity 33 (threshold 15). Drivers by points: if/else 13 (24 pts), boolean chains 4, loops 2 (3 pts), match/switch 1 (2 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Transaction::find_operator_dunder (cognitive 32) pyrefly/lib/state/lsp.rs:2244 — 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:3980 — 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:649 — 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:371 — 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:1232 — 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:1198 — 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:545 — 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:475 — 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:848 — 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::type_from_resolution (cognitive 19) pyrefly/lib/state/lsp.rs:1415 — 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.
  • Transaction::type_from_expression_at_impl (cognitive 18) pyrefly/lib/state/lsp.rs:940 — Transaction::type_from_expression_at_impl has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (17 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.
  • Transaction::resolve_named_import (cognitive 18) pyrefly/lib/state/lsp.rs:1658 — Transaction::resolve_named_import has cognitive complexity 18 (threshold 15). Drivers by points: if/else 4 (12 pts), match/switch 2 (4 pts), boolean chains 1, 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.
  • + 2 more in this group — see findings.md.
D2 · Cognitive Complexity · pyrefly_types · ×24
  • 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::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::einops::evaluate_einops_pattern (cognitive 41) crates/pyrefly_types/src/einops.rs:374 — pyrefly_types::einops::evaluate_einops_pattern has cognitive complexity 41 (threshold 15). Drivers by points: if/else 13 (25 pts), match/switch 6 (11 pts), boolean chains 3, loops 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_types::einsum::parse_einops_einsum_equation (cognitive 38) crates/pyrefly_types/src/einsum.rs:216 — 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:933 — 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::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:780 — pyrefly_types::dimension::canonicalize_product has cognitive complexity 33 (threshold 15). Drivers by points: if/else 12 (22 pts), loops 3 (6 pts), match/switch 1 (3 pts), boolean chains 2 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • pyrefly_types::simplify::collapse_literals (cognitive 32) crates/pyrefly_types/src/simplify.rs:185 — 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_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::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::gufunc::parse_gufunc_signature (cognitive 24) crates/pyrefly_types/src/gufunc.rs:240 — 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::simplify::collapse_quantifieds (cognitive 19) crates/pyrefly_types/src/simplify.rs:447 — 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::evaluate_einops_einsum (cognitive 19) crates/pyrefly_types/src/einsum.rs:306 — 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::type_level_dsl::lower_parameter (cognitive 19) crates/pyrefly_types/src/type_level_dsl.rs:8322 — pyrefly_types::type_level_dsl::lower_parameter has cognitive complexity 19 (threshold 15). Drivers by points: match/switch 7 (17 pts), if/else 1 (2 pts) (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.
  • pyrefly_types::einsum::parse_einsum_equation (cognitive 18) crates/pyrefly_types/src/einsum.rs:418 — 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::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::gufunc::evaluate_gufunc (cognitive 16) crates/pyrefly_types/src/gufunc.rs:502 — pyrefly_types::gufunc::evaluate_gufunc has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (11 pts), loops 2 (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.
  • 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.
D4 · Code Duplication · Duplicated block (8 lines × 2) · ×24
  • 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:1023 — crates/pyrefly_types/src/dimension.rs:1023-1030 | crates/pyrefly_types/src/dimension.rs:1034-1043 — both copies are in the same file, so extract the block into 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:1403 — crates/pyrefly_types/src/dimension.rs:1403-1410 | crates/pyrefly_types/src/dimension.rs:1420-1427 — both copies are in the same file, so extract the block into 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:2113 — pyrefly/lib/alt/attr.rs:2113-2120 | pyrefly/lib/alt/attr.rs:2133-2140 — both copies are in the same file, so extract the block into 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:860 — pyrefly/lib/alt/class/class_field.rs:860-867 | pyrefly/lib/alt/class/class_field.rs:1179-1189 — both copies are in the same file, so extract the block into 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:474 — pyrefly/lib/alt/narrow.rs:474-481 | pyrefly/lib/alt/narrow.rs:1852-1860 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (8 lines × 2) pyrefly/lib/alt/narrow.rs:1210 — pyrefly/lib/alt/narrow.rs:1210-1217 | pyrefly/lib/alt/narrow.rs:1226-1233 — both copies are in the same file, so extract the block into 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:304 — pyrefly/lib/alt/operators.rs:304-311 | pyrefly/lib/alt/operators.rs:318-325 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • 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:971 — pyrefly/lib/binding/expr.rs:971-978 | pyrefly/lib/binding/expr.rs:991-998 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (8 lines × 2) pyrefly/lib/binding/narrow.rs:853 — pyrefly/lib/binding/narrow.rs:853-860 | pyrefly/lib/binding/narrow.rs:874-881 — both copies are in the same file, so extract the block into 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:2394 — pyrefly/lib/lsp/non_wasm/server.rs:2394-2401 | pyrefly/lib/lsp/non_wasm/server.rs:2516-2523 — both copies are in the same file, so extract the block into 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:6006 — pyrefly/lib/lsp/non_wasm/server.rs:6006-6013 | pyrefly/lib/lsp/non_wasm/server.rs:6059-6066 — both copies are in the same file, so extract the block into 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:4115 — pyrefly/lib/lsp/non_wasm/server.rs:4115-4122 | pyrefly/lib/lsp/non_wasm/server.rs:4190-4197 — both copies are in the same file, so extract the block into 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) scripts/llm_transport.py:122 — scripts/llm_transport.py:122-129 | scripts/llm_transport.py:178-185 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift 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/llm_transport.py:122` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (8 lines × 2) scripts/primer_classifier/code_fetcher.py:199 — scripts/primer_classifier/code_fetcher.py:199-206 | scripts/primer_classifier/code_fetcher.py:246-253 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • 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/pyrefly-jax-stubs/examples/bert.py:479 — tensor-shapes/pyrefly-jax-stubs/examples/bert.py:479-486 | tensor-shapes/pyrefly-jax-stubs/examples/bert.py:492-499 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D1 · Cyclomatic Complexity · pyrefly_types · ×23
  • 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::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 38) crates/pyrefly_types/src/simplify.rs:185 — pyrefly_types::simplify::collapse_literals 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.
  • 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::evaluate_einops_pattern (cyclomatic 30) crates/pyrefly_types/src/einops.rs:374 — pyrefly_types::einops::evaluate_einops_pattern has cyclomatic complexity 30 (threshold 15). To reduce it, separate the cases: extract each independent 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::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::einsum::parse_einops_einsum_equation (cyclomatic 20) crates/pyrefly_types/src/einsum.rs:216 — 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:933 — 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.
  • 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::gufunc::parse_gufunc_signature (cyclomatic 19) crates/pyrefly_types/src/gufunc.rs:240 — pyrefly_types::gufunc::parse_gufunc_signature has cyclomatic complexity 19 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • pyrefly_types::dimension::int_is_provably_negative (cyclomatic 18) crates/pyrefly_types/src/dimension.rs:327 — 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 19) 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:780 — 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 19) 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::lower_parameter (cyclomatic 17) crates/pyrefly_types/src/type_level_dsl.rs:8322 — pyrefly_types::type_level_dsl::lower_parameter 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.
  • pyrefly_types::type_level_dsl::evaluate_dimension_arithmetic (cyclomatic 17) crates/pyrefly_types/src/type_level_dsl.rs:8376 — 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::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.
  • pyrefly_types::einsum::parse_einsum_equation (cyclomatic 16) crates/pyrefly_types/src/einsum.rs:418 — 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.
D4 · Code Duplication · Duplicated block (6 lines × 2) · ×23
  • 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:3550 — crates/pyrefly_types/src/type_level_dsl.rs:3550-3555 | crates/pyrefly_types/src/type_level_dsl.rs:4604-4609 — both copies are in the same file, so extract the block into 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:7502 — crates/pyrefly_types/src/type_level_dsl.rs:7502-7507 | crates/pyrefly_types/src/type_level_dsl.rs:7541-7546 — both copies are in the same file, so extract the block into 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:2691 — pyrefly/lib/alt/attr.rs:2691-2696 | pyrefly/lib/alt/attr.rs:2864-2869 — both copies are in the same file, so extract the block into 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:4011 — pyrefly/lib/alt/expr.rs:4011-4016 | pyrefly/lib/alt/expr.rs:4042-4048 — both copies are in the same file, so extract the block into 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:2761 — pyrefly/lib/alt/function.rs:2761-2766 | pyrefly/lib/alt/function.rs:2851-2856 — both copies are in the same file, so extract the block into 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:2402 — pyrefly/lib/alt/narrow.rs:2402-2409 | pyrefly/lib/alt/narrow.rs:2467-2472 — both copies are in the same file, so extract the block into 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:1221 — pyrefly/lib/alt/polars_specials.rs:1221-1226 | pyrefly/lib/alt/polars_specials.rs:1631-1636 — both copies are in the same file, so extract the block into 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/solve.rs:4246 — pyrefly/lib/alt/solve.rs:4246-4251 | pyrefly/lib/alt/solve.rs:4279-4284 — both copies are in the same file, so extract the block into 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:1154 — pyrefly/lib/binding/expr.rs:1154-1159 | pyrefly/lib/binding/expr.rs:1161-1166 — both copies are in the same file, so extract the block into 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:333 — pyrefly/lib/export/definitions.rs:333-338 | 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/solver/subset.rs:498 — pyrefly/lib/solver/subset.rs:498-503 | pyrefly/lib/solver/subset.rs:509-514 — both copies are in the same file, so extract the block into 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) 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) crates/pyrefly_types/src/type_level_dsl.rs:6928 — crates/pyrefly_types/src/type_level_dsl.rs:6928-6933 | crates/pyrefly_types/src/type_level_dsl.rs:7057-7062 — both copies are in the same file, so extract the block into 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) scripts/issue_ranker/report_formatter.py:24 — scripts/issue_ranker/report_formatter.py:24-35 | scripts/issue_ranker/report_formatter.py:187-192 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. 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, `scripts/issue_ranker/report_formatter.py:22` calls `get` and `scripts/issue_ranker/report_formatter.py:185` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (6 lines × 2) tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations_runnable.py:374 — tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations_runnable.py:374-379 | 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.
D1 · Cyclomatic Complexity · pyrefly · ×22
  • 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 37) pyrefly/lib/commands/coverage/collect.rs:755 — pyrefly::lib::commands::coverage::collect::parse_functions has cyclomatic complexity 37 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • 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::binding::function::function_last_expressions::f (cyclomatic 28) pyrefly/lib/binding/function.rs:980 — 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::error::suppress::remove_unused_ignores_from_serialized (cyclomatic 27) pyrefly/lib/error/suppress.rs:636 — pyrefly::lib::error::suppress::remove_unused_ignores_from_serialized 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::lib::commands::coverage::collect::parse_variables (cyclomatic 26) pyrefly/lib/commands/coverage/collect.rs:462 — pyrefly::lib::commands::coverage::collect::parse_variables has cyclomatic complexity 26 (threshold 15). Of this number, 17 points are the body's own statements and 9 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::module::finder::find_import_with_mode (cyclomatic 24) pyrefly/lib/module/finder.rs:592 — pyrefly::lib::module::finder::find_import_with_mode has cyclomatic complexity 24 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
  • pyrefly::lib::commands::coverage::collect::collect_module_reports (cyclomatic 22) pyrefly/lib/commands/coverage/collect.rs:1613 — 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::alt::class::variance_inference::on_type (cyclomatic 22) pyrefly/lib/alt/class/variance_inference.rs:374 — 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::lsp::non_wasm::server::dispatch_lsp_events (cyclomatic 22) pyrefly/lib/lsp/non_wasm/server.rs:1436 — 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 21) pyrefly/lib/stubgen/extract.rs:173 — pyrefly::lib::stubgen::extract::extract_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.
  • 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::error::suppress::add_suppressions (cyclomatic 20) pyrefly/lib/error/suppress.rs:342 — pyrefly::lib::error::suppress::add_suppressions has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • pyrefly::lib::report::cinderx::collect::collect_call_contextual_types (cyclomatic 20) pyrefly/lib/report/cinderx/collect.rs: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::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::semantic_tokens::collect_disabled_ranges_from_stmt (cyclomatic 17) pyrefly/lib/state/semantic_tokens.rs:739 — 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::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::commands::coverage::collect::parse_instance_attrs (cyclomatic 16) pyrefly/lib/commands/coverage/collect.rs:657 — pyrefly::lib::commands::coverage::collect::parse_instance_attrs has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • pyrefly::lib::lsp::non_wasm::document_symbols::recurse_stmt_adding_symbols (cyclomatic 16) pyrefly/lib/lsp/non_wasm/document_symbols.rs:195 — pyrefly::lib::lsp::non_wasm::document_symbols::recurse_stmt_adding_symbols has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • pyrefly::lib::lsp::wasm::hover::get_hover_with_verbosity (cyclomatic 16) pyrefly/lib/lsp/wasm/hover.rs:930 — pyrefly::lib::lsp::wasm::hover::get_hover_with_verbosity 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.
D3 · God Classes · TooManyMethods · ×22
  • TooManyMethods: AnswersSolver pyrefly/lib/alt/answers_solver.rs:2070 — TooManyMethods — 1175 methods, declared across 49 files: alt/solve.rs (147), alt/expr.rs (103), class/class_field.rs (94), alt/answers_solver.rs (89), +45 more file(s). The bar is 30 methods; this is 1145 over it, 39.17× the bar. That list is where to read them, not a suggestion to split the file: the members belong to the type wherever they are declared, so moving them between files leaves the count unchanged. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: Transaction pyrefly/lib/state/state.rs:746 — TooManyMethods — 289 methods, declared across 13 files: state/lsp.rs (115), state/state.rs (84), lsp/dict_completions.rs (29), wasm/completion.rs (22), +9 more file(s). The bar is 30 methods; this is 259 over it, 9.63× 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:286 — TooManyMethods — 210 methods, declared across 13 files: binding/bindings.rs (77), binding/class.rs (22), binding/expr.rs (21), binding/stmt.rs (20), +9 more file(s). The bar is 30 methods; this is 180 over it, 7.00× 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:1597 — TooManyMethods — 131 methods. The bar is 30 methods; this is 101 over it, 4.37× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: Type crates/pyrefly_types/src/types.rs:890 — TooManyMethods — 112 methods, declared across 3 files: src/types.rs (99), src/boundary.rs (9), src/display.rs (4). The bar is 30 methods; this is 82 over it, 3.73× 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:1112 — TooManyMethods — 111 methods. The bar is 30 methods; this is 81 over it, 3.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: 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:545 — TooManyMethods — 76 methods. The bar is 30 methods; this is 46 over it, 2.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: 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: Subset pyrefly/lib/solver/solver.rs:3282 — 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: TestClient crates/pyrefly_lsp_test/src/object_model.rs:258 — TooManyMethods — 62 methods. The bar is 30 methods; this is 32 over it, 2.07× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: ConfigFile crates/pyrefly_config/src/config.rs:579 — 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: ModuleName crates/pyrefly_python/src/module_name.rs:39 — TooManyMethods — 52 methods. The bar is 30 methods; this is 22 over it, 1.73× 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:1937 — TooManyMethods — 49 methods. The bar is 30 methods; this is 19 over it, 1.63× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: 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:339 — TooManyMethods — 43 methods. The bar is 30 methods; this is 13 over it, 1.43× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • 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: 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: Ast crates/pyrefly_python/src/ast.rs:62 — TooManyMethods — 34 methods. The bar is 30 methods; this is 4 over it, 1.13× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: Bindings pyrefly/lib/binding/bindings.rs:211 — 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:1296 — 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.
D3 · God Classes · FunctionTooLong · ×22
  • 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 210 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 110 over it, 2.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: 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 191 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 91 over it, 1.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.
  • 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: 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::lib::lsp::wasm::hover::get_hover_with_verbosity pyrefly/lib/lsp/wasm/hover.rs:930 — FunctionTooLong — pyrefly::lib::lsp::wasm::hover::get_hover_with_verbosity runs 130 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 30 over it, 1.30× 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::error::suppress::add_suppressions pyrefly/lib/error/suppress.rs:342 — FunctionTooLong — pyrefly::lib::error::suppress::add_suppressions 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: 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::einops::evaluate_einops_pattern crates/pyrefly_types/src/einops.rs:374 — FunctionTooLong — pyrefly_types::einops::evaluate_einops_pattern runs 108 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 8 over it, 1.08× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: pyrefly::lib::lsp::non_wasm::server::capabilities pyrefly/lib/lsp/non_wasm/server.rs:1579 — FunctionTooLong — pyrefly::lib::lsp::non_wasm::server::capabilities runs 107 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 7 over it, 1.07× 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::module::finder::find_import_with_mode pyrefly/lib/module/finder.rs:592 — FunctionTooLong — pyrefly::lib::module::finder::find_import_with_mode runs 104 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 4 over it, 1.04× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • 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.
D3 · God Classes · ClassTooLong · ×19
  • ClassTooLong: Server pyrefly/lib/lsp/non_wasm/server.rs:1112 — ClassTooLong — 3894 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 111 methods, 3 blocks, lines 1112-7419. The bar is 400 significant lines; this is 3494 over it, 9.74× 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 — 2043 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-4459. The bar is 400 significant lines; this is 1643 over it, 5.11× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: StructurallyValidatedTypeShapeDslFunction crates/pyrefly_types/src/type_level_dsl.rs:922 — ClassTooLong — 1377 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 922-8233. The bar is 400 significant lines; this is 977 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: Solver pyrefly/lib/solver/solver.rs:545 — ClassTooLong — 1310 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 76 methods, 3 blocks, lines 545-2630. The bar is 400 significant lines; this is 910 over it, 3.28× 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:746 — ClassTooLong — 1198 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 289 methods, 2 blocks, lines 746-2735. The bar is 400 significant lines; this is 798 over it, 3.00× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: Scopes pyrefly/lib/binding/scope.rs:1597 — ClassTooLong — 1126 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 131 methods, 2 blocks, lines 1597-3661. The bar is 400 significant lines; this is 726 over it, 2.82× 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 — 1115 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-1768. The bar is 400 significant lines; this is 715 over it, 2.79× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: BindingsBuilder pyrefly/lib/binding/bindings.rs:286 — ClassTooLong — 1089 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 210 methods, 5 blocks, lines 286-2925. The bar is 400 significant lines; this is 689 over it, 2.72× 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 — 1066 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 1175 methods, 2 blocks, lines 2070-4034. The bar is 400 significant lines; this is 666 over it, 2.67× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: ConfigFile crates/pyrefly_config/src/config.rs:579 — ClassTooLong — 876 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 53 methods, 5 blocks, lines 579-2184. The bar is 400 significant lines; this is 476 over it, 2.19× 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:890 — ClassTooLong — 860 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 112 methods, 4 blocks, lines 890-2373. The bar is 400 significant lines; this is 460 over it, 2.15× 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:258 — ClassTooLong — 708 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 62 methods, 2 blocks, lines 258-1294. The bar is 400 significant lines; this is 308 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.
  • ClassTooLong: Subset pyrefly/lib/solver/solver.rs:3282 — ClassTooLong — 593 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 3282-4197. The bar is 400 significant lines; this is 193 over it, 1.48× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: ClassField pyrefly/lib/alt/class/class_field.rs:339 — ClassTooLong — 593 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 43 methods, 2 blocks, lines 421-1239. The bar is 400 significant lines; this is 193 over it, 1.48× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: Query pyrefly/lib/query.rs:151 — ClassTooLong — 501 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 151-1751. The bar is 400 significant lines; this is 101 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: CalleesWithLocation pyrefly/lib/query.rs:365 — 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 365-1056. 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: CheckArgs pyrefly/lib/commands/check.rs:224 — ClassTooLong — 496 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 224-2303. The bar is 400 significant lines; this is 96 over it, 1.24× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: LspInteraction crates/pyrefly_lsp_test/src/object_model.rs:1296 — 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 1296-2046. The bar is 400 significant lines; this is 29 over it, 1.07× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: Binding pyrefly/lib/binding/binding.rs:2494 — ClassTooLong — 416 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 2494-3140. The bar is 400 significant lines; this is 16 over it, 1.04× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
D4 · Code Duplication · Duplicated block (9 lines × 2) · ×19
  • Duplicated block (9 lines × 2) crates/pyrefly_types/src/type_level_dsl.rs:3599 — crates/pyrefly_types/src/type_level_dsl.rs:3599-3607 | crates/pyrefly_types/src/type_level_dsl.rs:3700-3708 — both copies are in the same file, so extract the block into 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:7553 — crates/pyrefly_types/src/type_level_dsl.rs:7553-7561 | crates/pyrefly_types/src/type_level_dsl.rs:7591-7599 — both copies are in the same file, so extract the block into 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:871 — pyrefly/lib/alt/class/class_field.rs:871-879 | pyrefly/lib/alt/class/class_field.rs:883-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 (9 lines × 2) pyrefly/lib/alt/narrow.rs:1376 — pyrefly/lib/alt/narrow.rs:1376-1384 | pyrefly/lib/alt/narrow.rs:1398-1406 — both copies are in the same file, so extract the block into 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/overload.rs:956 — pyrefly/lib/alt/overload.rs:956-964 | pyrefly/lib/alt/overload.rs:965-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 (9 lines × 2) pyrefly/lib/alt/solve.rs:1222 — pyrefly/lib/alt/solve.rs:1222-1230 | pyrefly/lib/alt/solve.rs:1431-1439 — both copies are in the same file, so extract the block into 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/solve.rs:1251 — pyrefly/lib/alt/solve.rs:1251-1259 | pyrefly/lib/alt/solve.rs:1455-1463 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • 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:1191-1199 — 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/semantic_tokens.rs:573 — pyrefly/lib/state/semantic_tokens.rs:573-581 | pyrefly/lib/state/semantic_tokens.rs:582-590 — both copies are in the same file, so extract the block into 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/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/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:3464 — crates/pyrefly_types/src/type_level_dsl.rs:3464-3472 | crates/pyrefly_types/src/type_level_dsl.rs:3514-3522 — both copies are in the same file, so extract the block into 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.
D1 · Cyclomatic Complexity · BindingsBuilder · ×17
  • BindingsBuilder::stmt_impl (cyclomatic 157) pyrefly/lib/binding/stmt.rs:847 — BindingsBuilder::stmt_impl has cyclomatic complexity 157 (threshold 15). To reduce it, separate the cases: extract each independent 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 78) pyrefly/lib/binding/expr.rs:712 — BindingsBuilder::ensure_expr has cyclomatic complexity 78 (threshold 15). Of this number, 77 points are the body's own statements and 1 belongs to one function item inside it that branches. To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
  • 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:1282 — 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:871 — 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:245 — 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:692 — 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 23) pyrefly/lib/binding/scope.rs:3903 — BindingsBuilder::merged_flow_info has cyclomatic complexity 23 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • BindingsBuilder::bind_single_name_assign (cyclomatic 20) pyrefly/lib/binding/target.rs:651 — BindingsBuilder::bind_single_name_assign has cyclomatic complexity 20 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
  • BindingsBuilder::ensure_name_impl (cyclomatic 19) pyrefly/lib/binding/expr.rs:359 — BindingsBuilder::ensure_name_impl 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::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:605 — 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:543 — 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::stmts (cyclomatic 17) pyrefly/lib/binding/bindings.rs:1321 — BindingsBuilder::stmts 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::merge_flow (cyclomatic 16) pyrefly/lib/binding/scope.rs:4118 — BindingsBuilder::merge_flow 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.
  • BindingsBuilder::typealiastype_from_call (cyclomatic 16) pyrefly/lib/binding/stmt.rs:580 — 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.
D4 · Code Duplication · Duplicated block (11 lines × 2) · ×16
  • Duplicated block (11 lines × 2) crates/pyrefly_lsp_test/src/object_model.rs:544 — crates/pyrefly_lsp_test/src/object_model.rs:544-554 | crates/pyrefly_lsp_test/src/object_model.rs:585-595 — both copies are in the same file, so extract the block into 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/solve.rs:1435 — pyrefly/lib/alt/solve.rs:1435-1445 | pyrefly/lib/alt/solve.rs:1459-1469 — both copies are in the same file, so extract the block into 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:355 — pyrefly/lib/export/exports.rs:355-365 | pyrefly/lib/export/exports.rs:378-388 — both copies are in the same file, so extract the block into 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:4129 — pyrefly/lib/lsp/non_wasm/server.rs:4129-4139 | pyrefly/lib/lsp/non_wasm/server.rs:4205-4215 — both copies are in the same file, so extract the block into 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/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/state/lsp.rs:3375 — pyrefly/lib/state/lsp.rs:3375-3385 | pyrefly/lib/state/lsp.rs:3387-3397 — both copies are in the same file, so extract the block into 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/stubgen/extract.rs:356 — pyrefly/lib/stubgen/extract.rs:356-366 | pyrefly/lib/stubgen/extract.rs:385-395 — both copies are in the same file, so extract the block into 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/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:2114 — pyrefly/lib/binding/bindings.rs:2114-2124 | pyrefly/lib/binding/bindings.rs:2125-2135 — both copies are in the same file, so extract the block into 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:2478 — crates/pyrefly_types/src/type_level_dsl.rs:2478-2488 | crates/pyrefly_types/src/type_level_dsl.rs:4972-4982 — both copies are in the same file, so extract the block into 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.
D4 · Code Duplication · Duplicated block (12 lines × 2) · ×15
  • Duplicated block (12 lines × 2) crates/pyrefly_types/src/display.rs:1276 — crates/pyrefly_types/src/display.rs:1276-1287 | crates/pyrefly_types/src/display.rs:1492-1503 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (12 lines × 2) crates/pyrefly_types/src/einsum.rs:239 — crates/pyrefly_types/src/einsum.rs:239-250 | crates/pyrefly_types/src/einsum.rs:271-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 (12 lines × 2) crates/pyrefly_types/src/type_level_dsl.rs:6542 — crates/pyrefly_types/src/type_level_dsl.rs:6542-6553 | crates/pyrefly_types/src/type_level_dsl.rs:6565-6576 — both copies are in the same file, so extract the block into 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:7076 — crates/pyrefly_types/src/type_level_dsl.rs:7076-7087 | crates/pyrefly_types/src/type_level_dsl.rs:7153-7164 — both copies are in the same file, so extract the block into 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/alt/function.rs:2772 — pyrefly/lib/alt/function.rs:2772-2783 | pyrefly/lib/alt/function.rs:2822-2833 — both copies are in the same file, so extract the block into 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:1029 — pyrefly/lib/state/lsp.rs:1029-1040 | pyrefly/lib/state/lsp.rs:1063-1074 — both copies are in the same file, so extract the block into 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:3622 — pyrefly/lib/state/lsp.rs:3622-3633 | pyrefly/lib/state/lsp.rs:3649-3660 — both copies are in the same file, so extract the block into 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:500 — tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations_runnable.py:500-511 | 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.
D4 · Code Duplication · Duplicated block (10 lines × 2) · ×15
  • Duplicated block (10 lines × 2) crates/pyrefly_types/src/display.rs:1495 — crates/pyrefly_types/src/display.rs:1495-1504 | crates/pyrefly_types/src/display.rs:1520-1529 — both copies are in the same file, so extract the block into 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:2574 — crates/pyrefly_types/src/type_level_dsl.rs:2574-2583 | crates/pyrefly_types/src/type_level_dsl.rs:2838-2847 — both copies are in the same file, so extract the block into 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:788 — pyrefly/lib/commands/check.rs:788-797 | pyrefly/lib/commands/check.rs:804-813 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (10 lines × 2) pyrefly/lib/lsp/non_wasm/server.rs:4761 — pyrefly/lib/lsp/non_wasm/server.rs:4761-4770 | pyrefly/lib/lsp/non_wasm/server.rs:4788-4797 — both copies are in the same file, so extract the block into 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:3652 — pyrefly/lib/solver/solver.rs:3652-3661 | pyrefly/lib/solver/solver.rs:3663-3672 — both copies are in the same file, so extract the block into 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:925 — pyrefly/lib/solver/subset.rs:925-934 | pyrefly/lib/solver/subset.rs:939-948 — both copies are in the same file, so extract the block into 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:503 — pyrefly/lib/state/lsp/dict_completions.rs:503-512 | pyrefly/lib/state/lsp/dict_completions.rs:701-710 — both copies are in the same file, so extract the block into 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:602 — pyrefly/lib/stubgen/extract.rs:602-611 | pyrefly/lib/stubgen/extract.rs:620-629 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (10 lines × 2) pyrefly/lib/alt/expr.rs:1241 — pyrefly/lib/alt/expr.rs:1241-1252 | pyrefly/lib/alt/expr.rs:1279-1288 — both copies are in the same file, so extract the block into 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:2036 — pyrefly/lib/binding/stmt.rs:2036-2045 | pyrefly/lib/binding/stmt.rs:2050-2059 — both copies are in the same file, so extract the block into 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:945 — pyrefly/lib/tsp/type_conversion.rs:945-954 | pyrefly/lib/tsp/type_conversion.rs:960-969 — both copies are in the same file, so extract the block into 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:485 — pyrefly/lib/binding/narrow.rs:485-494 | pyrefly/lib/binding/narrow.rs:496-505 — both copies are in the same file, so extract the block into 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:484 — tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations_runnable.py:484-493 | 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.
D4 · Code Duplication · Duplicated block (14 lines × 2) · ×13
  • 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:2867 — pyrefly/lib/alt/attr.rs:2867-2880 | pyrefly/lib/alt/attr.rs:2891-2904 — both copies are in the same file, so extract the block into 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:3220 — pyrefly/lib/alt/attr.rs:3220-3233 | pyrefly/lib/alt/attr.rs:3236-3250 — both copies are in the same file, so extract the block into 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:496 — pyrefly/lib/alt/class/dataclass.rs:496-509 | pyrefly/lib/alt/functools.rs:57-71 — 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/lsp/wasm/completion.rs:771 — pyrefly/lib/lsp/wasm/completion.rs:771-784 | pyrefly/lib/lsp/wasm/completion.rs:803-816 — both copies are in the same file, so extract the block into 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:1116 — pyrefly/lib/solver/solver.rs:1116-1129 | pyrefly/lib/solver/solver.rs:1180-1193 — both copies are in the same file, so extract the block into 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/function.rs:2822 — pyrefly/lib/alt/function.rs:2822-2835 | pyrefly/lib/alt/function.rs:2864-2877 — both copies are in the same file, so extract the block into 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) scripts/issue_ranker/passes/primer_impact.py:247 — scripts/issue_ranker/passes/primer_impact.py:247-260 | scripts/issue_ranker/passes/primer_impact.py:270-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 (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.
D1 · Cyclomatic Complexity · Transaction · ×11
  • 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::completion_sorted_opt_with_incomplete (cyclomatic 47) pyrefly/lib/lsp/wasm/completion.rs:1068 — 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::find_definition (cyclomatic 46) pyrefly/lib/state/lsp.rs:2676 — Transaction::find_definition has cyclomatic complexity 46 (threshold 15). To reduce it, separate the cases: extract each independent 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 39) pyrefly/lib/state/lsp.rs:3328 — Transaction::local_quickfix_code_actions_sorted 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.
  • Transaction::demand (cyclomatic 36) pyrefly/lib/state/state.rs:1457 — 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:2244 — 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::dict_literal_string_literal_at (cyclomatic 20) pyrefly/lib/state/lsp/dict_completions.rs:626 — 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::clean (cyclomatic 20) pyrefly/lib/state/state.rs:1292 — Transaction::clean 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:684 — 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:942 — 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.
D1 · Cyclomatic Complexity · DslValidator · ×10
  • DslValidator::validate_condition (cyclomatic 79) crates/pyrefly_types/src/type_level_dsl.rs:4461 — 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 49) crates/pyrefly_types/src/type_level_dsl.rs:4946 — DslValidator::validate_return 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.
  • DslValidator::validate_dimension (cyclomatic 28) crates/pyrefly_types/src/type_level_dsl.rs:2492 — DslValidator::validate_dimension has cyclomatic complexity 28 (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_generator_source (cyclomatic 25) crates/pyrefly_types/src/type_level_dsl.rs:3086 — 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:3284 — 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::validate_assignment_value (cyclomatic 24) crates/pyrefly_types/src/type_level_dsl.rs:3953 — DslValidator::validate_assignment_value 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.
  • DslValidator::collect_integer_expression_sources (cyclomatic 20) crates/pyrefly_types/src/type_level_dsl.rs:2168 — DslValidator::collect_integer_expression_sources has cyclomatic complexity 20 (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 18) crates/pyrefly_types/src/type_level_dsl.rs:2802 — DslValidator::validate_flag_int 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.
  • DslValidator::validate_flag_slot (cyclomatic 16) crates/pyrefly_types/src/type_level_dsl.rs:2708 — 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.
  • DslValidator::validate_int_tuple_expression (cyclomatic 16) crates/pyrefly_types/src/type_level_dsl.rs:3829 — DslValidator::validate_int_tuple_expression 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.
D2 · Cognitive Complexity · Server · ×10
  • Server::process_event (cognitive 263) pyrefly/lib/lsp/non_wasm/server.rs:2054 — Server::process_event has cognitive complexity 263 (threshold 15). Drivers by points: if/else 84 (170 pts), match/switch 21 (81 pts), boolean chains 9, loops 1 (3 pts) (nesting depth added 148). 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:4964 — 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:4181 — 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:6821 — 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:3393 — 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::get_diag_if_shown (cognitive 22) pyrefly/lib/lsp/non_wasm/server.rs:3190 — 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:4446 — 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:4828 — 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:5382 — 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:6328 — 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/microtorch/run_pyrefly.py:24 — tensor-shapes/microtorch/run_pyrefly.py:24-50 | tensor-shapes/pyrefly-einops-stubs/run_pyrefly.py:30-80 | tensor-shapes/pyrefly-jax-stubs/run_pyrefly.py:30-83 | 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:104 — tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:104-121 | 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:494 — tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:494-524 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations.py:499-529 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations_runnable.py:465-495 | 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/gptfast.py:227 — tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:227-247 | 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:278 — tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:278-295 | 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/nanogpt.py:75 — tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:75-101 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations.py:77-103 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations_runnable.py:77-100 | 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:336-341 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations_runnable.py:288-293 | 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:397-404 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations_runnable.py:337-344 | 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:408-465 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations_runnable.py:348-405 | 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:502-515 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations_runnable.py:442-455 | 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.
D2 · Cognitive Complexity · Subset · ×9
  • Subset::is_subset_eq_no_recursive_check (cognitive 127) pyrefly/lib/solver/subset.rs:1877 — Subset::is_subset_eq_no_recursive_check has cognitive complexity 127 (threshold 15). Drivers by points: if/else 37 (60 pts), boolean chains 44, match/switch 10 (21 pts), loops 1 (2 pts) (nesting depth added 35). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Subset::is_subset_eq_var (cognitive 94) pyrefly/lib/solver/solver.rs:3727 — Subset::is_subset_eq_var has cognitive complexity 94 (threshold 15). Drivers by points: if/else 31 (68 pts), match/switch 9 (21 pts), boolean chains 5 (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.
  • Subset::is_subset_param_list_impl (cognitive 91) pyrefly/lib/solver/subset.rs:259 — 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 46) pyrefly/lib/solver/subset.rs:3227 — Subset::bind_tensor_dimensions has cognitive complexity 46 (threshold 15). Drivers by points: if/else 12 (25 pts), loops 7 (14 pts), boolean chains 5, match/switch 2 (nesting depth added 20). Of this number, 45 points are the body's own statements and 1 belongs 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.
  • Subset::is_subset_eq_quantified (cognitive 39) pyrefly/lib/solver/solver.rs:3563 — 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:844 — 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 23) pyrefly/lib/solver/subset.rs:2963 — Subset::check_targs has cognitive complexity 23 (threshold 15). Drivers by points: if/else 7 (10 pts), boolean chains 7, match/switch 2 (5 pts), 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.
  • Subset::is_subset_overload (cognitive 22) pyrefly/lib/solver/subset.rs:1590 — 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:758 — Subset::is_subset_protocol_inner has cognitive complexity 20 (threshold 15). Drivers by points: if/else 8 (12 pts), boolean chains 5, match/switch 1 (2 pts), loops 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D4 · Code Duplication · Duplicated block (15 lines × 2) · ×8
  • 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:2099 — pyrefly/lib/alt/attr.rs:2099-2113 | pyrefly/lib/alt/attr.rs:2200-2214 — both copies are in the same file, so extract the block into 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:2112 — pyrefly/lib/alt/call.rs:2112-2126 | pyrefly/lib/alt/call.rs:2136-2150 — both copies are in the same file, so extract the block into 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/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:2008 — crates/pyrefly_lsp_test/src/object_model.rs:2008-2022 | crates/pyrefly_lsp_test/src/object_model.rs:2031-2045 — both copies are in the same file, so extract the block into 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:448 — tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations_runnable.py:448-462 | 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:448` it does not close everything it opens, so those exact lines 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.
D1 · Cyclomatic Complexity · Subset · ×7
  • Subset::is_subset_eq_no_recursive_check (cyclomatic 240) pyrefly/lib/solver/subset.rs:1877 — Subset::is_subset_eq_no_recursive_check has cyclomatic complexity 240 (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:259 — 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 54) pyrefly/lib/solver/solver.rs:3727 — Subset::is_subset_eq_var has cyclomatic complexity 54 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • Subset::is_subset_tuple (cyclomatic 31) pyrefly/lib/solver/subset.rs:844 — 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::bind_tensor_dimensions (cyclomatic 29) pyrefly/lib/solver/subset.rs:3227 — Subset::bind_tensor_dimensions has cyclomatic complexity 29 (threshold 15). Of this number, 27 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_eq_quantified (cyclomatic 21) pyrefly/lib/solver/solver.rs:3563 — 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 19) pyrefly/lib/solver/subset.rs:2963 — Subset::check_targs has cyclomatic complexity 19 (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.
D2 · Cognitive Complexity · DslValidator · ×7
  • DslValidator::validate_condition (cognitive 107) crates/pyrefly_types/src/type_level_dsl.rs:4461 — 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:4946 — 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 30) crates/pyrefly_types/src/type_level_dsl.rs:2168 — DslValidator::collect_integer_expression_sources has cognitive complexity 30 (threshold 15). Drivers by points: if/else 5 (12 pts), loops 3 (11 pts), match/switch 2 (4 pts), boolean chains 3 (nesting depth added 17). 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:3086 — 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:3284 — 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_dimension (cognitive 19) crates/pyrefly_types/src/type_level_dsl.rs:2492 — 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.
  • DslValidator::validate_assignment_value (cognitive 17) crates/pyrefly_types/src/type_level_dsl.rs:3953 — DslValidator::validate_assignment_value has cognitive complexity 17 (threshold 15). Drivers by points: if/else 9 (14 pts), match/switch 2 (3 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D4 · Code Duplication · Duplicated block (8 lines × 3) · ×7
  • Duplicated block (8 lines × 3) crates/pyrefly_lsp_test/src/object_model.rs:693 — crates/pyrefly_lsp_test/src/object_model.rs:693-700 | crates/pyrefly_lsp_test/src/object_model.rs:704-711 | crates/pyrefly_lsp_test/src/object_model.rs:715-722 — 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/narrow.rs:2044 — pyrefly/lib/alt/narrow.rs:2044-2051 | pyrefly/lib/alt/narrow.rs:2072-2079 | pyrefly/lib/alt/narrow.rs:2104-2111 — 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:443-450 | 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:570-577 | 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:215-222 | 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:345 — tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:345-352 | 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.
D3 · God Classes · TooManyFields · ×6
  • 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 — 59 stored fields beside 1 method. The bar is 30 stored fields; this is 29 over it, 1.97× 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:1112 — TooManyFields — 49 stored fields beside 111 methods. The bar is 30 stored fields; this is 19 over it, 1.63× 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:286 — TooManyFields — 34 stored fields beside 210 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.
  • TooManyFields: ConfigFile crates/pyrefly_config/src/config.rs:579 — TooManyFields — 31 stored fields beside 53 methods. The bar is 30 stored fields; this is 1 over it, 1.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.
D35 · Change Coupling · Change coupling · ×6
  • Change coupling: traits.rs ↔ table.rs pyrefly/lib/alt/traits.rs — `pyrefly/lib/alt/traits.rs` and `pyrefly/lib/binding/table.rs` change together 100% of the time (11 of the 11 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 11 shared commits counted here, the most recent 3 are `19eb5f49` Add per-module Django relationship summaries; `4ebb45d0` Add KeyClassDisjointBase scaffolding; `24eb9c3e` Merge class-level diagnostic check bindings — run `git show` on any of them.
  • Change coupling: buck_check.rs ↔ map_db.rs crates/pyrefly_build/src/source_db/buck_check.rs — `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: subset.rs ↔ type_order.rs pyrefly/lib/solver/subset.rs — `pyrefly/lib/solver/subset.rs` and `pyrefly/lib/solver/type_order.rs` change together 78% of the time (21 of the 27 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 21 shared commits counted here, the most recent 3 are `647610b5` Guard against recursive protocol member checking in __getattr__ self …; `ee9a4f85` fix enum.Flag unions incorrectly do not match typing.self in (class)m…; `5a29260f` Simplify `constructor_to_callable` — run `git show` on any of them.
  • Change coupling: call_graph.rs ↔ override_graph.rs pyrefly/lib/report/pysa/call_graph.rs — `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: solve.rs ↔ ide.rs pyrefly/lib/alt/solve.rs — `pyrefly/lib/alt/solve.rs` and `pyrefly/lib/state/ide.rs` change together 56% of the time (24 of the 43 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 24 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.
  • Change coupling: type_table.rs ↔ convert.rs pyrefly/lib/query/type_table.rs — `pyrefly/lib/query/type_table.rs` and `pyrefly/lib/report/cinderx/convert.rs` change together 55% of the time (11 of the 20 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 11 shared commits counted here, the most recent 3 are `e916f286` Delete the CallableResidual type; `702f0d12` Add Type::Overloaded; `47ef3b51` Add plumbing for literal-capturing Flag-bound type vars — run `git show` on any of them.
D4 · Code Duplication · Duplicated block (16 lines × 2) · ×6
  • Duplicated block (16 lines × 2) crates/pyrefly_build/src/query.rs:53 — crates/pyrefly_build/src/query.rs:53-68 | crates/pyrefly_build/src/source_db/buck_check.rs:110-125 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (16 lines × 2) pyrefly/lib/binding/narrow.rs:793 — pyrefly/lib/binding/narrow.rs:793-808 | pyrefly/lib/binding/narrow.rs:826-841 — both copies are in the same file, so extract the block into 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:2037 — pyrefly/lib/state/lsp.rs:2037-2052 | pyrefly/lib/state/lsp.rs:2068-2083 — both copies are in the same file, so extract the block into 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:98 — pyrefly/lib/alt/special_calls.rs:98-113 | pyrefly/lib/alt/special_calls.rs:201-216 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • 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.
D4 · Code Duplication · Duplicated block (7 lines × 3) · ×6
  • Duplicated block (7 lines × 3) pyrefly/lib/alt/attr.rs:2115 — pyrefly/lib/alt/attr.rs:2115-2121 | pyrefly/lib/alt/attr.rs:2135-2141 | pyrefly/lib/alt/attr.rs:2216-2222 — 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) 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) 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:393-399 | 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:202-208 | 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:189-195 | 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.
D4 · Code Duplication · Duplicated block (9 lines × 3) · ×5
  • 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:336 — pyrefly/lib/stubgen/extract.rs:336-344 | pyrefly/lib/stubgen/extract.rs:355-363 | pyrefly/lib/stubgen/extract.rs:384-392 — 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/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/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:6015 — pyrefly/lib/lsp/non_wasm/server.rs:6015-6023 | pyrefly/lib/lsp/non_wasm/server.rs:6040-6048 | pyrefly/lib/lsp/non_wasm/server.rs:6068-6076 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
D4 · Code Duplication · Duplicated block (6 lines × 3) · ×5
  • 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:6890 — crates/pyrefly_types/src/type_level_dsl.rs:6890-6895 | crates/pyrefly_types/src/type_level_dsl.rs:7488-7493 | crates/pyrefly_types/src/type_level_dsl.rs:7519-7524 — 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:352-357 | 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:416-421 | 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.
D4 · Code Duplication · Duplicated block (5 lines × 3) · ×5
  • Duplicated block (5 lines × 3) pyrefly/lib/lsp/non_wasm/server.rs:6010 — pyrefly/lib/lsp/non_wasm/server.rs:6010-6014 | pyrefly/lib/lsp/non_wasm/server.rs:6035-6039 | pyrefly/lib/lsp/non_wasm/server.rs:6063-6067 — 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:453-457 | 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:77-81 | 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:36 — tensor-shapes/pyrefly-torch-stubs/examples/nanogpt.py:36-40 | 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.
D1 · Cyclomatic Complexity · StructurallyValidatedTypeShapeDslFunction · ×4
  • StructurallyValidatedTypeShapeDslFunction::evaluate_expression (cyclomatic 247) crates/pyrefly_types/src/type_level_dsl.rs:6770 — StructurallyValidatedTypeShapeDslFunction::evaluate_expression has cyclomatic complexity 247 (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:7795 — 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:6510 — 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:7664 — 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.
D1 · Cyclomatic Complexity · Server · ×4
  • Server::process_event (cyclomatic 128) pyrefly/lib/lsp/non_wasm/server.rs:2054 — Server::process_event has cyclomatic complexity 128 (threshold 15). To reduce it, separate the cases: extract each independent 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:4964 — 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:4181 — 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:3393 — 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.
D17 · Explicit Debt · HackComment · ×4
  • HackComment pyrefly/lib/alt/callable.rs:126 — // 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:2327 — // 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/call.rs:2009 — // 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/types/class_bases.rs:374 — // 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.
D2 · Cognitive Complexity · StructurallyValidatedTypeShapeDslFunction · ×4
  • StructurallyValidatedTypeShapeDslFunction::evaluate_expression (cognitive 250) crates/pyrefly_types/src/type_level_dsl.rs:6770 — StructurallyValidatedTypeShapeDslFunction::evaluate_expression has cognitive complexity 250 (threshold 15). Drivers by points: match/switch 60 (127 pts), if/else 53 (108 pts), loops 5 (10 pts), boolean chains 5 (nesting depth added 127). 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:7795 — 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:6510 — 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:7664 — 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.
D2 · Cognitive Complexity · Solver · ×4
  • Solver::finish_quantified_with_captures (cognitive 70) pyrefly/lib/solver/solver.rs:2103 — Solver::finish_quantified_with_captures has cognitive complexity 70 (threshold 15). Drivers by points: if/else 22 (46 pts), match/switch 5 (10 pts), loops 6 (9 pts), boolean chains 5 (nesting depth added 32). To reduce it, split the body into named stages: move each independent 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:1207 — 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:1306 — 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 18) pyrefly/lib/solver/solver.rs:1775 — Solver::build_overload_rows has cognitive complexity 18 (threshold 15). Drivers by points: if/else 4 (9 pts), loops 3 (6 pts), match/switch 1 (2 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.
D2 · Cognitive Complexity · pyrefly_build · ×4
  • pyrefly_build::module_resolver::find_one_part_prefix (cognitive 62) crates/pyrefly_build/src/module_resolver.rs:768 — pyrefly_build::module_resolver::find_one_part_prefix has cognitive complexity 62 (threshold 15). Drivers by points: if/else 11 (43 pts), loops 4 (11 pts), match/switch 1 (6 pts), boolean chains 2 (nesting depth added 44). 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 44) crates/pyrefly_build/src/module_resolver.rs:360 — pyrefly_build::module_resolver::find_one_part_in_root has cognitive complexity 44 (threshold 15). Drivers by points: if/else 18 (33 pts), loops 4 (6 pts), match/switch 1 (4 pts), boolean chains 1 (nesting depth added 20). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • pyrefly_build::module_resolver::find_module_prefixes (cognitive 19) crates/pyrefly_build/src/module_resolver.rs:841 — 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:459 — 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.
D2 · Cognitive Complexity · pyrefly_python · ×4
  • 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:525 — 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:652 — 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:434 — pyrefly_python::docstring::parse_sphinx_params has cognitive complexity 23 (threshold 15). Drivers by points: if/else 8 (19 pts), match/switch 1 (3 pts), loops 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D4 · Code Duplication · Duplicated block (11 lines × 3) · ×4
  • Duplicated block (11 lines × 3) crates/pyrefly_lsp_test/src/object_model.rs:423 — crates/pyrefly_lsp_test/src/object_model.rs:423-433 | crates/pyrefly_lsp_test/src/object_model.rs:441-451 | crates/pyrefly_lsp_test/src/object_model.rs:459-469 — 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:513-523 — 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:382-392 | 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:539-549 | 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.
D4 · Code Duplication · Duplicated block (10 lines × 3) · ×4
  • Duplicated block (10 lines × 3) crates/pyrefly_types/src/type_level_dsl.rs:3580 — crates/pyrefly_types/src/type_level_dsl.rs:3580-3589 | crates/pyrefly_types/src/type_level_dsl.rs:3651-3660 | crates/pyrefly_types/src/type_level_dsl.rs:3681-3690 — 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) crates/pyrefly_types/src/type_level_dsl.rs:6913 — crates/pyrefly_types/src/type_level_dsl.rs:6913-6922 | crates/pyrefly_types/src/type_level_dsl.rs:6974-6983 | crates/pyrefly_types/src/type_level_dsl.rs:7030-7039 — 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:257 — tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:257-266 | 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:257` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (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:432-441 | 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.
D1 · Cyclomatic Complexity · pyrefly_python · ×3
  • 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:652 — 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:525 — 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.
D1 · Cyclomatic Complexity · Scopes · ×3
  • Scopes::finish_class_and_get_field_definitions (cyclomatic 20) pyrefly/lib/binding/scope.rs:3091 — Scopes::finish_class_and_get_field_definitions 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.
  • Scopes::look_up_name_for_read (cyclomatic 19) pyrefly/lib/binding/scope.rs:3424 — 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.
D2 · Cognitive Complexity · TypeDisplayContext · ×3
  • TypeDisplayContext::fmt_helper_generic (cognitive 212) crates/pyrefly_types/src/display.rs:917 — TypeDisplayContext::fmt_helper_generic has cognitive complexity 212 (threshold 15). Drivers by points: if/else 60 (146 pts), match/switch 16 (31 pts), loops 8 (22 pts), boolean chains 13 (nesting depth added 115). 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.
D2 · Cognitive Complexity · SemanticTokenBuilder · ×3
  • SemanticTokenBuilder::process_stmt (cognitive 71) pyrefly/lib/state/semantic_tokens.rs:528 — 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 22) pyrefly/lib/state/semantic_tokens.rs:361 — SemanticTokenBuilder::process_syntax_tokens has cognitive complexity 22 (threshold 15). Drivers by points: if/else 6 (16 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.
  • SemanticTokenBuilder::process_expr (cognitive 17) pyrefly/lib/state/semantic_tokens.rs:453 — 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.
D2 · Cognitive Complexity · ConfigFile · ×3
  • ConfigFile::configure_at (cognitive 66) crates/pyrefly_config/src/config.rs:1578 — 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:1470 — 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:1941 — 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
  • REDACTED
  • REDACTED
  • REDACTED
D4 · Code Duplication · Duplicated block (19 lines × 2) · ×3
  • Duplicated block (19 lines × 2) pyrefly/lib/alt/solve.rs:5593 — pyrefly/lib/alt/solve.rs:5593-5611 | pyrefly/lib/alt/solve.rs:5654-5672 — both copies are in the same file, so extract the block into 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:1049 — crates/pyrefly_lsp_test/src/object_model.rs:1049-1067 | crates/pyrefly_lsp_test/src/object_model.rs:1090-1108 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (19 lines × 2) tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations_runnable.py:465 — tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations_runnable.py:465-483 | 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.
D4 · Code Duplication · Duplicated block (17 lines × 3) · ×3
  • Duplicated block (17 lines × 3) pyrefly/lib/alt/narrow.rs:1717 — pyrefly/lib/alt/narrow.rs:1717-1733 | pyrefly/lib/alt/narrow.rs:1744-1760 | pyrefly/lib/alt/narrow.rs:1776-1792 — 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:166-182 | 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:289-305 | 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.
D4 · Code Duplication · Duplicated block (17 lines × 2) · ×3
  • Duplicated block (17 lines × 2) crates/pyrefly_lsp_test/src/object_model.rs:1817 — crates/pyrefly_lsp_test/src/object_model.rs:1817-1833 | crates/pyrefly_lsp_test/src/object_model.rs:1859-1875 — both copies are in the same file, so extract the block into 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.
D4 · Code Duplication · Duplicated block (13 lines × 2) · ×3
  • 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.
D4 · Code Duplication · Duplicated block (11–12 lines × 2) · ×3
  • Duplicated block (11–12 lines × 2) pyrefly/lib/alt/class/class_field.rs:1195 — pyrefly/lib/alt/class/class_field.rs:1195-1206 | pyrefly/lib/alt/class/class_field.rs:1211-1221 — both copies are in the same file, so extract the block into 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) pyrefly/lib/lsp/wasm/signature_help.rs:358 — pyrefly/lib/lsp/wasm/signature_help.rs:358-369 | pyrefly/lib/lsp/wasm/signature_help.rs:381-391 — both copies are in the same file, so extract the block into 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.
D4 · Code Duplication · Duplicated block (8–9 lines × 2) · ×3
  • 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:6385 — crates/pyrefly_types/src/type_level_dsl.rs:6385-6393 | crates/pyrefly_types/src/type_level_dsl.rs:6397-6404 — both copies are in the same file, so extract the block into 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:416 — pyrefly/lib/binding/stmt.rs:416-423 | pyrefly/lib/binding/stmt.rs:541-549 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (14 lines × 3) · ×3
  • Duplicated block (14 lines × 3) scripts/issue_ranker/v1_analysis.py:324 — scripts/issue_ranker/v1_analysis.py:324-337 | scripts/issue_ranker/v1_analysis.py:345-358 | scripts/issue_ranker/v1_analysis.py:367-380 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `scripts/issue_ranker/v1_analysis.py:359` calls `_escape_md_table`, `get` and `scripts/issue_ranker/v1_analysis.py:338` 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 (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:475-488 | 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:547-560 | 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.
D1 · Cyclomatic Complexity · TypeDisplayContext · ×2
  • TypeDisplayContext::fmt_helper_generic (cyclomatic 148) crates/pyrefly_types/src/display.rs:917 — TypeDisplayContext::fmt_helper_generic has cyclomatic complexity 148 (threshold 15). To reduce it, separate the cases: extract each independent 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.
D1 · Cyclomatic Complexity · ConfigFile · ×2
  • ConfigFile::configure_at (cyclomatic 59) crates/pyrefly_config/src/config.rs:1578 — 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:1915 — 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.
D1 · Cyclomatic Complexity · Solver · ×2
  • Solver::finish_quantified_with_captures (cyclomatic 37) pyrefly/lib/solver/solver.rs:2103 — Solver::finish_quantified_with_captures has cyclomatic complexity 37 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • Solver::simplify_mut (cyclomatic 21) pyrefly/lib/solver/solver.rs:1207 — 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.
D1 · Cyclomatic Complexity · SemanticTokenBuilder · ×2
  • SemanticTokenBuilder::process_stmt (cyclomatic 36) pyrefly/lib/state/semantic_tokens.rs:528 — 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_expr (cyclomatic 16) pyrefly/lib/state/semantic_tokens.rs:453 — 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.
D1 · Cyclomatic Complexity · pyrefly_config · ×2
  • 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 17) crates/pyrefly_config/src/migration/mypy/util.rs:133 — pyrefly_config::migration::mypy::util::make_error_config 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_config::migration::mypy::util::code_to_kind (cyclomatic 37) 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.
D1 · Cyclomatic Complexity · pyrefly_build · ×2
  • pyrefly_build::module_resolver::find_one_part_in_root (cyclomatic 22) crates/pyrefly_build/src/module_resolver.rs:360 — pyrefly_build::module_resolver::find_one_part_in_root 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_build::module_resolver::find_one_part_prefix (cyclomatic 19) crates/pyrefly_build/src/module_resolver.rs:768 — pyrefly_build::module_resolver::find_one_part_prefix 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.
D17 · Explicit Debt · FixmeComment · ×2
  • FixmeComment pyrefly/lib/alt/function.rs:2794 — // 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.
  • FixmeComment pyrefly/lib/alt/attr.rs:2840 — // 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.
D2 · Cognitive Complexity · DefinitionsBuilder · ×2
  • DefinitionsBuilder::stmt (cognitive 163) pyrefly/lib/export/definitions.rs:559 — DefinitionsBuilder::stmt has cognitive complexity 163 (threshold 15). Drivers by points: if/else 35 (87 pts), match/switch 13 (38 pts), loops 13 (28 pts), boolean chains 10 (nesting depth added 92). 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:534 — 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.
D2 · Cognitive Complexity · Expectation · ×2
  • 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.
D2 · Cognitive Complexity · SysInfo · ×2
  • SysInfo::evaluate (cognitive 37) crates/pyrefly_python/src/sys_info.rs:898 — 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:1031 — 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.
D2 · Cognitive Complexity · pyrefly_config · ×2
  • 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 21) crates/pyrefly_config/src/migration/mypy/util.rs:133 — pyrefly_config::migration::mypy::util::make_error_config has cognitive complexity 21 (threshold 15). Drivers by points: if/else 10 (14 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.
D2 · Cognitive Complexity · Scopes · ×2
  • Scopes::finish_class_and_get_field_definitions (cognitive 32) pyrefly/lib/binding/scope.rs:3091 — Scopes::finish_class_and_get_field_definitions has cognitive complexity 32 (threshold 15). Drivers by points: if/else 14 (24 pts), match/switch 2 (5 pts), boolean chains 3 (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.
  • Scopes::look_up_name_for_read (cognitive 27) pyrefly/lib/binding/scope.rs:3424 — 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.
D2 · Cognitive Complexity · Linearization · ×2
  • Linearization::merge (cognitive 31) pyrefly/lib/alt/types/class_metadata.rs:1115 — 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:1007 — 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.
D2 · Cognitive Complexity · ImportTracker · ×2
  • 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.
D2 · Cognitive Complexity · ArgsExpander · ×2
  • 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.
D2 · Cognitive Complexity · Query · ×2
  • Query::get_attributes (cognitive 22) pyrefly/lib/query.rs:1125 — 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:1518 — 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.
D2 · Cognitive Complexity · Workspaces · ×2
  • 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.
D2 · Cognitive Complexity · CallGraphVisitor · ×2
  • CallGraphVisitor::resolve_attribute_access (cognitive 18) pyrefly/lib/report/pysa/call_graph.rs:2639 — 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:3163 — 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.
D2 · Cognitive Complexity · GleanState · ×2
  • GleanState::process_statement (cognitive 17) pyrefly/lib/report/glean/convert.rs:1539 — GleanState::process_statement has cognitive complexity 17 (threshold 15). Drivers by points: if/else 3 (7 pts), loops 4 (7 pts), match/switch 2 (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.
  • GleanState::variable_facts (cognitive 16) pyrefly/lib/report/glean/convert.rs:1169 — GleanState::variable_facts has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (7 pts), loops 2 (7 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.
D30 · Dependency Vulnerabilities · Medium CVE · ×2
  • REDACTED
  • REDACTED
D35 · Change Coupling · Change-coupling hub · ×2
  • 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:972 — crates/pyrefly_lsp_test/src/object_model.rs:972-995 | crates/pyrefly_lsp_test/src/object_model.rs:1002-1027 | crates/pyrefly_lsp_test/src/object_model.rs:1034-1067 | crates/pyrefly_lsp_test/src/object_model.rs:1075-1108 — 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:869 — pyrefly/lib/alt/class/class_field.rs:869-879 | pyrefly/lib/alt/class/class_field.rs:881-891 | pyrefly/lib/alt/class/class_field.rs:971-983 | pyrefly/lib/alt/class/class_field.rs:1226-1238 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
D4 · Code Duplication · Duplicated block (21 lines × 2) · ×2
  • Duplicated block (21 lines × 2) pyrefly/lib/alt/class/class_field.rs:923 — pyrefly/lib/alt/class/class_field.rs:923-943 | pyrefly/lib/alt/class/class_field.rs:945-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 (21 lines × 2) tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations_runnable.py:410 — tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations_runnable.py:410-430 | 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.
D4 · Code Duplication · Duplicated block (20 lines × 2) · ×2
  • Duplicated block (20 lines × 2) pyrefly/lib/commands/check.rs:1337 — pyrefly/lib/commands/check.rs:1337-1356 | 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.
D4 · Code Duplication · Duplicated block (10–13 lines × 2) · ×2
  • Duplicated block (10–13 lines × 2) pyrefly/lib/alt/class/variance_inference.rs:740 — pyrefly/lib/alt/class/variance_inference.rs:740-752 | pyrefly/lib/alt/class/variance_inference.rs:762-771 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (10–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.
D4 · Code Duplication · Duplicated block (9 lines × 5) · ×2
  • Duplicated block (9 lines × 5) pyrefly/lib/lsp/non_wasm/server.rs:2423 — pyrefly/lib/lsp/non_wasm/server.rs:2423-2431 | pyrefly/lib/lsp/non_wasm/server.rs:2498-2506 | pyrefly/lib/lsp/non_wasm/server.rs:2794-2802 | pyrefly/lib/lsp/non_wasm/server.rs:2809-2817 | pyrefly/lib/lsp/non_wasm/server.rs:2839-2847 — 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:330 — tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:330-338 | 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.
D4 · Code Duplication · Duplicated block (4–7 lines × 3) · ×2
  • 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:490-496 | 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:490` 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.
D4 · Code Duplication · Duplicated block (15 lines × 3) · ×2
  • Duplicated block (15 lines × 3) pyrefly/lib/alt/special_calls.rs:101 — pyrefly/lib/alt/special_calls.rs:101-115 | pyrefly/lib/alt/special_calls.rs:204-218 | pyrefly/lib/alt/special_calls.rs:326-340 — 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:281 — tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:281-295 | 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:281` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (8 lines × 5) · ×2
  • 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:310-317 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations_runnable.py:262-269 | 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:397-404 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations_runnable.py:337-344 | 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.
D6 · Cohesion (LCOM4) · Low cohesion · ×2
  • 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:545 — 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 — 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 — 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.
D1 · Cyclomatic Complexity · DefinitionsBuilder · ×1
  • DefinitionsBuilder::stmt (cyclomatic 90) pyrefly/lib/export/definitions.rs:559 — DefinitionsBuilder::stmt has cyclomatic complexity 90 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · Binding · ×1
  • Binding::fmt (cyclomatic 74) pyrefly/lib/binding/binding.rs:2699 — Binding::fmt has cyclomatic complexity 74 (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.
D1 · Cyclomatic Complexity · NarrowOps · ×1
  • NarrowOps::from_expr_helper (cyclomatic 55) pyrefly/lib/binding/narrow.rs:889 — 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.
D1 · Cyclomatic Complexity · CheckArgs · ×1
  • CheckArgs::finish_cli_run (cyclomatic 54) pyrefly/lib/commands/check.rs:1893 — CheckArgs::finish_cli_run has cyclomatic complexity 54 (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.
D1 · Cyclomatic Complexity · TypeConverter · ×1
  • TypeConverter::convert (cyclomatic 54) pyrefly/lib/tsp/type_conversion.rs:225 — TypeConverter::convert 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.
D1 · Cyclomatic Complexity · SysInfo · ×1
  • SysInfo::evaluate (cyclomatic 41) crates/pyrefly_python/src/sys_info.rs:898 — 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.
D1 · Cyclomatic Complexity · TypeCheckKind · ×1
  • 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.
D1 · Cyclomatic Complexity · ConfigOverrideArgs · ×1
  • 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.
D1 · Cyclomatic Complexity · primer_impact.compute_primer_impact (cyclomatic 33) · ×1
  • primer_impact.compute_primer_impact (cyclomatic 33) scripts/issue_ranker/passes/primer_impact.py:171 — primer_impact.compute_primer_impact 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.
D1 · Cyclomatic Complexity · TypeShapeDslHelperCall · ×1
  • TypeShapeDslHelperCall::argument_domains (cyclomatic 28) crates/pyrefly_types/src/type_level_dsl.rs:204 — 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.
D1 · Cyclomatic Complexity · compare_typecheckers.check_project (cyclomatic 28) · ×1
  • compare_typecheckers.check_project (cyclomatic 28) scripts/compare_typecheckers.py:547 — 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.
D1 · Cyclomatic Complexity · cross_checker.cross_check_projects (cyclomatic 26) · ×1
  • cross_checker.cross_check_projects (cyclomatic 26) scripts/primer_classifier/cross_checker.py:307 — cross_checker.cross_check_projects has cyclomatic complexity 26 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · PolarsScalarDType · ×1
  • 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.
D1 · Cyclomatic Complexity · CalleesWithLocation · ×1
  • CalleesWithLocation::callee_from_type (cyclomatic 25) pyrefly/lib/query.rs:943 — 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.
D1 · Cyclomatic Complexity · Errors · ×1
  • Errors::collect_unused_ignore_errors (cyclomatic 25) pyrefly/lib/state/errors.rs:533 — Errors::collect_unused_ignore_errors 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.
D1 · Cyclomatic Complexity · score.score_issue (cyclomatic 25) · ×1
  • score.score_issue (cyclomatic 25) scripts/issue_ranker/passes/score.py:82 — score.score_issue 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.
D1 · Cyclomatic Complexity · stub_coverage._literal_all (cyclomatic 25) · ×1
  • 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.
D1 · Cyclomatic Complexity · extension.activate (cyclomatic 25) · ×1
  • 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.
D1 · Cyclomatic Complexity · InitArgs · ×1
  • 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.
D1 · Cyclomatic Complexity · CallGraphVisitor · ×1
  • CallGraphVisitor::resolve_and_register_call (cyclomatic 24) pyrefly/lib/report/pysa/call_graph.rs:3163 — 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.
D1 · Cyclomatic Complexity · generate_protocol.convert_json_to_model (cyclomatic 24) · ×1
  • 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.
D1 · Cyclomatic Complexity · __main__.collect_issue_data (cyclomatic 24) · ×1
  • __main__.collect_issue_data (cyclomatic 24) scripts/issue_ranker/__main__.py:127 — __main__.collect_issue_data 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.
D1 · Cyclomatic Complexity · formatter.format_markdown (cyclomatic 24) · ×1
  • formatter.format_markdown (cyclomatic 24) scripts/primer_classifier/formatter.py:243 — formatter.format_markdown 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.
D1 · Cyclomatic Complexity · stub_coverage.parse_stub (cyclomatic 24) · ×1
  • 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.
D1 · Cyclomatic Complexity · DslExpr · ×1
  • 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.
D1 · Cyclomatic Complexity · BindingExpect · ×1
  • BindingExpect::fmt (cyclomatic 21) pyrefly/lib/binding/binding.rs:1343 — 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 28) 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.
D1 · Cyclomatic Complexity · TestAssertion · ×1
  • TestAssertion::to_narrow_ops (cyclomatic 21) pyrefly/lib/binding/expr.rs:172 — 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.
D1 · Cyclomatic Complexity · GleanState · ×1
  • GleanState::process_statement (cyclomatic 21) pyrefly/lib/report/glean/convert.rs:1539 — 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.
D1 · Cyclomatic Complexity · github_utils.list_contributors_main (cyclomatic 21) · ×1
  • 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.
D1 · Cyclomatic Complexity · whyPyreflyGridItem.WhyPyreflyGridItem (cyclomatic 21) · ×1
  • 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 literals inside it that branch (lines 86, 60, 71). 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.
D1 · Cyclomatic Complexity · SideParser · ×1
  • SideParser::parse (cyclomatic 20) crates/pyrefly_types/src/gufunc.rs:155 — 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.
D1 · Cyclomatic Complexity · generate_release_notes._fix_bug_fix_count (cyclomatic 20) · ×1
  • generate_release_notes._fix_bug_fix_count (cyclomatic 20) scripts/generate_release_notes.py:367 — 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.
D1 · Cyclomatic Complexity · Value · ×1
  • Value::compare (cyclomatic 19) crates/pyrefly_python/src/sys_info.rs:650 — 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.
D1 · Cyclomatic Complexity · classifier.classify_project (cyclomatic 19) · ×1
  • classifier.classify_project (cyclomatic 19) scripts/primer_classifier/classifier.py:547 — classifier.classify_project has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · llm_client._build_suggestion_user_prompt (cyclomatic 19) · ×1
  • llm_client._build_suggestion_user_prompt (cyclomatic 19) scripts/primer_classifier/llm_client.py:660 — llm_client._build_suggestion_user_prompt has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · PysaModuleIndex · ×1
  • 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.
D1 · Cyclomatic Complexity · generate_protocol.replace_integer_enum (cyclomatic 18) · ×1
  • 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.
D1 · Cyclomatic Complexity · report_formatter.format_markdown (cyclomatic 18) · ×1
  • report_formatter.format_markdown (cyclomatic 18) scripts/issue_ranker/report_formatter.py:14 — report_formatter.format_markdown 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.
D1 · Cyclomatic Complexity · Int · ×1
  • Int::fmt_prec (cyclomatic 17) crates/pyrefly_types/src/dimension.rs:439 — Int::fmt_prec 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. This is NOT this file's highest cyclomatic complexity: pyrefly_types::dimension::compare_int (cyclomatic 19) 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.
D1 · Cyclomatic Complexity · UpwardSearch · ×1
  • 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.
D1 · Cyclomatic Complexity · CallArg · ×1
  • CallArg::pre_eval (cyclomatic 17) pyrefly/lib/alt/callable.rs:325 — 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.
D1 · Cyclomatic Complexity · generate_protocol.replace_flag_enum (cyclomatic 17) · ×1
  • 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.
D1 · Cyclomatic Complexity · github_issues.fetch_issues (cyclomatic 17) · ×1
  • github_issues.fetch_issues (cyclomatic 17) scripts/issue_ranker/github_issues.py:214 — github_issues.fetch_issues 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.
D1 · Cyclomatic Complexity · IgnoreMissingImports · ×1
  • 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.
D1 · Cyclomatic Complexity · ResolvedTypeShapeDslProgram · ×1
  • ResolvedTypeShapeDslProgram::evaluate_suite (cyclomatic 16) crates/pyrefly_types/src/type_level_dsl.rs:6253 — 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.
D1 · Cyclomatic Complexity · InferArgs · ×1
  • 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.
D1 · Cyclomatic Complexity · ContextualTypeCollector · ×1
  • 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.
D1 · Cyclomatic Complexity · ModuleChanges · ×1
  • ModuleChanges::overlaps (cyclomatic 16) pyrefly/lib/state/state.rs:278 — 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.
D1 · Cyclomatic Complexity · conformance_output.main (cyclomatic 16) · ×1
  • 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.
D1 · Cyclomatic Complexity · github_utils.load_env_file (cyclomatic 16) · ×1
  • 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.
D1 · Cyclomatic Complexity · issue_checker._run_all_checkers (cyclomatic 16) · ×1
  • issue_checker._run_all_checkers (cyclomatic 16) scripts/issue_ranker/issue_checker.py:77 — issue_checker._run_all_checkers has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · rank.rank_issues (cyclomatic 16) · ×1
  • rank.rank_issues (cyclomatic 16) scripts/issue_ranker/passes/rank.py:134 — rank.rank_issues 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.
D1 · Cyclomatic Complexity · classifier._format_errors_for_llm (cyclomatic 16) · ×1
  • classifier._format_errors_for_llm (cyclomatic 16) scripts/primer_classifier/classifier.py:304 — classifier._format_errors_for_llm has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · classifier._enforce_cross_project_consistency (cyclomatic 16) · ×1
  • classifier._enforce_cross_project_consistency (cyclomatic 16) scripts/primer_classifier/classifier.py:736 — classifier._enforce_cross_project_consistency has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · formatter._build_high_level_summary (cyclomatic 16) · ×1
  • formatter._build_high_level_summary (cyclomatic 16) scripts/primer_classifier/formatter.py:188 — formatter._build_high_level_summary has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · llm_client._parse_classification (cyclomatic 16) · ×1
  • llm_client._parse_classification (cyclomatic 16) scripts/primer_classifier/llm_client.py:225 — llm_client._parse_classification has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · parser.parse_primer_diff (cyclomatic 16) · ×1
  • parser.parse_primer_diff (cyclomatic 16) scripts/primer_classifier/parser.py:165 — parser.parse_primer_diff 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.
D15 · Churn × Complexity Hotspots · Repeated repair · ×1
  • Repeated repair: crates/pyrefly_python/src/module_name.rs crates/pyrefly_python/src/module_name.rs:488 — crates/pyrefly_python/src/module_name.rs changed 6 times in last 90 days and 4 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 13 (its worst body is ModuleName::from_path_impl at line 488), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix pydantic - Strict types are not treated as strict mode #3543 (#3565)”; “fix Django REST Framework: false positives on serializer declared fields (named like Field attrs) and inner Meta #3933 (#4630)”; “fix djangorestframework-stubs: ModelSerializer.Meta class pattern causes false positive bad-override errors #4595 (#4599)”; “fix Pydantic alias_generator (#2946)”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-07-01..2026-09-29, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-01 01:37:31 -07:00' --until='2026-09-29 01:37:31 -07:00' --full-history --no-merges -- crates/pyrefly_python/src/module_name.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.
D17 · Explicit Debt · XxxComment · ×1
  • XxxComment pyrefly/lib/state/lsp.rs:1163 — // 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.
D2 · Cognitive Complexity · primer_impact.compute_primer_impact (cognitive 102) · ×1
  • primer_impact.compute_primer_impact (cognitive 102) scripts/issue_ranker/passes/primer_impact.py:171 — primer_impact.compute_primer_impact has cognitive complexity 102 (threshold 15). Drivers by points: if/else 20 (66 pts), loops 8 (31 pts), boolean chains 5 (nesting depth added 69). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · CheckArgs · ×1
  • CheckArgs::finish_cli_run (cognitive 87) pyrefly/lib/commands/check.rs:1893 — CheckArgs::finish_cli_run has cognitive complexity 87 (threshold 15). Drivers by points: if/else 50 (66 pts), loops 4 (8 pts), match/switch 2 (7 pts), boolean chains 6 (nesting depth added 25). 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.
D2 · Cognitive Complexity · Errors · ×1
  • Errors::collect_unused_ignore_errors (cognitive 75) pyrefly/lib/state/errors.rs:533 — Errors::collect_unused_ignore_errors has cognitive complexity 75 (threshold 15). Drivers by points: if/else 15 (49 pts), loops 7 (18 pts), boolean chains 4, match/switch 1 (4 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.
D2 · Cognitive Complexity · NarrowOps · ×1
  • NarrowOps::from_expr_helper (cognitive 63) pyrefly/lib/binding/narrow.rs:889 — 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.
D2 · Cognitive Complexity · SideParser · ×1
  • SideParser::parse (cognitive 55) crates/pyrefly_types/src/gufunc.rs:155 — 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.
D2 · Cognitive Complexity · stub_coverage._literal_all (cognitive 55) · ×1
  • 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.
D2 · Cognitive Complexity · formatter.format_markdown (cognitive 48) · ×1
  • formatter.format_markdown (cognitive 48) scripts/primer_classifier/formatter.py:243 — formatter.format_markdown has cognitive complexity 48 (threshold 15). Drivers by points: if/else 16 (35 pts), loops 5 (10 pts), boolean chains 3 (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.
D2 · Cognitive Complexity · PysaModuleIndex · ×1
  • 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.
D2 · Cognitive Complexity · cross_checker.cross_check_projects (cognitive 46) · ×1
  • cross_checker.cross_check_projects (cognitive 46) scripts/primer_classifier/cross_checker.py:307 — cross_checker.cross_check_projects has cognitive complexity 46 (threshold 15). Drivers by points: if/else 15 (28 pts), loops 3 (6 pts), boolean chains 4, error handling 2 (4 pts), ternaries 2 (4 pts) (nesting depth added 20). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · UpwardSearch · ×1
  • 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.
D2 · Cognitive Complexity · generate_protocol.convert_json_to_model (cognitive 41) · ×1
  • 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.
D2 · Cognitive Complexity · __main__.collect_issue_data (cognitive 41) · ×1
  • __main__.collect_issue_data (cognitive 41) scripts/issue_ranker/__main__.py:127 — __main__.collect_issue_data has cognitive complexity 41 (threshold 15). Drivers by points: if/else 14 (24 pts), loops 8 (12 pts), boolean chains 4, ternaries 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.
D2 · Cognitive Complexity · Binding · ×1
  • Binding::fmt (cognitive 40) pyrefly/lib/binding/binding.rs:2699 — 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.
D2 · Cognitive Complexity · CallArg · ×1
  • CallArg::pre_eval (cognitive 38) pyrefly/lib/alt/callable.rs:325 — 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.
D2 · Cognitive Complexity · TypeShapeDslHelperCall · ×1
  • TypeShapeDslHelperCall::argument_domains (cognitive 37) crates/pyrefly_types/src/type_level_dsl.rs:204 — 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.
D2 · Cognitive Complexity · InitArgs · ×1
  • 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.
D2 · Cognitive Complexity · parser.parse_primer_diff (cognitive 37) · ×1
  • parser.parse_primer_diff (cognitive 37) scripts/primer_classifier/parser.py:165 — parser.parse_primer_diff has cognitive complexity 37 (threshold 15). Drivers by points: if/else 11 (33 pts), loops 2 (3 pts), boolean chains 1 (nesting depth added 23). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ConfigOverrideArgs · ×1
  • 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.
D2 · Cognitive Complexity · InferArgs · ×1
  • 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.
D2 · Cognitive Complexity · github_utils.list_contributors_main (cognitive 35) · ×1
  • 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.
D2 · Cognitive Complexity · llm_client._build_suggestion_user_prompt (cognitive 35) · ×1
  • llm_client._build_suggestion_user_prompt (cognitive 35) scripts/primer_classifier/llm_client.py:660 — llm_client._build_suggestion_user_prompt has cognitive complexity 35 (threshold 15). Drivers by points: if/else 12 (22 pts), loops 5 (11 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.
D2 · Cognitive Complexity · generate_protocol.replace_integer_enum (cognitive 34) · ×1
  • 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.
D2 · Cognitive Complexity · compare_typecheckers.check_project (cognitive 34) · ×1
  • compare_typecheckers.check_project (cognitive 34) scripts/compare_typecheckers.py:547 — 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.
D2 · Cognitive Complexity · github_utils.fetch_bug_issues (cognitive 34) · ×1
  • 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.
D2 · Cognitive Complexity · llm_transport._extract_json (cognitive 34) · ×1
  • llm_transport._extract_json (cognitive 34) scripts/llm_transport.py:220 — llm_transport._extract_json has cognitive complexity 34 (threshold 15). Drivers by points: if/else 7 (21 pts), error handling 3 (9 pts), loops 2 (4 pts) (nesting depth added 22). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · llm_client._parse_classification (cognitive 34) · ×1
  • llm_client._parse_classification (cognitive 34) scripts/primer_classifier/llm_client.py:225 — llm_client._parse_classification has cognitive complexity 34 (threshold 15). Drivers by points: if/else 6 (19 pts), error handling 3 (8 pts), loops 2 (4 pts), boolean chains 3 (nesting depth added 20). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · score.score_issue (cognitive 33) · ×1
  • score.score_issue (cognitive 33) scripts/issue_ranker/passes/score.py:82 — score.score_issue has cognitive complexity 33 (threshold 15). Drivers by points: if/else 12 (19 pts), boolean chains 7, loops 4 (6 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.
D2 · Cognitive Complexity · ContextualTypeCollector · ×1
  • 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.
D2 · Cognitive Complexity · conformance_output.main (cognitive 31) · ×1
  • 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.
D2 · Cognitive Complexity · ContributorAnalyzer._extract_contributors (cognitive 30) · ×1
  • 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.
D2 · Cognitive Complexity · github_utils.load_env_file (cognitive 29) · ×1
  • 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.
D2 · Cognitive Complexity · rank.rank_issues (cognitive 28) · ×1
  • rank.rank_issues (cognitive 28) scripts/issue_ranker/passes/rank.py:134 — rank.rank_issues has cognitive complexity 28 (threshold 15). Drivers by points: if/else 7 (9 pts), loops 5 (9 pts), error handling 2 (6 pts), ternaries 2 (3 pts), boolean chains 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · report_formatter.format_markdown (cognitive 28) · ×1
  • report_formatter.format_markdown (cognitive 28) scripts/issue_ranker/report_formatter.py:14 — report_formatter.format_markdown has cognitive complexity 28 (threshold 15). Drivers by points: if/else 10 (17 pts), loops 6 (11 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.
D2 · Cognitive Complexity · Tuple · ×1
  • 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.
D2 · Cognitive Complexity · relationship_resolver.resolve_relationships (cognitive 27) · ×1
  • relationship_resolver.resolve_relationships (cognitive 27) scripts/issue_ranker/relationship_resolver.py:25 — relationship_resolver.resolve_relationships has cognitive complexity 27 (threshold 15). Drivers by points: if/else 5 (15 pts), loops 6 (11 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.
D2 · Cognitive Complexity · classifier._categorize_errors (cognitive 27) · ×1
  • classifier._categorize_errors (cognitive 27) scripts/primer_classifier/classifier.py:199 — classifier._categorize_errors has cognitive complexity 27 (threshold 15). Drivers by points: if/else 9 (23 pts), boolean chains 2, loops 2 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Exports · ×1
  • Exports::invalid_dunder_all_entries (cognitive 26) pyrefly/lib/export/exports.rs:396 — 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.
D2 · Cognitive Complexity · generate_release_notes._fix_bug_fix_count (cognitive 26) · ×1
  • generate_release_notes._fix_bug_fix_count (cognitive 26) scripts/generate_release_notes.py:367 — 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.
D2 · Cognitive Complexity · github_issues.fetch_issues (cognitive 26) · ×1
  • github_issues.fetch_issues (cognitive 26) scripts/issue_ranker/github_issues.py:214 — github_issues.fetch_issues has cognitive complexity 26 (threshold 15). Drivers by points: if/else 9 (18 pts), boolean chains 4, loops 3 (4 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · stub_coverage.parse_stub (cognitive 26) · ×1
  • 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.
D2 · Cognitive Complexity · Value · ×1
  • Value::compare (cognitive 25) crates/pyrefly_python/src/sys_info.rs:650 — 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.
D2 · Cognitive Complexity · ErrorCollector · ×1
  • ErrorCollector::collect_into (cognitive 25) pyrefly/lib/error/collector.rs:298 — ErrorCollector::collect_into has cognitive complexity 25 (threshold 15). Drivers by points: if/else 7 (18 pts), match/switch 1 (4 pts), loops 1 (2 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.
D2 · Cognitive Complexity · classifier._enforce_cross_project_consistency (cognitive 25) · ×1
  • classifier._enforce_cross_project_consistency (cognitive 25) scripts/primer_classifier/classifier.py:736 — classifier._enforce_cross_project_consistency has cognitive complexity 25 (threshold 15). Drivers by points: if/else 8 (15 pts), loops 5 (8 pts), boolean chains 2 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · primer_history.render_markdown (cognitive 25) · ×1
  • primer_history.render_markdown (cognitive 25) scripts/primer_history.py:69 — primer_history.render_markdown has cognitive complexity 25 (threshold 15). Drivers by points: if/else 4 (10 pts), ternaries 4 (9 pts), loops 4 (6 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.
D2 · Cognitive Complexity · ResolvedTypeShapeDslProgram · ×1
  • ResolvedTypeShapeDslProgram::evaluate_suite (cognitive 24) crates/pyrefly_types/src/type_level_dsl.rs:6253 — 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.
D2 · Cognitive Complexity · generate_protocol.replace_flag_enum (cognitive 24) · ×1
  • 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.
D2 · Cognitive Complexity · classifier._format_errors_for_llm (cognitive 23) · ×1
  • classifier._format_errors_for_llm (cognitive 23) scripts/primer_classifier/classifier.py:304 — classifier._format_errors_for_llm has cognitive complexity 23 (threshold 15). Drivers by points: if/else 10 (14 pts), loops 2 (4 pts), ternaries 1 (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.
D2 · Cognitive Complexity · formatter._build_high_level_summary (cognitive 23) · ×1
  • formatter._build_high_level_summary (cognitive 23) scripts/primer_classifier/formatter.py:188 — formatter._build_high_level_summary has cognitive complexity 23 (threshold 15). Drivers by points: if/else 9 (15 pts), loops 3 (6 pts), boolean chains 2 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · extension.activate (cognitive 23) · ×1
  • 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.
D2 · Cognitive Complexity · RenameUsageVisitor · ×1
  • 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.
D2 · Cognitive Complexity · WorkspaceConfigConfigurer · ×1
  • 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.
D2 · Cognitive Complexity · issue_checker._run_all_checkers (cognitive 22) · ×1
  • issue_checker._run_all_checkers (cognitive 22) scripts/issue_ranker/issue_checker.py:77 — issue_checker._run_all_checkers has cognitive complexity 22 (threshold 15). Drivers by points: if/else 5 (12 pts), boolean chains 9, 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.
D2 · Cognitive Complexity · classifier.classify_project (cognitive 22) · ×1
  • classifier.classify_project (cognitive 22) scripts/primer_classifier/classifier.py:547 — classifier.classify_project has cognitive complexity 22 (threshold 15). Drivers by points: if/else 12 (16 pts), boolean chains 3, error handling 2, loops 1 (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.
D2 · Cognitive Complexity · llm_client.assign_verdict_with_llm (cognitive 22) · ×1
  • llm_client.assign_verdict_with_llm (cognitive 22) scripts/primer_classifier/llm_client.py:523 — llm_client.assign_verdict_with_llm has cognitive complexity 22 (threshold 15). Drivers by points: if/else 7 (13 pts), loops 6 (7 pts), error handling 1 (2 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · QuerySourceDatabase · ×1
  • 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.
D2 · Cognitive Complexity · ParamList · ×1
  • 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.
D2 · Cognitive Complexity · PolarsScalarDType · ×1
  • 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.
D2 · Cognitive Complexity · Tarjan · ×1
  • 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.
D2 · Cognitive Complexity · TypeCheckKind · ×1
  • 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.
D2 · Cognitive Complexity · TspExtraConnection · ×1
  • TspExtraConnection::run (cognitive 21) pyrefly/lib/tsp/server.rs:499 — 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.
D2 · Cognitive Complexity · AdvancedIndexPlan · ×1
  • 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.
D2 · Cognitive Complexity · BaselineIndex · ×1
  • BaselineIndex::apply (cognitive 20) pyrefly/lib/error/baseline.rs:268 — 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.
D2 · Cognitive Complexity · ModuleChanges · ×1
  • ModuleChanges::overlaps (cognitive 20) pyrefly/lib/state/state.rs:278 — 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.
D2 · Cognitive Complexity · cross_checker._collect_checker_errors (cognitive 20) · ×1
  • cross_checker._collect_checker_errors (cognitive 20) scripts/primer_classifier/cross_checker.py:84 — cross_checker._collect_checker_errors has cognitive complexity 20 (threshold 15). Drivers by points: if/else 6 (8 pts), ternaries 3 (8 pts), boolean chains 4 (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.
D2 · Cognitive Complexity · PyProject · ×1
  • 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.
D2 · Cognitive Complexity · TaskHeap · ×1
  • TaskHeap::work (cognitive 19) crates/pyrefly_util/src/task_heap.rs:168 — 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.
D2 · Cognitive Complexity · Bindings · ×1
  • Bindings::new (cognitive 19) pyrefly/lib/binding/bindings.rs:642 — Bindings::new has cognitive complexity 19 (threshold 15). Drivers by points: if/else 9 (13 pts), loops 4, match/switch 1 (2 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.
D2 · Cognitive Complexity · SemanticTokensLegends · ×1
  • SemanticTokensLegends::convert_tokens_into_lsp_semantic_tokens (cognitive 19) pyrefly/lib/state/semantic_tokens.rs:160 — 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.
D2 · Cognitive Complexity · view_types.inline_type (cognitive 19) · ×1
  • 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.
D2 · Cognitive Complexity · shape_testing.check_suites (cognitive 19) · ×1
  • shape_testing.check_suites (cognitive 19) tensor-shapes/shape_testing.py:214 — shape_testing.check_suites has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (12 pts), loops 3 (5 pts), boolean chains 1, ternaries 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · IgnoreMissingImports · ×1
  • 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.
D2 · Cognitive Complexity · Ignore · ×1
  • Ignore::parse (cognitive 18) crates/pyrefly_python/src/ignore.rs:441 — 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.
D2 · Cognitive Complexity · Callable · ×1
  • 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.
D2 · Cognitive Complexity · PolarsDType · ×1
  • 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.
D2 · Cognitive Complexity · Answers · ×1
  • Answers::solve (cognitive 18) pyrefly/lib/alt/answers.rs:1343 — 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.
D2 · Cognitive Complexity · PytestAliases · ×1
  • 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.
D2 · Cognitive Complexity · ModuleDeps · ×1
  • ModuleDeps::invalidated_by (cognitive 18) pyrefly/lib/state/state.rs:411 — 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.
D2 · Cognitive Complexity · conformance_output.diff_expected_errors (cognitive 18) · ×1
  • 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.
D2 · Cognitive Complexity · github_utils.display_contributors (cognitive 18) · ×1
  • 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.
D2 · Cognitive Complexity · __main__.main (cognitive 18) · ×1
  • __main__.main (cognitive 18) scripts/primer_classifier/__main__.py:30 — __main__.main has cognitive complexity 18 (threshold 15). Drivers by points: error handling 6 (10 pts), if/else 7, ternaries 1 (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.
D2 · Cognitive Complexity · stub_coverage.collect (cognitive 18) · ×1
  • 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.
D2 · Cognitive Complexity · DslExpr · ×1
  • 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.
D2 · Cognitive Complexity · Solutions · ×1
  • Solutions::changed_exports::check_table (cognitive 17) pyrefly/lib/alt/answers.rs:1042 — 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.
D2 · Cognitive Complexity · conformance_output.get_expected_errors (cognitive 17) · ×1
  • 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.
D2 · Cognitive Complexity · llm_transport.call_anthropic_api (cognitive 17) · ×1
  • llm_transport.call_anthropic_api (cognitive 17) scripts/llm_transport.py:135 — llm_transport.call_anthropic_api has cognitive complexity 17 (threshold 15). Drivers by points: if/else 2 (6 pts), error handling 2 (4 pts), boolean chains 3, ternaries 1 (3 pts), loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · code-lens.runTestAtLocation (cognitive 17) · ×1
  • 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.
D2 · Cognitive Complexity · whyPyreflyGridItem.WhyPyreflyGridItem (cognitive 17) · ×1
  • 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 literals inside it that branch (lines 86, 60, 71). 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.
D2 · Cognitive Complexity · pyrefly_bundled · ×1
  • 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.
D2 · Cognitive Complexity · Type · ×1
  • Type::finalize_type_level_dsl_at_boundary (cognitive 16) crates/pyrefly_types/src/types.rs:1774 — 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). Most of this is not in the body itself: 0 of the 16 points are its own statements and the rest belongs 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.
D2 · Cognitive Complexity · AttrSubsetError · ×1
  • AttrSubsetError::to_error_msg (cognitive 16) pyrefly/lib/alt/attr.rs:131 — 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.
D2 · Cognitive Complexity · Static · ×1
  • Static::stmts (cognitive 16) pyrefly/lib/binding/scope.rs:498 — 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.
D2 · Cognitive Complexity · view_types.format_type (cognitive 16) · ×1
  • 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.
D2 · Cognitive Complexity · compare_typecheckers.main (cognitive 16) · ×1
  • compare_typecheckers.main (cognitive 16) scripts/compare_typecheckers.py:821 — 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.
D2 · Cognitive Complexity · llm_client.critique_reasoning (cognitive 16) · ×1
  • llm_client.critique_reasoning (cognitive 16) scripts/primer_classifier/llm_client.py:407 — llm_client.critique_reasoning has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (12 pts), loops 1 (3 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.
D2 · Cognitive Complexity · stub_coverage.stub_exports (cognitive 16) · ×1
  • 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.
D22 · Internal API Consistency · Redundant methods with unclear distinction. `override_config` and `override_config_at` have nearly identical signatures and return types. It is unclear why one requires a `project_root` and the other does not, or if they represent different scoping contexts that should be unified via a single method with an optional or explicit scope parameter. · ×1
  • Redundant methods with unclear distinction. `override_config` and `override_config_at` have nearly identical signatures and return types. It is unclear why one requires a `project_root` and the other does not, or if they represent different scoping contexts that should be unified via a single method with an optional or explicit scope parameter. — Unify into a single method `override_config(config: ConfigFile, scope: Option<Path>)` or determine if one is obsolete and remove it. (signatures: pyrefly_config.args.ConfigOverrideArgs.override_config(config: ConfigFile): (ArcId<ConfigFile>, Vec<ConfigError>) | pyrefly_config.args.ConfigOverrideArgs.override_config_at(config: ConfigFile, project_root: Path): (ArcId<ConfigFile>, Vec<ConfigError>))
D22 · Internal API Consistency · Duplicate method signatures. Two methods named `get_env_from_interpreter` exist with identical parameter types. The underscore in the second parameter name (`_interpreter`) suggests one might be a placeholder or deprecated, but both are exposed in the public API surface. · ×1
  • Duplicate method signatures. Two methods named `get_env_from_interpreter` exist with identical parameter types. The underscore in the second parameter name (`_interpreter`) suggests one might be a placeholder or deprecated, but both are exposed in the public API surface. — Remove the duplicate signature. If one is deprecated, mark it as such or remove it entirely. If they differ in implementation details not visible in the signature, rename one to reflect the difference (e.g., `get_env_from_interpreter_cached`). (signatures: pyrefly_config.environment.environment.PythonEnvironment.get_env_from_interpreter(interpreter: Path): Result | pyrefly_config.environment.environment.PythonEnvironment.get_env_from_interpreter(_interpreter: Path): Result)
D22 · Internal API Consistency · Ambiguous overlap in intent. `includes` returns `Globs` for a scope, while `get_filtered_globs` returns `FilteredGlobs` and takes `custom_excludes`. It is unclear if `includes` is a simplified version of `get_filtered_globs` with no custom excludes, or if they serve distinct filtering logic. The naming convention (`includes` vs `get_filtered_globs`) is inconsistent. · ×1
  • Ambiguous overlap in intent. `includes` returns `Globs` for a scope, while `get_filtered_globs` returns `FilteredGlobs` and takes `custom_excludes`. It is unclear if `includes` is a simplified version of `get_filtered_globs` with no custom excludes, or if they serve distinct filtering logic. The naming convention (`includes` vs `get_filtered_globs`) is inconsistent. — Unify under a single naming convention. If `includes` is just `get_filtered_globs` with empty excludes, rename `includes` to `get_includes` or merge logic into `get_filtered_globs`. (signatures: pyrefly_config.config.ConfigFile.includes(scope: ConfigScope): Globs | pyrefly_config.config.ConfigFile.get_filtered_globs(custom_excludes: Globs, scope: ConfigScope): FilteredGlobs)
D29 · Static Analysis (SAST) · REDACTED · ×1
  • REDACTED
D3 · God Classes · TooManyFunctions · ×1
  • 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.
D30 · Dependency Vulnerabilities · Medium advisory (unsound) · ×1
  • REDACTED
D36 · Supply-chain Provenance & Signing · REDACTED · ×1
  • REDACTED
D36 · Supply-chain Provenance & Signing · REDACTED · ×1
  • REDACTED
D36 · Supply-chain Provenance & Signing · REDACTED · ×1
  • REDACTED
D36 · Supply-chain Provenance & Signing · REDACTED · ×1
  • REDACTED
D4 · Code Duplication · Near-duplicate member pair (26 shared lines) · ×1
  • Near-duplicate member pair (26 shared lines) crates/pyrefly_types/src/type_level_dsl.rs:3568 — crates/pyrefly_types/src/type_level_dsl.rs:3568-3628 | crates/pyrefly_types/src/type_level_dsl.rs:3678-3721 — These two members are variants of one another: 26 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Duplicated block (37–40 lines × 2) · ×1
  • 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.
D4 · Code Duplication · Duplicated block (36 lines × 2) · ×1
  • 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.
D4 · Code Duplication · Duplicated block (27–33 lines × 2) · ×1
  • Duplicated block (27–33 lines × 2) pyrefly/lib/lsp/non_wasm/server.rs:6736 — pyrefly/lib/lsp/non_wasm/server.rs:6736-6768 | pyrefly/lib/lsp/non_wasm/server.rs:6893-6919 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (28–30 lines × 2) · ×1
  • Duplicated block (28–30 lines × 2) pyrefly/lib/alt/narrow.rs:1497 — pyrefly/lib/alt/narrow.rs:1497-1524 | pyrefly/lib/alt/narrow.rs:1573-1602 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (28 lines × 2) · ×1
  • Duplicated block (28 lines × 2) pyrefly/lib/report/pysa/call_graph.rs:2299 — pyrefly/lib/report/pysa/call_graph.rs:2299-2326 | pyrefly/lib/report/pysa/call_graph.rs:2330-2357 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (22 lines × 2) · ×1
  • 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.
D4 · Code Duplication · Duplicated block (20–21 lines × 2) · ×1
  • 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.
D4 · Code Duplication · Duplicated block (18–19 lines × 3) · ×1
  • Duplicated block (18–19 lines × 3) pyrefly/lib/alt/solve.rs:6411 — pyrefly/lib/alt/solve.rs:6411-6429 | pyrefly/lib/alt/solve.rs:6434-6452 | pyrefly/lib/alt/solve.rs:6627-6644 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
D4 · Code Duplication · Duplicated block (18–19 lines × 2) · ×1
  • 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.
D4 · Code Duplication · Duplicated block (14–15 lines × 3) · ×1
  • Duplicated block (14–15 lines × 3) pyrefly/lib/alt/solve.rs:1182 — pyrefly/lib/alt/solve.rs:1182-1196 | pyrefly/lib/alt/solve.rs:1207-1220 | pyrefly/lib/alt/solve.rs:1236-1249 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
D4 · Code Duplication · Duplicated block (14–15 lines × 2) · ×1
  • Duplicated block (14–15 lines × 2) pyrefly/lib/alt/expr.rs:2231 — pyrefly/lib/alt/expr.rs:2231-2245 | pyrefly/lib/alt/expr.rs:2269-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.
D4 · Code Duplication · Duplicated block (11–14 lines × 3) · ×1
  • Duplicated block (11–14 lines × 3) pyrefly/lib/alt/solve.rs:1400 — pyrefly/lib/alt/solve.rs:1400-1413 | pyrefly/lib/alt/solve.rs:1423-1433 | pyrefly/lib/alt/solve.rs:1447-1457 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
D4 · Code Duplication · Duplicated block (12–14 lines × 2) · ×1
  • Duplicated block (12–14 lines × 2) pyrefly/lib/lsp/wasm/completion.rs:901 — pyrefly/lib/lsp/wasm/completion.rs:901-912 | pyrefly/lib/state/lsp.rs:450-463 — 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.
D4 · Code Duplication · Duplicated block (9–11 lines × 2) · ×1
  • Duplicated block (9–11 lines × 2) crates/pyrefly_types/src/type_level_dsl.rs:2605 — crates/pyrefly_types/src/type_level_dsl.rs:2605-2615 | crates/pyrefly_types/src/type_level_dsl.rs:3794-3802 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (8–11 lines × 2) · ×1
  • Duplicated block (8–11 lines × 2) pyrefly/lib/alt/solve.rs:5577 — pyrefly/lib/alt/solve.rs:5577-5587 | pyrefly/lib/alt/solve.rs:5641-5648 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (7–11 lines × 2) · ×1
  • Duplicated block (7–11 lines × 2) pyrefly/lib/lsp/non_wasm/server.rs:3780 — pyrefly/lib/lsp/non_wasm/server.rs:3780-3786 | pyrefly/lib/lsp/non_wasm/server.rs:3821-3831 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (6–10 lines × 2) · ×1
  • Duplicated block (6–10 lines × 2) pyrefly/lib/binding/class.rs:1326 — pyrefly/lib/binding/class.rs:1326-1335 | pyrefly/lib/binding/class.rs:1386-1391 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (9–10 lines × 2) · ×1
  • 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.
D4 · Code Duplication · Duplicated block (8–9 lines × 3) · ×1
  • Duplicated block (8–9 lines × 3) pyrefly/lib/alt/solve.rs:4254 — pyrefly/lib/alt/solve.rs:4254-4261 | pyrefly/lib/alt/solve.rs:4270-4277 | pyrefly/lib/alt/solve.rs:4287-4295 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
D4 · Code Duplication · Duplicated block (5–9 lines × 2) · ×1
  • Duplicated block (5–9 lines × 2) pyrefly/lib/solver/subset.rs:2698 — pyrefly/lib/solver/subset.rs:2698-2706 | pyrefly/lib/solver/subset.rs:2711-2715 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (8 lines × 11) · ×1
  • Duplicated block (8 lines × 11) pyrefly/lib/lsp/non_wasm/server.rs:2377 — pyrefly/lib/lsp/non_wasm/server.rs:2377-2384 | pyrefly/lib/lsp/non_wasm/server.rs:2409-2416 | pyrefly/lib/lsp/non_wasm/server.rs:2484-2491 | pyrefly/lib/lsp/non_wasm/server.rs:2569-2576 | pyrefly/lib/lsp/non_wasm/server.rs:2604-2611 | pyrefly/lib/lsp/non_wasm/server.rs:2631-2638 | pyrefly/lib/lsp/non_wasm/server.rs:2646-2653 | pyrefly/lib/lsp/non_wasm/server.rs:2661-2668 | pyrefly/lib/lsp/non_wasm/server.rs:2765-2772 | pyrefly/lib/lsp/non_wasm/server.rs:2780-2787 | pyrefly/lib/lsp/non_wasm/server.rs:2825-2832 — 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.
D4 · Code Duplication · Duplicated block (8 lines × 6) · ×1
  • Duplicated block (8 lines × 6) pyrefly/lib/alt/narrow.rs:1372 — pyrefly/lib/alt/narrow.rs:1372-1379 | pyrefly/lib/alt/narrow.rs:1394-1401 | pyrefly/lib/alt/narrow.rs:1416-1423 | pyrefly/lib/alt/narrow.rs:1429-1436 | pyrefly/lib/alt/narrow.rs:1445-1452 | pyrefly/lib/alt/narrow.rs:1461-1468 — 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.
D4 · Code Duplication · Duplicated block (7 lines × 4) · ×1
  • Duplicated block (7 lines × 4) pyrefly/lib/state/semantic_tokens.rs:491 — pyrefly/lib/state/semantic_tokens.rs:491-497 | pyrefly/lib/state/semantic_tokens.rs:499-505 | pyrefly/lib/state/semantic_tokens.rs:507-513 | pyrefly/lib/state/semantic_tokens.rs:515-521 — 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.
D4 · Code Duplication · Duplicated block (6–7 lines × 2) · ×1
  • Duplicated block (6–7 lines × 2) pyrefly/lib/solver/subset.rs:2072 — pyrefly/lib/solver/subset.rs:2072-2077 | pyrefly/lib/solver/subset.rs:2098-2104 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (6 lines × 4) · ×1
  • Duplicated block (6 lines × 4) pyrefly/lib/alt/class/class_field.rs:870 — pyrefly/lib/alt/class/class_field.rs:870-875 | pyrefly/lib/alt/class/class_field.rs:882-887 | pyrefly/lib/alt/class/class_field.rs:972-977 | pyrefly/lib/alt/class/class_field.rs:1227-1232 — 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.
D4 · Code Duplication · Duplicated block (13 lines × 3) · ×1
  • 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.
D4 · Code Duplication · Duplicated block (10 lines × 4) · ×1
  • Duplicated block (10 lines × 4) crates/pyrefly_lsp_test/src/object_model.rs:973 — crates/pyrefly_lsp_test/src/object_model.rs:973-982 | crates/pyrefly_lsp_test/src/object_model.rs:1003-1012 | crates/pyrefly_lsp_test/src/object_model.rs:1035-1044 | crates/pyrefly_lsp_test/src/object_model.rs:1076-1085 — 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.
D4 · Code Duplication · Duplicated block (9 lines × 4) · ×1
  • Duplicated block (9 lines × 4) pyrefly/lib/report/pysa/call_graph.rs:3246 — pyrefly/lib/report/pysa/call_graph.rs:3246-3254 | pyrefly/lib/report/pysa/call_graph.rs:3259-3267 | pyrefly/lib/report/pysa/call_graph.rs:3272-3280 | pyrefly/lib/report/pysa/call_graph.rs:3285-3293 — 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.
D4 · Code Duplication · Duplicated block (45–46 lines × 4) · ×1
  • Duplicated block (45–46 lines × 4) tensor-shapes/pyrefly-einops-stubs/run_pyrefly.py:30 — tensor-shapes/pyrefly-einops-stubs/run_pyrefly.py:30-74 | tensor-shapes/pyrefly-jax-stubs/run_pyrefly.py:30-75 | tensor-shapes/pyrefly-numpy-stubs/run_pyrefly.py:29-74 | tensor-shapes/pyrefly-torch-stubs/run_pyrefly.py:29-74 — `tensor-shapes/pyrefly-einops-stubs/run_pyrefly.py` and `tensor-shapes/pyrefly-jax-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/pyrefly-einops-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.
D4 · Code Duplication · Duplicated block (27–28 lines × 2) · ×1
  • Duplicated block (27–28 lines × 2) tensor-shapes/pyrefly-jax-stubs/suites.py:19 — tensor-shapes/pyrefly-jax-stubs/suites.py:19-46 | tensor-shapes/pyrefly-numpy-stubs/suites.py:19-45 — `tensor-shapes/pyrefly-jax-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.
D4 · Code Duplication · Duplicated block (14–16 lines × 3) · ×1
  • 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.
D4 · Code Duplication · Duplicated block (14–15 lines × 5) · ×1
  • Duplicated block (14–15 lines × 5) tensor-shapes/microtorch/run_pyrefly.py:35 — tensor-shapes/microtorch/run_pyrefly.py:35-48 | tensor-shapes/pyrefly-einops-stubs/run_pyrefly.py:64-77 | tensor-shapes/pyrefly-jax-stubs/run_pyrefly.py:64-78 | tensor-shapes/pyrefly-numpy-stubs/run_pyrefly.py:63-77 | tensor-shapes/pyrefly-torch-stubs/run_pyrefly.py:63-77 — `tensor-shapes/microtorch/run_pyrefly.py` and `tensor-shapes/pyrefly-torch-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 1 separate duplicated blocks between them, totalling at least 15 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/microtorch/run_pyrefly.py:35` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `tensor-shapes/pyrefly-torch-stubs/run_pyrefly.py:78` calls `venv_site_packages`, `venv_python` and `tensor-shapes/microtorch/run_pyrefly.py:49` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (13–15 lines × 2) · ×1
  • 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.
D4 · Code Duplication · Duplicated block (12–14 lines × 3) · ×1
  • Duplicated block (12–14 lines × 3) scripts/primer_classifier/llm_client.py:313 — scripts/primer_classifier/llm_client.py:313-326 | scripts/primer_classifier/llm_client.py:429-442 | scripts/primer_classifier/llm_client.py:765-776 — 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 `scripts/primer_classifier/llm_client.py:313` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (13–14 lines × 2) · ×1
  • Duplicated block (13–14 lines × 2) scripts/primer_classifier/classifier.py:389 — scripts/primer_classifier/classifier.py:389-402 | scripts/primer_classifier/classifier.py:532-544 — both copies are in the same file, so extract the 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.
D4 · Code Duplication · Duplicated block (9–10 lines × 3) · ×1
  • 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:469-499 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations_runnable.py:409-439 | 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:278-317 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations_runnable.py:235-269 | 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:108-182 | 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:416-457 | 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:257 — tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:257-272 | 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.
D4 · Code Duplication · Near-duplicate member pair (80 shared lines) · ×1
  • 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:94 — tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:94-100 | tensor-shapes/pyrefly-torch-stubs/examples/mixtral_moe.py:184-190 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations.py:99-105 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations_runnable.py:103-109 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var.py:117-123 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_sym_int_var_runnable.py:107-113 — These 6 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
D4 · Code Duplication · Duplicated block (58 lines × 5) · ×1
  • 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:408-465 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations_runnable.py:348-405 | 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.
D4 · Code Duplication · Duplicated block (45 lines × 2) · ×1
  • Duplicated block (45 lines × 2) tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations_runnable.py:105 — tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations_runnable.py:105-149 | 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.
D4 · Code Duplication · Duplicated block (44 lines × 3) · ×1
  • 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:348-391 | 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.
D4 · Code Duplication · Duplicated block (32 lines × 3) · ×1
  • 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:108-139 | 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.
D4 · Code Duplication · Duplicated block (32 lines × 2) · ×1
  • Duplicated block (32 lines × 2) tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations_runnable.py:300 — tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations_runnable.py:300-331 | 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.
D4 · Code Duplication · Duplicated block (31 lines × 5) · ×1
  • 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:499-529 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations_runnable.py:465-495 | 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.
D4 · Code Duplication · Duplicated block (26 lines × 5) · ×1
  • 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:474-499 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations_runnable.py:414-439 | 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.
D4 · Code Duplication · Duplicated block (22 lines × 3) · ×1
  • 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:525-546 | 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.
D4 · Code Duplication · Duplicated block (21 lines × 5) · ×1
  • Duplicated block (21 lines × 5) tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:227 — tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:227-247 | 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.
D4 · Code Duplication · Duplicated block (20 lines × 3) · ×1
  • 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:141-160 | 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.
D4 · Code Duplication · Duplicated block (18 lines × 5) · ×1
  • Duplicated block (18 lines × 5) tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:104 — tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:104-121 | 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.
D4 · Code Duplication · Duplicated block (17 lines × 5) · ×1
  • 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:86-102 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations_runnable.py:84-100 | 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:102` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (15 lines × 5) · ×1
  • 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:278-292 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations_runnable.py:235-249 | 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.
D4 · Code Duplication · Duplicated block (14 lines × 5) · ×1
  • 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:502-515 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations_runnable.py:442-455 | 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.
D4 · Code Duplication · Duplicated block (8–13 lines × 2) · ×1
  • 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.
D4 · Code Duplication · Duplicated block (12 lines × 3) · ×1
  • 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:303-314 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations_runnable.py:255-266 — 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.
D4 · Code Duplication · Duplicated block (7 lines × 6) · ×1
  • Duplicated block (7 lines × 6) tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:94 — tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:94-100 | tensor-shapes/pyrefly-torch-stubs/examples/mixtral_moe.py:184-190 | 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.
D4 · Code Duplication · Duplicated block (7 lines × 5) · ×1
  • Duplicated block (7 lines × 5) tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:283 — tensor-shapes/pyrefly-torch-stubs/examples/gptfast.py:283-289 | 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:290` 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.
D4 · Code Duplication · Duplicated block (4–5 lines × 25) · ×1
  • 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.
D4 · Code Duplication · Duplicated block (5 lines × 16) · ×1
  • 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.
D4 · Code Duplication · Duplicated block (5 lines × 5) · ×1
  • 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:336-340 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations_runnable.py:288-292 | 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.
D4 · Code Duplication · Duplicated block (5 lines × 6) · ×1
  • 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:269-273 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations.py:403-407 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/gptfast_future_annotations_runnable.py:390-394 | 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.
D4 · Code Duplication · Duplicated block (10 lines × 5) · ×1
  • 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:324-333 | tensor-shapes/pyrefly-torch-stubs/examples/runtime/nanogpt_future_annotations_runnable.py:276-285 | 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.
D4 · Code Duplication · Duplicated block (5 lines × 7) · ×1
  • 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:1309-1313 — 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.
D4 · Code Duplication · Duplicated block (5 lines × 4) · ×1
  • 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.
R10 · Code Duplication · Duplicated block (10 lines × 2 locations) · ×1
  • 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.
R2 · Cyclomatic Complexity · Complex function runTestAtLocation (cyclomatic 14, cognitive 17) · ×1
  • 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.
R2 · Cyclomatic Complexity · Complex function updateStatusBar (cyclomatic 13, cognitive 13) · ×1
  • 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.
R2 · Cyclomatic Complexity · Complex function selectBinary (cyclomatic 11, cognitive 11) · ×1
  • 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.
R3 · Large Files · Large Files · ×1
  • Large Files — 1 file(s) over 400 lines (counted as significant lines — blank lines excluded — over production source only, tests excluded), largest first: lsp/src/extension.ts (534).
R8 · Dependency Hygiene · Unused dependency '@vscode/test-electron' · ×1
  • 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.
R8 · Dependency Hygiene · Unused dependency 'serialize-javascript' · ×1
  • 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.
R8 · Dependency Hygiene · Unused dependency 'underscore' · ×1
  • 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.
Minor — 16 finding(s)
D16 · Bus Factor · Off-boarding risk · ×4
  • Off-boarding risk: anonymized user #1 — If anonymized user #1 becomes unavailable, 11 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/type_var/flag.rs, pyrefly/lib/alt/shape_flag.rs, tensor-shapes/pyrefly-shape-extensions/shape_extensions/__init__.py, pyrefly/lib/report/cinderx.rs, tensor-shapes/pyrefly-shape-extensions/shape_extensions/torchscript.py (+3 more). Pair on, review, or document these before any departure.
  • Off-boarding risk: anonymized user #2 — If anonymized user #2 becomes unavailable, 10 significant file(s) lose their only recent owner: scripts/primer_classifier/llm_client.py, scripts/compare_typecheckers.py, scripts/issue_ranker/v1_analysis.py, scripts/primer_classifier/formatter.py, scripts/issue_ranker/__main__.py, scripts/issue_ranker/passes/primer_impact.py, scripts/llm_transport.py, scripts/issue_ranker/passes/score.py (+2 more). Pair on, review, or document these before any departure.
  • Off-boarding risk: anonymized user #3 — If anonymized user #3 becomes unavailable, 5 significant file(s) lose their only recent owner: crates/pyrefly_util/src/visit.rs, crates/pyrefly_util/src/watcher.rs, crates/pyrefly_derive/src/visit.rs, crates/pyrefly_derive/src/type_eq.rs, crates/pyrefly_util/src/with_hash.rs. Pair on, review, or document these before any departure.
  • Off-boarding risk: anonymized user #4 — If anonymized user #4 becomes unavailable, 4 significant file(s) lose their only recent owner: pyrefly/lib/lsp/non_wasm/connection.rs, lsp/src/python-environment.ts, crates/pyrefly_util/src/timer.rs, crates/pyrefly_python/src/deprecated_aliases.rs. Pair on, review, or document these before any departure.
D16 · Bus Factor · Further sole-owners (lower concentration) · ×1
  • Further sole-owners (lower concentration) — 12 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 (49 single-owned of 407 analysed files in total, counted over production source files of roughly 2,400 bytes or more, excluding vendored, generated and example/demo trees and test files identified by path convention, largest first; 407 of the 520 production source files in this repository met that bar). They are 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 (2 file(s)), anonymized user #10 (2 file(s)) (+6 more) — spread or document their files in the same way, at lower priority than the named off-boarding risks above.
D20 · ADR Quality · No ADRs found · ×1
  • 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 · Split pyrefly · ×1
  • Split pyrefly — The repository root is already the single large project; its children are under it and not splitable. Suggested:
D28 · Secrets (history) · Rotate the exposed credentials · ×1
  • REDACTED
D29 · Static Analysis (SAST) · REDACTED · ×1
  • REDACTED
D30 · Dependency Vulnerabilities · Low CVE · ×1
  • REDACTED
D34 · Knowledge Freshness · Orphaned files with no living knowledge · ×1
  • Orphaned files with no living knowledge — 15 of 407 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 and example/demo trees and test files identified by path convention, largest first; 407 of the 520 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: scripts/primer_classifier/cross_checker.py, scripts/issue_ranker/passes/rank.py, scripts/issue_ranker/github_issues.py, scripts/issue_ranker/report_formatter.py, scripts/primer_classifier/code_fetcher.py, scripts/issue_ranker/issue_checker.py, scripts/issue_ranker/status_classifier.py, scripts/issue_ranker/pipeline.py (and 7 more). 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.
D36 · Supply-chain Provenance & Signing · REDACTED · ×1
  • REDACTED
D36 · Supply-chain Provenance & Signing · REDACTED · ×1
  • REDACTED
M2 · Architecture documentation · No ADRs · ×1
  • No ADRs — No Architecture Decision Records found — no conventional ADR directory, no numbered `NNNN-title` documents in any markup this check reads, and nothing ADR-shaped by content. Design rationale recorded elsewhere (a design-notes tree, a mailing list, pull-request discussion) is not visible to this check and is not re-findable per decision, so a future maintainer cannot ask why one choice was made and get an answer.
P2 · Observability · Logging is not universal · ×1
  • Logging is not universal — Only 5/10 runnable modules use logging (modules with no entry point or server are excluded — they are libraries a runnable module hosts). Silent: `pyrefly`, `tensor-shapes/pyrefly-einops-stubs`, `tensor-shapes/pyrefly-jax-stubs`, `tensor-shapes/pyrefly-numpy-stubs`, `tensor-shapes/pyrefly-torch-stubs`.
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.
Minor — 1 finding(s)
D12 · Dependency Hygiene · Outdated · ×1
  • Outdated: xxhash-rust — `xxhash-rust` is locked at 0.8.18 but 0.8.19 is the current stable release on crates.io, and it already satisfies the `"0.8.18"` requirement declared in pyrefly/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p xxhash-rust` 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.

DimensionToolVersionCommandFindingsRaw output
D28 · Secrets (history)gitleaks—gitleaks detect --no-banner --config /opt/gitleaks-rules/watchdog-gitleaks.toml --report-format json --report-path /tmp/watchdog-gitleaks-263670e8963146de88d180dd4c0fe7e7/history.json --exit-code 0 --source .3artifacts/raw/gitleaks-history.json
D28 · Secrets (history)gitleaks—gitleaks detect --no-git --no-banner --config /opt/gitleaks-rules/watchdog-gitleaks.toml --report-format json --report-path /tmp/watchdog-gitleaks-263670e8963146de88d180dd4c0fe7e7/tree.json --exit-code 0 --source .2artifacts/raw/gitleaks-tree.json
D29 · Static Analysis (SAST)semgrep—semgrep --config /opt/semgrep-rules/security-audit.yml --config /opt/semgrep-rules/owasp-top-ten.yml --config /opt/semgrep-rules/watchdog-sast.yml --json --quiet --timeout 10 --timeout-threshold 3 --metrics off .151artifacts/raw/semgrep.json
D30 · Dependency Vulnerabilitiestrivy—trivy fs --scanners vuln --format json --quiet --severity CRITICAL,HIGH,MEDIUM,LOW --skip-dirs **/bin/** --skip-dirs **/obj/** . --skip-db-update11artifacts/raw/trivy-fs.json
D31 · IaC & Container Securitytrivy—trivy: not applicable — No Infrastructure-as-Code or container manifests found (Dockerfile, Docker Compose, Terraform, Kubernetes/Helm, CloudFormation, ARM, Bicep, Ansible); nothing to scan.0—
D32 · Data Compliance (PII/GDPR)semgrep—semgrep: not applicable — No personal data was found crossing a boundary the PII/GDPR ruleset checks — nothing written to a log or console sink, placed in a URL or query string, or persisted to browser storage. That is a clean result for the LEAK surface only: this ruleset detects personal data escaping, it does not inventory the personal data a repository holds, so it is not evidence that this repository has no personal-data surface. The personal-data map (Appendix C) and the C1-C5 compliance cards are what speak to that. semgrep could not parse 48 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`, … (+43 more) — so the PII/GDPR sweep did not cover the unparsed regions of them; rows reported elsewhere in those files are real.0—
D37 · Vulnerability-disclosure Policydisclosure—disclosure: not applicable — No vulnerability-disclosure policy file found (SECURITY.md/.markdown/.rst/.txt at root or under .github/.forgejo/.gitea/docs, .well-known/security.txt). A coordinated-disclosure policy may live off-repo, so this is not evidenced rather than failed.0—
D40 · Network Egress Confinementruntime-hardening—runtime-hardening: not applicable — No Kubernetes/orchestration workloads found in the repository manifests; network egress policy is a cluster-native control that may live at the platform/firewall layer, so there is nothing to assess here.0—
D41 · Kernel & Syscall Confinementruntime-hardening—runtime-hardening: not applicable — No Kubernetes/orchestration workloads found in the repository manifests; seccomp/AppArmor/SELinux confinement is a workload-level control, so there is nothing to assess here.0—
D42 · Runtime Threat Enforcementruntime-hardening—runtime-hardening: not applicable — No Kubernetes/orchestration workloads found in the repository manifests; runtime threat-detection and admission-control policy are cluster-level controls, so there is nothing to assess here.0—
D43 · Malicious Dependenciestrivy—trivy fs --scanners vuln --format json --quiet --severity CRITICAL,HIGH,MEDIUM,LOW --skip-dirs **/bin/** --skip-dirs **/obj/** . --skip-db-update0artifacts/raw/trivy-fs.json

Run 01a0edc8-9e4c-787e-bd6c-cff8050637b3 · every finding is also locatable in findings.md, and the complete scoring record (with exit codes + durations) in sidecar.json.

Downloadable artifacts

Machine-readable and reproducible from this commit + frozen rubric — drop them straight into a contract appendix, a CRA dossier, or a downstream SCA / VEX tool.

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