Public report of BoundaryML/baml, published 27 October 2026. It has the same score, grades and number of
findings as the full report. The details of security findings (where they are in the code, which known
vulnerabilities and which passwords or keys were found) are left out, so nobody can use them against the project.
Public
Executive reportMeasured under the Code Assurance Index, an open standard for code quality, using its published scoring rules (rubric version 2026.10.5). Assert signed this survey and filed it in the standard's public register, where anyone can look it up by its survey ID. Check this survey →
Signed and filed in the standard's public register, 27 October 2026, 08:15 UTC · Survey ID cd_950fd46abecc47cda784f6c33b646c0b
BoundaryML/baml
Measured 27 October 2026, 07:59 UTC, at code version 3d20df8
Regression: 2 dimensions fell since the last survey
A regression is a drop of 0.5 points or more in the score, or of 2.5 or more out of 10 in a dimension, since the last survey.
CAI scoreWeak
CriticalWeakAdequateStrongExemplary
Down 2 since the last survey
The score is built from these lenses. Each lens grades one area of the code, such as how easy it is to change or how well it is protected. The weakest lens counts most, so one weak area pulls the score down instead of being averaged away.
A very large codebase: 1,092,280 lines of product code in 239 projects, tests not counted · Estimated rebuild effort: about 9.5 person-years · Weakest lens: Architecture, 44
Findings by how serious they are
739 critical5055 serious279 minor
8 dimensions are left out of the score. For each one, Watchdog either couldn't measure it in this code, or found no evidence of the safeguard it looks for, such as a tested backup restore. They count neither for nor against the score, and Limitations lists each one with its reason.
This survey was produced by
Watchdog
Producer
Canine Development
Analyzer
Watchdog engine 1.0.0
Measured
27 October 2026, 07:59 UTC
A measurement, not a certificate. The Code Assurance Index records a number
together with the evidence it was worked out from, so anyone can recalculate it, but it doesn't certify or guarantee
the code. The standard was written by Canine Development, which also builds Watchdog. It is open to any tool that
implements it, and today Watchdog is the only one that does.
The score is deterministic, which means the same code always gets the same score. Watchdog works it out with tools that follow published rules, and an AI model never decides it, so anyone who applies the same rules to the same code gets the same number. How it is done is explained under Methodology ▸
93of 93 dimensions measured by tools.
6000of 6073 findings point to an exact file and line, so you can open each one in the code. The other 73 concern the repository as a whole, such as missing documentation.
93dimensions across 8 lenses, read from 1,092,280 lines of product code in 239 projects.
BoundaryML/baml falls short of our standard for production, in part because it has pieces of product code that depend on test code. It scores 49 out of 100 and is rated Weak, and 654 of its 739 critical findings are security problems.
Architecture, at 44, is the weakest lens and counts most in the score. The best first step for the work it takes is fixing the two runtimes or frameworks that no longer get security updates, worth about 2 points. Removing the test references would lift Architecture itself, worth about 3 points. Raising Architecture to 70 would lift the score to about 52.
432 pipeline tools are referenced by a changeable name, so the build pipeline can be tampered with. 149 known security holes in the packages the code depends on can be used by attackers, and nineteen weaknesses in the code could be used by an attacker. Pinning each tool to an exact version, updating the vulnerable packages and fixing the weaknesses the scanner points to would close these risks. Passing outside input through environment variables would fix the ten pipeline steps that put outside input straight into a shell command, and limiting each secret to its own step would deal with the nine secrets exposed to more of the pipeline than needed. The 53 data fields that are written but never read need removing.
The product code is 1,092,280 lines, about €1,400,000 to rebuild.
A lens is capped at Adequate while one of its dimensions scores below 4 out of 10, however well the rest of the lens does. That way a serious problem in one place always shows in the lens's rating.
How the score is built: what each lens counts forThe lenses don't count equally. The weakest lens counts most, the next weakest a little less, and so on, so a weak area pulls the score down instead of being averaged away. In the bar below, each part's width shows how much that lens counts and its colour shows its rating. Improving the widest part moves the score most, and as that lens improves, it counts for less, because another lens becomes the weakest.
If Architecture rose from 44 to 70, the lowest score rated Strong, the score would rise from 49 to about 52.
Code composition: what the lines of code are
Business logic 3%Supporting code 4%Tests 93%
New since the last survey: 543 findings
These 543 critical or serious findings weren't in the previous survey, on 13 October 2026. The first 100 are listed here, and the findings file in the download package lists them all.
Watchdog compares every finding with the previous survey's. A finding that has only moved to another line in the same file counts as the same finding, so only new findings appear here. Advisory notes from the AI model are left out, because the model words them afresh in every survey.
Fixed since the last survey: 1615 findings
These 1615 critical or serious findings were in the previous survey, on 13 October 2026, and are gone from this one. The first 100 are listed here.
God Classes · MethodTooLong: BexEngine.convert_external_to_vm_value_with_ty_and_runtime baml_language/crates/bex_engine/src/conversion.rs
God Classes · MethodTooLong: Bytecode.lower_to_compact baml_language/crates/bex_vm_types/src/bytecode.rs
God Classes · FunctionTooLong: bex_project::runtime_compile::lower_session_submission baml_language/crates/bex_project/src/runtime_compile.rs
God Classes · FileTooLong: package_baml/json.rs baml_language/crates/bex_vm/src/package_baml/json.rs
God Classes · MethodTooLong: ProjectRuntimeCompiler.compile baml_language/crates/bex_project/src/runtime_compile.rs
God Classes · MethodTooLong: LoweringContext.lower_pattern_test baml_language/crates/baml_compiler2_mir/src/lower.rs
God Classes · FunctionTooLong: bex_project::runtime_compile::projected_interface baml_language/crates/bex_project/src/runtime_compile.rs
God Classes · FileTooLong: src/runtime.rs engine/language_client_typescript/src/runtime.rs
God Classes · MethodTooLong: BamlRuntime.call_function engine/language_client_typescript/src/runtime.rs
God Classes · FunctionTooLong: bex_vm::package_baml::json::ty_serde_to_value baml_language/crates/bex_vm/src/package_baml/json.rs
God Classes · FunctionTooLong: bex_project::runtime_compile::owned_diagnostic baml_language/crates/bex_project/src/runtime_compile.rs
God Classes · MethodTooLong: InferenceContext.item_projection_value baml_language/crates/baml_compiler2_hir_ty/src/infer.rs
God Classes · MethodTooLong: BamlRuntime.call_function_sync engine/language_client_typescript/src/runtime.rs
God Classes · FunctionTooLong: bex_vm::package_baml::json::ty_value_to_serde baml_language/crates/bex_vm/src/package_baml/json.rs
God Classes · FunctionTooLong: bex_vm::package_baml::json::render_to_serde baml_language/crates/bex_vm/src/package_baml/json.rs
God Classes · FunctionTooLong: bex_project::runtime_compile::rewrite_identifiers baml_language/crates/bex_project/src/runtime_compile.rs
God Classes · FunctionTooLong: sdkgen_python_pydantic2::emit::build_emitted baml_language/sdks/python/rust/sdkgen_python_pydantic2/src/emit/mod.rs
God Classes · MethodTooLong: TypeCtx.convert_ty baml_language/crates/bex_sap/src/sap_model/convert.rs
Code Duplication · Near-duplicate member pair (49 shared lines) baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs
Code Duplication · Edited copy of a member (37 corresponding lines) baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs
Code Duplication · Edited copy of a member (32 corresponding lines) baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs
Code Duplication · Edited copy of a member (23 corresponding lines) baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs
Code Duplication · Edited copy of a member (20 corresponding lines) baml_language/crates/bex_vm/src/package_reflect/reflect.rs
Code Duplication · Members sharing a duplicated core (9 members, 50+ identical tokens) engine/language_client_typescript/src/runtime.rs
Code Duplication · Members sharing a duplicated core (8 members, 50+ identical tokens) baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs
Code Duplication · Members sharing a duplicated core (8 members, 50+ identical tokens) baml_language/crates/baml_compiler2_visualization/src/control_flow/from_ast.rs
Code Duplication · Members sharing a duplicated core (7 members, 50+ identical tokens) baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift
Code Duplication · Members sharing a duplicated core (6 members, 50+ identical tokens) baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift
Code Duplication · Members sharing a duplicated core (5 members, 50+ identical tokens) baml_language/crates/baml_compiler2_mir/src/lower.rs
Code Duplication · Members sharing a duplicated core (5 members, 50+ identical tokens) baml_language/crates/baml_compiler_parser/src/parser.rs
Code Duplication · Members sharing a duplicated core (5 members, 50+ identical tokens) baml_language/crates/baml_type/src/normalize.rs
Code Duplication · Members sharing a duplicated core (5 members, 50+ identical tokens) baml_language/sdks/go/baml_go/class.go
Code Duplication · Members sharing a duplicated core (5 members, 50+ identical tokens) baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift
Code Duplication · Members sharing a duplicated core (5 members, 50+ identical tokens) baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift
Code Duplication · Members sharing a duplicated core (4 members, 50+ identical tokens) baml_language/crates/baml_base/src/escape.rs
Code Duplication · Members sharing a duplicated core (4 members, 50+ identical tokens) baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs
Code Duplication · Members sharing a duplicated core (4 members, 50+ identical tokens) baml_language/crates/baml_compiler2_mir/src/lower.rs
Rebuild cost: about €1,400,000 · Estimate
Cost to rebuild
€460,000 to €2,300,000, for 7,674 to 24,356 hours of work, about 9.5 person-years for 5 to 19 engineers
Difficulty of the problem
Standard, judged from the kind of software and how it is built. Code that solves a harder problem, such as payments or medical bookings, costs more per line to write.
Quality factor
×0.7 at a score of 49. Better code takes more work to write, so the factor is ×1.0 at a score of 70, lower below it and higher above it.
Size
Very large: 1,092,280 lines of product code
Comment lines
The estimate prices 1,078,012 lines. Comment lines count towards the size of 1,092,280 lines but aren't priced as work.
What it is not
Not a quotation: nobody has offered to build it for that. Not a valuation: it says nothing about what the business is worth. Not a certified figure: no professional has signed it as one.
How the estimate is made: Watchdog prices the hours a team would need to write this code again, at €60 to €95 an hour. Declarations and boilerplate are priced at a fast rate and logic at a slower one, and the logic is then multiplied by the difficulty of the problem and by the quality factor. The estimate can be about 30% off either way, and it moves most with the hourly rate and the difficulty.
Top priorities
The three actions that raise the score most for the work they take. The full ranked list is in the Roadmap.
1
Resolve the 2 End-of-life runtime finding(s) in Platform End-of-Life — start with REDACTED (2).
Remove every production → test project reference: extract any shared test helper into a production support library (which the tests reference), or invert the dependency so the test project depends on production — not the reverse.
Raises the score by about 3 points · Medium effort · Test isolation
3
Fix the listed violations: import through the target package's declared public entry rather than a deep path into its internals or a relative path into its directory (12 rows); move the shared test helper into a source directory production code may depend on (9 rows); respect the layer/slice order — import only through a slice's public index and never upward into a higher layer (5 rows).
Raises the score by about 3 points · Medium effort · Import Boundaries
Diagnosis: what the measurements show together
Each conclusion below combines several dimensions into one point that no single dimension shows, and lists the measurements it rests on.
Where the investment is most exposed · Value at risk
This code would cost about €1,400,000 to build again, about 9.5 person-years of work. Its weakest lens is Architecture, at 44 (Weak). Architecture is about whether the structure holds up as the product grows, and when the structure is weak, a change in one place ripples into many others. Because the weakest lens counts most in the score, work on Architecture also moves the score most.
Based on: the rebuild estimate · the Architecture grade · how much each lens counts
What to do: Start with the Architecture actions in Top priorities.
If you do one thing first · First action
Resolve the 2 End-of-life runtime finding(s) in Platform End-of-Life. Of all the actions in this report, it raises the score most for the work it takes: about 2 points for low effort, because it clears the 2 Platform End-of-Life findings. The next survey will show the change in the score.
Based on: the ranked actions in Top priorities, by score gain and effort
What hard-to-read code costs each year · Cost
Four dimensions measure how easy the code is to work in: two measure how tangled its logic is, one how much of it is copied, and one how well each part sticks to a single job. In this codebase they average 6.4 out of 10. Code at that level is slower to change than clean code, and Watchdog estimates the extra work at 4% to 9% on every change. The history of the code shows how much it changes: about 1,161,441 lines over the last 90 days, which is about 4,710,288 lines a year. At that pace, the extra work comes to an estimated 476.6 to 2859.3 engineer-days a year, and it grows as more code changes.
How this is estimated: The number of changed lines is measured from the history of the code. The rest rests on two assumptions of Watchdog's own: code scoring 8 out of 10 or more adds no extra work, and each point below 8 adds 2.5% to 5.6% to every change, never less than 2% to 5% and never more than 40% to 60% in all; and an engineer changes 150 to 400 lines in a day. The result is a range for planning, not a measurement.
Based on: Cyclomatic Complexity · Cognitive Complexity · Code Duplication · Cohesion (LCOM4) · the code's change history
What to do: Start with the files listed under Churn × Complexity Hotspots, which change often and are hard to read, because that is where the extra work is paid most often.
Architecture — module dependency graph
Project dependencies, layered top-to-bottom; arrows show direction. Any dashed red edge points upward or sideways, which only happens where the projects form a dependency cycle. A graph without cycles has none.
Architecture: which parts of the code depend on which
The code is divided into modules, groups of code that each handle one part of the product, and a module depends on another when it uses code from it. The table lists the modules both down the side and across the top, in an order where each module should only use modules listed above it. A number in a cell means the module on that row uses the module in that column, and it counts the pairs of building blocks (types) that connect them. The one thing to look for is a mark above the diagonal line. It means two or more modules use each other in a loop (a dependency cycle), so none of them can be changed, tested or released on its own.
2567 modules, with 7852 dependencies between them. 10 loops run through 537 of the modules, marked above the diagonal.
The table shows the 40 modules with the most connections; 2527 more are left out to keep it readable.
Which modules use which. The module on each row uses the module in each column, and the number counts the pairs of types that connect them. A cell above the diagonal is part of a loop.
baml_query.value.model uses baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result, so a change to baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result can break baml_query.value.model, while a change to baml_query.value.model can't break baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
2→20 bex_chunkedringbuffer uses baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_resultpart of a loop✕
Connections
1 pair of types, where a type in bex_chunkedringbuffer uses a type in baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result.
bex_chunkedringbuffer uses baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result, so a change to baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result can break bex_chunkedringbuffer, while a change to bex_chunkedringbuffer can't break baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
2→28 bex_chunkedringbuffer uses bamlpart of a loop✕
Connections
3 pairs of types, where a type in bex_chunkedringbuffer uses a type in baml.
The types involved
bex_chunkedringbuffer.ChunkPool → baml.Config
bex_chunkedringbuffer.Shared → baml.Config
bex_chunkedringbuffer.Shared → baml.State
Direction
bex_chunkedringbuffer uses baml, so a change to baml can break bex_chunkedringbuffer, while a change to bex_chunkedringbuffer can't break baml.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
3→20 internal_baml_ast.formatter uses baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_resultpart of a loop✕
Connections
2 pairs of types, where a type in internal_baml_ast.formatter uses a type in baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result.
internal_baml_ast.formatter uses baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result, so a change to baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result can break internal_baml_ast.formatter, while a change to internal_baml_ast.formatter can't break baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
baml_runtime.internal.llm_client.primitive.google.types uses baml_query.value.model, so a change to baml_query.value.model can break baml_runtime.internal.llm_client.primitive.google.types, while a change to baml_runtime.internal.llm_client.primitive.google.types can't break baml_query.value.model.
Position
Below the diagonal: baml_runtime.internal.llm_client.primitive.google.types uses a module listed above it, which is the healthy direction.
baml_type.interned uses internal_baml_ast.formatter, so a change to internal_baml_ast.formatter can break baml_type.interned, while a change to baml_type.interned can't break internal_baml_ast.formatter.
Position
Below the diagonal: baml_type.interned uses a module listed above it, which is the healthy direction.
5→20 baml_type.interned uses baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_resultpart of a loop✕
Connections
3 pairs of types, where a type in baml_type.interned uses a type in baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result.
baml_type.interned uses baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result, so a change to baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result can break baml_type.interned, while a change to baml_type.interned can't break baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
bex_vm_types.errors uses baml_query.value.model, so a change to baml_query.value.model can break bex_vm_types.errors, while a change to bex_vm_types.errors can't break baml_query.value.model.
Position
Below the diagonal: bex_vm_types.errors uses a module listed above it, which is the healthy direction.
baml_compiler2_hir_ty.infer.unify uses baml_type.interned, so a change to baml_type.interned can break baml_compiler2_hir_ty.infer.unify, while a change to baml_compiler2_hir_ty.infer.unify can't break baml_type.interned.
Position
Below the diagonal: baml_compiler2_hir_ty.infer.unify uses a module listed above it, which is the healthy direction.
7→20 baml_compiler2_hir_ty.infer.unify uses baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_resultpart of a loop✕
Connections
2 pairs of types, where a type in baml_compiler2_hir_ty.infer.unify uses a type in baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result.
baml_compiler2_hir_ty.infer.unify uses baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result, so a change to baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result can break baml_compiler2_hir_ty.infer.unify, while a change to baml_compiler2_hir_ty.infer.unify can't break baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
language_server.baml_text_size.range uses internal_baml_ast.formatter, so a change to internal_baml_ast.formatter can break language_server.baml_text_size.range, while a change to language_server.baml_text_size.range can't break internal_baml_ast.formatter.
Position
Below the diagonal: language_server.baml_text_size.range uses a module listed above it, which is the healthy direction.
language_server.baml_text_size.range uses baml_compiler2_hir_ty.infer.unify, so a change to baml_compiler2_hir_ty.infer.unify can break language_server.baml_text_size.range, while a change to language_server.baml_text_size.range can't break baml_compiler2_hir_ty.infer.unify.
Position
Below the diagonal: language_server.baml_text_size.range uses a module listed above it, which is the healthy direction.
8→20 language_server.baml_text_size.range uses baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_resultpart of a loop✕
Connections
1 pair of types, where a type in language_server.baml_text_size.range uses a type in baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result.
language_server.baml_text_size.range uses baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result, so a change to baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result can break language_server.baml_text_size.range, while a change to language_server.baml_text_size.range can't break baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
baml_compiler2_ast.ast uses internal_baml_ast.formatter, so a change to internal_baml_ast.formatter can break baml_compiler2_ast.ast, while a change to baml_compiler2_ast.ast can't break internal_baml_ast.formatter.
Position
Below the diagonal: baml_compiler2_ast.ast uses a module listed above it, which is the healthy direction.
26 pairs of types, where a type in baml_compiler2_ast.ast uses a type in language_server.baml_text_size.range. Showing 25 of them; the rest are in namespace-graph.json in this report's bundle.
baml_compiler2_ast.ast uses language_server.baml_text_size.range, so a change to language_server.baml_text_size.range can break baml_compiler2_ast.ast, while a change to baml_compiler2_ast.ast can't break language_server.baml_text_size.range.
Position
Below the diagonal: baml_compiler2_ast.ast uses a module listed above it, which is the healthy direction.
9→13 baml_compiler2_ast.ast uses internal_baml_jinja.output_format.typespart of a loop✕
Connections
24 pairs of types, where a type in baml_compiler2_ast.ast uses a type in internal_baml_jinja.output_format.types.
baml_compiler2_ast.ast uses internal_baml_jinja.output_format.types, so a change to internal_baml_jinja.output_format.types can break baml_compiler2_ast.ast, while a change to baml_compiler2_ast.ast can't break internal_baml_jinja.output_format.types.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
9→20 baml_compiler2_ast.ast uses baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_resultpart of a loop✕
Connections
4 pairs of types, where a type in baml_compiler2_ast.ast uses a type in baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result.
baml_compiler2_ast.ast uses baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result, so a change to baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result can break baml_compiler2_ast.ast, while a change to baml_compiler2_ast.ast can't break baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
91 pairs of types, where a type in baml_fmt.ast.tokens uses a type in internal_baml_ast.formatter. Showing 25 of them; the rest are in namespace-graph.json in this report's bundle.
baml_fmt.ast.tokens uses internal_baml_ast.formatter, so a change to internal_baml_ast.formatter can break baml_fmt.ast.tokens, while a change to baml_fmt.ast.tokens can't break internal_baml_ast.formatter.
Position
Below the diagonal: baml_fmt.ast.tokens uses a module listed above it, which is the healthy direction.
105 pairs of types, where a type in baml_fmt.ast.tokens uses a type in language_server.baml_text_size.range. Showing 25 of them; the rest are in namespace-graph.json in this report's bundle.
baml_fmt.ast.tokens uses language_server.baml_text_size.range, so a change to language_server.baml_text_size.range can break baml_fmt.ast.tokens, while a change to baml_fmt.ast.tokens can't break language_server.baml_text_size.range.
Position
Below the diagonal: baml_fmt.ast.tokens uses a module listed above it, which is the healthy direction.
10→20 baml_fmt.ast.tokens uses baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_resultpart of a loop✕
Connections
104 pairs of types, where a type in baml_fmt.ast.tokens uses a type in baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result. Showing 25 of them; the rest are in namespace-graph.json in this report's bundle.
baml_fmt.ast.tokens uses baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result, so a change to baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result can break baml_fmt.ast.tokens, while a change to baml_fmt.ast.tokens can't break baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
baml_compiler2_hir.item_tree.classes uses language_server.baml_text_size.range, so a change to language_server.baml_text_size.range can break baml_compiler2_hir.item_tree.classes, while a change to baml_compiler2_hir.item_tree.classes can't break language_server.baml_text_size.range.
Position
Below the diagonal: baml_compiler2_hir.item_tree.classes uses a module listed above it, which is the healthy direction.
baml_compiler2_hir.item_tree.classes uses baml_compiler2_ast.ast, so a change to baml_compiler2_ast.ast can break baml_compiler2_hir.item_tree.classes, while a change to baml_compiler2_hir.item_tree.classes can't break baml_compiler2_ast.ast.
Position
Below the diagonal: baml_compiler2_hir.item_tree.classes uses a module listed above it, which is the healthy direction.
11→13 baml_compiler2_hir.item_tree.classes uses internal_baml_jinja.output_format.typespart of a loop✕
Connections
2 pairs of types, where a type in baml_compiler2_hir.item_tree.classes uses a type in internal_baml_jinja.output_format.types.
baml_compiler2_hir.item_tree.classes uses internal_baml_jinja.output_format.types, so a change to internal_baml_jinja.output_format.types can break baml_compiler2_hir.item_tree.classes, while a change to baml_compiler2_hir.item_tree.classes can't break internal_baml_jinja.output_format.types.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
baml_compiler_syntax.ast uses language_server.baml_text_size.range, so a change to language_server.baml_text_size.range can break baml_compiler_syntax.ast, while a change to baml_compiler_syntax.ast can't break language_server.baml_text_size.range.
Position
Below the diagonal: baml_compiler_syntax.ast uses a module listed above it, which is the healthy direction.
baml_compiler_syntax.ast uses baml_compiler2_ast.ast, so a change to baml_compiler2_ast.ast can break baml_compiler_syntax.ast, while a change to baml_compiler_syntax.ast can't break baml_compiler2_ast.ast.
Position
Below the diagonal: baml_compiler_syntax.ast uses a module listed above it, which is the healthy direction.
internal_baml_jinja.output_format.types uses baml_query.value.model, so a change to baml_query.value.model can break internal_baml_jinja.output_format.types, while a change to internal_baml_jinja.output_format.types can't break baml_query.value.model.
Position
Below the diagonal: internal_baml_jinja.output_format.types uses a module listed above it, which is the healthy direction.
internal_baml_jinja.output_format.types uses internal_baml_ast.formatter, so a change to internal_baml_ast.formatter can break internal_baml_jinja.output_format.types, while a change to internal_baml_jinja.output_format.types can't break internal_baml_ast.formatter.
Position
Below the diagonal: internal_baml_jinja.output_format.types uses a module listed above it, which is the healthy direction.
internal_baml_jinja.output_format.types uses baml_compiler2_hir.item_tree.classes, so a change to baml_compiler2_hir.item_tree.classes can break internal_baml_jinja.output_format.types, while a change to internal_baml_jinja.output_format.types can't break baml_compiler2_hir.item_tree.classes.
Position
Below the diagonal: internal_baml_jinja.output_format.types uses a module listed above it, which is the healthy direction.
internal_baml_jinja.output_format.types uses baml_compiler_syntax.ast, so a change to baml_compiler_syntax.ast can break internal_baml_jinja.output_format.types, while a change to internal_baml_jinja.output_format.types can't break baml_compiler_syntax.ast.
Position
Below the diagonal: internal_baml_jinja.output_format.types uses a module listed above it, which is the healthy direction.
13→20 internal_baml_jinja.output_format.types uses baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_resultpart of a loop✕
Connections
7 pairs of types, where a type in internal_baml_jinja.output_format.types uses a type in baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result.
internal_baml_jinja.output_format.types uses baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result, so a change to baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result can break internal_baml_jinja.output_format.types, while a change to internal_baml_jinja.output_format.types can't break baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
baml_base.core_types uses internal_baml_ast.formatter, so a change to internal_baml_ast.formatter can break baml_base.core_types, while a change to baml_base.core_types can't break internal_baml_ast.formatter.
Position
Below the diagonal: baml_base.core_types uses a module listed above it, which is the healthy direction.
baml_base.core_types uses language_server.baml_text_size.range, so a change to language_server.baml_text_size.range can break baml_base.core_types, while a change to baml_base.core_types can't break language_server.baml_text_size.range.
Position
Below the diagonal: baml_base.core_types uses a module listed above it, which is the healthy direction.
baml_base.core_types uses internal_baml_jinja.output_format.types, so a change to internal_baml_jinja.output_format.types can break baml_base.core_types, while a change to baml_base.core_types can't break internal_baml_jinja.output_format.types.
Position
Below the diagonal: baml_base.core_types uses a module listed above it, which is the healthy direction.
14→20 baml_base.core_types uses baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_resultpart of a loop✕
Connections
5 pairs of types, where a type in baml_base.core_types uses a type in baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result.
baml_base.core_types uses baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result, so a change to baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result can break baml_base.core_types, while a change to baml_base.core_types can't break baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
baml_compiler2_hir.item_tree.functions uses language_server.baml_text_size.range, so a change to language_server.baml_text_size.range can break baml_compiler2_hir.item_tree.functions, while a change to baml_compiler2_hir.item_tree.functions can't break language_server.baml_text_size.range.
Position
Below the diagonal: baml_compiler2_hir.item_tree.functions uses a module listed above it, which is the healthy direction.
baml_compiler2_hir.item_tree.functions uses baml_compiler2_ast.ast, so a change to baml_compiler2_ast.ast can break baml_compiler2_hir.item_tree.functions, while a change to baml_compiler2_hir.item_tree.functions can't break baml_compiler2_ast.ast.
Position
Below the diagonal: baml_compiler2_hir.item_tree.functions uses a module listed above it, which is the healthy direction.
baml_compiler2_hir.item_tree.functions uses internal_baml_jinja.output_format.types, so a change to internal_baml_jinja.output_format.types can break baml_compiler2_hir.item_tree.functions, while a change to baml_compiler2_hir.item_tree.functions can't break internal_baml_jinja.output_format.types.
Position
Below the diagonal: baml_compiler2_hir.item_tree.functions uses a module listed above it, which is the healthy direction.
baml_base.files uses internal_baml_ast.formatter, so a change to internal_baml_ast.formatter can break baml_base.files, while a change to baml_base.files can't break internal_baml_ast.formatter.
Position
Below the diagonal: baml_base.files uses a module listed above it, which is the healthy direction.
baml_base.files uses internal_baml_jinja.output_format.types, so a change to internal_baml_jinja.output_format.types can break baml_base.files, while a change to baml_base.files can't break internal_baml_jinja.output_format.types.
Position
Below the diagonal: baml_base.files uses a module listed above it, which is the healthy direction.
baml_base.files uses baml_base.core_types, so a change to baml_base.core_types can break baml_base.files, while a change to baml_base.files can't break baml_base.core_types.
Position
Below the diagonal: baml_base.files uses a module listed above it, which is the healthy direction.
16→20 baml_base.files uses baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_resultpart of a loop✕
Connections
1 pair of types, where a type in baml_base.files uses a type in baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result.
baml_base.files uses baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result, so a change to baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result can break baml_base.files, while a change to baml_base.files can't break baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
internal_baml_core.ir.repr uses baml_query.value.model, so a change to baml_query.value.model can break internal_baml_core.ir.repr, while a change to internal_baml_core.ir.repr can't break baml_query.value.model.
Position
Below the diagonal: internal_baml_core.ir.repr uses a module listed above it, which is the healthy direction.
internal_baml_core.ir.repr uses bex_chunkedringbuffer, so a change to bex_chunkedringbuffer can break internal_baml_core.ir.repr, while a change to internal_baml_core.ir.repr can't break bex_chunkedringbuffer.
Position
Below the diagonal: internal_baml_core.ir.repr uses a module listed above it, which is the healthy direction.
internal_baml_core.ir.repr uses baml_compiler2_ast.ast, so a change to baml_compiler2_ast.ast can break internal_baml_core.ir.repr, while a change to internal_baml_core.ir.repr can't break baml_compiler2_ast.ast.
Position
Below the diagonal: internal_baml_core.ir.repr uses a module listed above it, which is the healthy direction.
internal_baml_core.ir.repr uses baml_fmt.ast.tokens, so a change to baml_fmt.ast.tokens can break internal_baml_core.ir.repr, while a change to internal_baml_core.ir.repr can't break baml_fmt.ast.tokens.
Position
Below the diagonal: internal_baml_core.ir.repr uses a module listed above it, which is the healthy direction.
internal_baml_core.ir.repr uses baml_compiler2_hir.item_tree.classes, so a change to baml_compiler2_hir.item_tree.classes can break internal_baml_core.ir.repr, while a change to internal_baml_core.ir.repr can't break baml_compiler2_hir.item_tree.classes.
Position
Below the diagonal: internal_baml_core.ir.repr uses a module listed above it, which is the healthy direction.
internal_baml_core.ir.repr uses baml_compiler_syntax.ast, so a change to baml_compiler_syntax.ast can break internal_baml_core.ir.repr, while a change to internal_baml_core.ir.repr can't break baml_compiler_syntax.ast.
Position
Below the diagonal: internal_baml_core.ir.repr uses a module listed above it, which is the healthy direction.
internal_baml_core.ir.repr uses baml_base.core_types, so a change to baml_base.core_types can break internal_baml_core.ir.repr, while a change to internal_baml_core.ir.repr can't break baml_base.core_types.
Position
Below the diagonal: internal_baml_core.ir.repr uses a module listed above it, which is the healthy direction.
internal_baml_core.ir.repr uses baml_compiler2_hir.item_tree.functions, so a change to baml_compiler2_hir.item_tree.functions can break internal_baml_core.ir.repr, while a change to internal_baml_core.ir.repr can't break baml_compiler2_hir.item_tree.functions.
Position
Below the diagonal: internal_baml_core.ir.repr uses a module listed above it, which is the healthy direction.
internal_baml_core.ir.repr uses baml_base.files, so a change to baml_base.files can break internal_baml_core.ir.repr, while a change to internal_baml_core.ir.repr can't break baml_base.files.
Position
Below the diagonal: internal_baml_core.ir.repr uses a module listed above it, which is the healthy direction.
17→18 internal_baml_core.ir.repr uses bex_sap.baml_valuepart of a loop✕
Connections
2 pairs of types, where a type in internal_baml_core.ir.repr uses a type in bex_sap.baml_value.
internal_baml_core.ir.repr uses bex_sap.baml_value, so a change to bex_sap.baml_value can break internal_baml_core.ir.repr, while a change to internal_baml_core.ir.repr can't break bex_sap.baml_value.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
17→20 internal_baml_core.ir.repr uses baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_resultpart of a loop✕
Connections
4 pairs of types, where a type in internal_baml_core.ir.repr uses a type in baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result.
internal_baml_core.ir.repr uses baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result, so a change to baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result can break internal_baml_core.ir.repr, while a change to internal_baml_core.ir.repr can't break baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
bex_sap.baml_value uses baml_query.value.model, so a change to baml_query.value.model can break bex_sap.baml_value, while a change to bex_sap.baml_value can't break baml_query.value.model.
Position
Below the diagonal: bex_sap.baml_value uses a module listed above it, which is the healthy direction.
bex_sap.baml_value uses internal_baml_core.ir.repr, so a change to internal_baml_core.ir.repr can break bex_sap.baml_value, while a change to bex_sap.baml_value can't break internal_baml_core.ir.repr.
Position
Below the diagonal: bex_sap.baml_value uses a module listed above it, which is the healthy direction.
18→20 bex_sap.baml_value uses baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_resultpart of a loop✕
Connections
13 pairs of types, where a type in bex_sap.baml_value uses a type in baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result.
bex_sap.baml_value uses baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result, so a change to baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result can break bex_sap.baml_value, while a change to bex_sap.baml_value can't break baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
baml_runtime.types.runtime_context uses bex_sap.baml_value, so a change to bex_sap.baml_value can break baml_runtime.types.runtime_context, while a change to baml_runtime.types.runtime_context can't break bex_sap.baml_value.
Position
Below the diagonal: baml_runtime.types.runtime_context uses a module listed above it, which is the healthy direction.
19→20 baml_runtime.types.runtime_context uses baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_resultpart of a loop✕
Connections
1 pair of types, where a type in baml_runtime.types.runtime_context uses a type in baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result.
baml_runtime.types.runtime_context uses baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result, so a change to baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result can break baml_runtime.types.runtime_context, while a change to baml_runtime.types.runtime_context can't break baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result uses baml_runtime.types.runtime_context, so a change to baml_runtime.types.runtime_context can break baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result, while a change to baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result can't break baml_runtime.types.runtime_context.
Position
Below the diagonal: baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result uses a module listed above it, which is the healthy direction.
baml_artifact uses internal_baml_ast.formatter, so a change to internal_baml_ast.formatter can break baml_artifact, while a change to baml_artifact can't break internal_baml_ast.formatter.
Position
Below the diagonal: baml_artifact uses a module listed above it, which is the healthy direction.
baml_artifact uses baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result, so a change to baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result can break baml_artifact, while a change to baml_artifact can't break baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result.
Position
Below the diagonal: baml_artifact uses a module listed above it, which is the healthy direction.
baml_compiler2_hir.contributions uses internal_baml_ast.formatter, so a change to internal_baml_ast.formatter can break baml_compiler2_hir.contributions, while a change to baml_compiler2_hir.contributions can't break internal_baml_ast.formatter.
Position
Below the diagonal: baml_compiler2_hir.contributions uses a module listed above it, which is the healthy direction.
baml_compiler2_hir.contributions uses language_server.baml_text_size.range, so a change to language_server.baml_text_size.range can break baml_compiler2_hir.contributions, while a change to baml_compiler2_hir.contributions can't break language_server.baml_text_size.range.
Position
Below the diagonal: baml_compiler2_hir.contributions uses a module listed above it, which is the healthy direction.
baml_compiler2_hir.contributions uses baml_base.files, so a change to baml_base.files can break baml_compiler2_hir.contributions, while a change to baml_compiler2_hir.contributions can't break baml_base.files.
Position
Below the diagonal: baml_compiler2_hir.contributions uses a module listed above it, which is the healthy direction.
baml_compiler2_hir.contributions uses baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result, so a change to baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result can break baml_compiler2_hir.contributions, while a change to baml_compiler2_hir.contributions can't break baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result.
Position
Below the diagonal: baml_compiler2_hir.contributions uses a module listed above it, which is the healthy direction.
baml_compiler2_hir.loc uses internal_baml_ast.formatter, so a change to internal_baml_ast.formatter can break baml_compiler2_hir.loc, while a change to baml_compiler2_hir.loc can't break internal_baml_ast.formatter.
Position
Below the diagonal: baml_compiler2_hir.loc uses a module listed above it, which is the healthy direction.
baml_compiler2_hir.loc uses baml_base.files, so a change to baml_base.files can break baml_compiler2_hir.loc, while a change to baml_compiler2_hir.loc can't break baml_base.files.
Position
Below the diagonal: baml_compiler2_hir.loc uses a module listed above it, which is the healthy direction.
baml_compiler2_hir.loc uses baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result, so a change to baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result can break baml_compiler2_hir.loc, while a change to baml_compiler2_hir.loc can't break baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result.
Position
Below the diagonal: baml_compiler2_hir.loc uses a module listed above it, which is the healthy direction.
bex_events.run uses internal_baml_ast.formatter, so a change to internal_baml_ast.formatter can break bex_events.run, while a change to bex_events.run can't break internal_baml_ast.formatter.
Position
Below the diagonal: bex_events.run uses a module listed above it, which is the healthy direction.
bex_events.run uses baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result, so a change to baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result can break bex_events.run, while a change to bex_events.run can't break baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result.
Position
Below the diagonal: bex_events.run uses a module listed above it, which is the healthy direction.
bex_external_types.bex_external_value uses internal_baml_ast.formatter, so a change to internal_baml_ast.formatter can break bex_external_types.bex_external_value, while a change to bex_external_types.bex_external_value can't break internal_baml_ast.formatter.
Position
Below the diagonal: bex_external_types.bex_external_value uses a module listed above it, which is the healthy direction.
bex_external_types.bex_external_value uses baml_base.core_types, so a change to baml_base.core_types can break bex_external_types.bex_external_value, while a change to bex_external_types.bex_external_value can't break baml_base.core_types.
Position
Below the diagonal: bex_external_types.bex_external_value uses a module listed above it, which is the healthy direction.
bex_external_types.bex_external_value uses baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result, so a change to baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result can break bex_external_types.bex_external_value, while a change to bex_external_types.bex_external_value can't break baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result.
Position
Below the diagonal: bex_external_types.bex_external_value uses a module listed above it, which is the healthy direction.
bex_vm_types.types.object uses internal_baml_ast.formatter, so a change to internal_baml_ast.formatter can break bex_vm_types.types.object, while a change to bex_vm_types.types.object can't break internal_baml_ast.formatter.
Position
Below the diagonal: bex_vm_types.types.object uses a module listed above it, which is the healthy direction.
bex_vm_types.types.object uses baml_compiler2_ast.ast, so a change to baml_compiler2_ast.ast can break bex_vm_types.types.object, while a change to bex_vm_types.types.object can't break baml_compiler2_ast.ast.
Position
Below the diagonal: bex_vm_types.types.object uses a module listed above it, which is the healthy direction.
bex_vm_types.types.object uses baml_compiler_syntax.ast, so a change to baml_compiler_syntax.ast can break bex_vm_types.types.object, while a change to bex_vm_types.types.object can't break baml_compiler_syntax.ast.
Position
Below the diagonal: bex_vm_types.types.object uses a module listed above it, which is the healthy direction.
bex_vm_types.types.object uses baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result, so a change to baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result can break bex_vm_types.types.object, while a change to bex_vm_types.types.object can't break baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result.
Position
Below the diagonal: bex_vm_types.types.object uses a module listed above it, which is the healthy direction.
generators_go.package uses internal_baml_ast.formatter, so a change to internal_baml_ast.formatter can break generators_go.package, while a change to generators_go.package can't break internal_baml_ast.formatter.
Position
Below the diagonal: generators_go.package uses a module listed above it, which is the healthy direction.
generators_go.package uses internal_baml_core.ir.repr, so a change to internal_baml_core.ir.repr can break generators_go.package, while a change to generators_go.package can't break internal_baml_core.ir.repr.
Position
Below the diagonal: generators_go.package uses a module listed above it, which is the healthy direction.
generators_go.package uses baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result, so a change to baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result can break generators_go.package, while a change to generators_go.package can't break baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result.
Position
Below the diagonal: generators_go.package uses a module listed above it, which is the healthy direction.
baml uses baml_runtime.internal.llm_client.primitive.google.types, so a change to baml_runtime.internal.llm_client.primitive.google.types can break baml, while a change to baml can't break baml_runtime.internal.llm_client.primitive.google.types.
Position
Below the diagonal: baml uses a module listed above it, which is the healthy direction.
baml uses baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result, so a change to baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result can break baml, while a change to baml can't break baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result.
Position
Below the diagonal: baml uses a module listed above it, which is the healthy direction.
baml_compiler2_mir.ir uses internal_baml_ast.formatter, so a change to internal_baml_ast.formatter can break baml_compiler2_mir.ir, while a change to baml_compiler2_mir.ir can't break internal_baml_ast.formatter.
Position
Below the diagonal: baml_compiler2_mir.ir uses a module listed above it, which is the healthy direction.
baml_compiler2_mir.ir uses internal_baml_jinja.output_format.types, so a change to internal_baml_jinja.output_format.types can break baml_compiler2_mir.ir, while a change to baml_compiler2_mir.ir can't break internal_baml_jinja.output_format.types.
Position
Below the diagonal: baml_compiler2_mir.ir uses a module listed above it, which is the healthy direction.
baml_compiler2_mir.ir uses baml_base.core_types, so a change to baml_base.core_types can break baml_compiler2_mir.ir, while a change to baml_compiler2_mir.ir can't break baml_base.core_types.
Position
Below the diagonal: baml_compiler2_mir.ir uses a module listed above it, which is the healthy direction.
baml_compiler2_mir.ir uses baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result, so a change to baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result can break baml_compiler2_mir.ir, while a change to baml_compiler2_mir.ir can't break baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result.
Position
Below the diagonal: baml_compiler2_mir.ir uses a module listed above it, which is the healthy direction.
baml_compiler2_mir.ir uses baml_artifact, so a change to baml_artifact can break baml_compiler2_mir.ir, while a change to baml_compiler2_mir.ir can't break baml_artifact.
Position
Below the diagonal: baml_compiler2_mir.ir uses a module listed above it, which is the healthy direction.
baml_lsp_server.lsp_ingress uses baml_query.value.model, so a change to baml_query.value.model can break baml_lsp_server.lsp_ingress, while a change to baml_lsp_server.lsp_ingress can't break baml_query.value.model.
Position
Below the diagonal: baml_lsp_server.lsp_ingress uses a module listed above it, which is the healthy direction.
baml_lsp_server.lsp_ingress uses baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result, so a change to baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result can break baml_lsp_server.lsp_ingress, while a change to baml_lsp_server.lsp_ingress can't break baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result.
Position
Below the diagonal: baml_lsp_server.lsp_ingress uses a module listed above it, which is the healthy direction.
baml_lsp_server.lsp_ingress uses bex_events.run, so a change to bex_events.run can break baml_lsp_server.lsp_ingress, while a change to baml_lsp_server.lsp_ingress can't break bex_events.run.
Position
Below the diagonal: baml_lsp_server.lsp_ingress uses a module listed above it, which is the healthy direction.
bcs_api.diagnostics uses internal_baml_ast.formatter, so a change to internal_baml_ast.formatter can break bcs_api.diagnostics, while a change to bcs_api.diagnostics can't break internal_baml_ast.formatter.
Position
Below the diagonal: bcs_api.diagnostics uses a module listed above it, which is the healthy direction.
bcs_api.diagnostics uses baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result, so a change to baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result can break bcs_api.diagnostics, while a change to bcs_api.diagnostics can't break baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result.
Position
Below the diagonal: bcs_api.diagnostics uses a module listed above it, which is the healthy direction.
bcs_api.diagnostics uses baml_artifact, so a change to baml_artifact can break bcs_api.diagnostics, while a change to bcs_api.diagnostics can't break baml_artifact.
Position
Below the diagonal: bcs_api.diagnostics uses a module listed above it, which is the healthy direction.
bex_vm_types.heap_ptr uses internal_baml_ast.formatter, so a change to internal_baml_ast.formatter can break bex_vm_types.heap_ptr, while a change to bex_vm_types.heap_ptr can't break internal_baml_ast.formatter.
Position
Below the diagonal: bex_vm_types.heap_ptr uses a module listed above it, which is the healthy direction.
bex_vm_types.heap_ptr uses baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result, so a change to baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result can break bex_vm_types.heap_ptr, while a change to bex_vm_types.heap_ptr can't break baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result.
Position
Below the diagonal: bex_vm_types.heap_ptr uses a module listed above it, which is the healthy direction.
bex_vm_types.heap_ptr uses bex_vm_types.types.object, so a change to bex_vm_types.types.object can break bex_vm_types.heap_ptr, while a change to bex_vm_types.heap_ptr can't break bex_vm_types.types.object.
Position
Below the diagonal: bex_vm_types.heap_ptr uses a module listed above it, which is the healthy direction.
45 pairs of types, where a type in baml_fmt.ast.expressions uses a type in language_server.baml_text_size.range. Showing 25 of them; the rest are in namespace-graph.json in this report's bundle.
baml_fmt.ast.expressions uses language_server.baml_text_size.range, so a change to language_server.baml_text_size.range can break baml_fmt.ast.expressions, while a change to baml_fmt.ast.expressions can't break language_server.baml_text_size.range.
Position
Below the diagonal: baml_fmt.ast.expressions uses a module listed above it, which is the healthy direction.
baml_fmt.ast.expressions uses baml_compiler2_ast.ast, so a change to baml_compiler2_ast.ast can break baml_fmt.ast.expressions, while a change to baml_fmt.ast.expressions can't break baml_compiler2_ast.ast.
Position
Below the diagonal: baml_fmt.ast.expressions uses a module listed above it, which is the healthy direction.
58 pairs of types, where a type in baml_fmt.ast.expressions uses a type in baml_fmt.ast.tokens. Showing 25 of them; the rest are in namespace-graph.json in this report's bundle.
baml_fmt.ast.expressions uses baml_fmt.ast.tokens, so a change to baml_fmt.ast.tokens can break baml_fmt.ast.expressions, while a change to baml_fmt.ast.expressions can't break baml_fmt.ast.tokens.
Position
Below the diagonal: baml_fmt.ast.expressions uses a module listed above it, which is the healthy direction.
baml_fmt.ast.expressions uses baml_compiler_syntax.ast, so a change to baml_compiler_syntax.ast can break baml_fmt.ast.expressions, while a change to baml_fmt.ast.expressions can't break baml_compiler_syntax.ast.
Position
Below the diagonal: baml_fmt.ast.expressions uses a module listed above it, which is the healthy direction.
baml_fmt.ast.expressions uses internal_baml_core.ir.repr, so a change to internal_baml_core.ir.repr can break baml_fmt.ast.expressions, while a change to baml_fmt.ast.expressions can't break internal_baml_core.ir.repr.
Position
Below the diagonal: baml_fmt.ast.expressions uses a module listed above it, which is the healthy direction.
43 pairs of types, where a type in baml_fmt.ast.expressions uses a type in baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result. Showing 25 of them; the rest are in namespace-graph.json in this report's bundle.
baml_fmt.ast.expressions uses baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result, so a change to baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result can break baml_fmt.ast.expressions, while a change to baml_fmt.ast.expressions can't break baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result.
Position
Below the diagonal: baml_fmt.ast.expressions uses a module listed above it, which is the healthy direction.
baml_fmt.ast.expressions uses baml_compiler2_mir.ir, so a change to baml_compiler2_mir.ir can break baml_fmt.ast.expressions, while a change to baml_fmt.ast.expressions can't break baml_compiler2_mir.ir.
Position
Below the diagonal: baml_fmt.ast.expressions uses a module listed above it, which is the healthy direction.
baml_lsp.state uses baml_query.value.model, so a change to baml_query.value.model can break baml_lsp.state, while a change to baml_lsp.state can't break baml_query.value.model.
Position
Below the diagonal: baml_lsp.state uses a module listed above it, which is the healthy direction.
baml_lsp.state uses internal_baml_ast.formatter, so a change to internal_baml_ast.formatter can break baml_lsp.state, while a change to baml_lsp.state can't break internal_baml_ast.formatter.
Position
Below the diagonal: baml_lsp.state uses a module listed above it, which is the healthy direction.
baml_lsp.state uses baml_compiler2_hir_ty.infer.unify, so a change to baml_compiler2_hir_ty.infer.unify can break baml_lsp.state, while a change to baml_lsp.state can't break baml_compiler2_hir_ty.infer.unify.
Position
Below the diagonal: baml_lsp.state uses a module listed above it, which is the healthy direction.
baml_lsp.state uses baml_base.core_types, so a change to baml_base.core_types can break baml_lsp.state, while a change to baml_lsp.state can't break baml_base.core_types.
Position
Below the diagonal: baml_lsp.state uses a module listed above it, which is the healthy direction.
baml_lsp.state uses baml_base.files, so a change to baml_base.files can break baml_lsp.state, while a change to baml_lsp.state can't break baml_base.files.
Position
Below the diagonal: baml_lsp.state uses a module listed above it, which is the healthy direction.
baml_lsp.state uses baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result, so a change to baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result can break baml_lsp.state, while a change to baml_lsp.state can't break baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result.
Position
Below the diagonal: baml_lsp.state uses a module listed above it, which is the healthy direction.
baml_lsp.state uses bex_events.run, so a change to bex_events.run can break baml_lsp.state, while a change to baml_lsp.state can't break bex_events.run.
Position
Below the diagonal: baml_lsp.state uses a module listed above it, which is the healthy direction.
baml_lsp.state uses baml_lsp_server.lsp_ingress, so a change to baml_lsp_server.lsp_ingress can break baml_lsp.state, while a change to baml_lsp.state can't break baml_lsp_server.lsp_ingress.
Position
Below the diagonal: baml_lsp.state uses a module listed above it, which is the healthy direction.
baml_runtime uses baml_base.core_types, so a change to baml_base.core_types can break baml_runtime, while a change to baml_runtime can't break baml_base.core_types.
Position
Below the diagonal: baml_runtime uses a module listed above it, which is the healthy direction.
baml_runtime uses internal_baml_core.ir.repr, so a change to internal_baml_core.ir.repr can break baml_runtime, while a change to baml_runtime can't break internal_baml_core.ir.repr.
Position
Below the diagonal: baml_runtime uses a module listed above it, which is the healthy direction.
baml_runtime uses bex_sap.baml_value, so a change to bex_sap.baml_value can break baml_runtime, while a change to baml_runtime can't break bex_sap.baml_value.
Position
Below the diagonal: baml_runtime uses a module listed above it, which is the healthy direction.
baml_runtime uses baml_runtime.types.runtime_context, so a change to baml_runtime.types.runtime_context can break baml_runtime, while a change to baml_runtime can't break baml_runtime.types.runtime_context.
Position
Below the diagonal: baml_runtime uses a module listed above it, which is the healthy direction.
baml_runtime uses baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result, so a change to baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result can break baml_runtime, while a change to baml_runtime can't break baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result.
Position
Below the diagonal: baml_runtime uses a module listed above it, which is the healthy direction.
baml_runtime uses baml_lsp_server.lsp_ingress, so a change to baml_lsp_server.lsp_ingress can break baml_runtime, while a change to baml_runtime can't break baml_lsp_server.lsp_ingress.
Position
Below the diagonal: baml_runtime uses a module listed above it, which is the healthy direction.
bex_heap.heap uses baml_query.value.model, so a change to baml_query.value.model can break bex_heap.heap, while a change to bex_heap.heap can't break baml_query.value.model.
Position
Below the diagonal: bex_heap.heap uses a module listed above it, which is the healthy direction.
bex_heap.heap uses internal_baml_ast.formatter, so a change to internal_baml_ast.formatter can break bex_heap.heap, while a change to bex_heap.heap can't break internal_baml_ast.formatter.
Position
Below the diagonal: bex_heap.heap uses a module listed above it, which is the healthy direction.
bex_heap.heap uses bex_vm_types.errors, so a change to bex_vm_types.errors can break bex_heap.heap, while a change to bex_heap.heap can't break bex_vm_types.errors.
Position
Below the diagonal: bex_heap.heap uses a module listed above it, which is the healthy direction.
bex_heap.heap uses baml_compiler2_ast.ast, so a change to baml_compiler2_ast.ast can break bex_heap.heap, while a change to bex_heap.heap can't break baml_compiler2_ast.ast.
Position
Below the diagonal: bex_heap.heap uses a module listed above it, which is the healthy direction.
bex_heap.heap uses baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result, so a change to baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result can break bex_heap.heap, while a change to bex_heap.heap can't break baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result.
Position
Below the diagonal: bex_heap.heap uses a module listed above it, which is the healthy direction.
bex_heap.heap uses bex_vm_types.types.object, so a change to bex_vm_types.types.object can break bex_heap.heap, while a change to bex_heap.heap can't break bex_vm_types.types.object.
Position
Below the diagonal: bex_heap.heap uses a module listed above it, which is the healthy direction.
bex_heap.heap uses bex_vm_types.heap_ptr, so a change to bex_vm_types.heap_ptr can break bex_heap.heap, while a change to bex_heap.heap can't break bex_vm_types.heap_ptr.
Position
Below the diagonal: bex_heap.heap uses a module listed above it, which is the healthy direction.
36→40 bex_heap.heap uses bex_enginepart of a loop✕
Connections
1 pair of types, where a type in bex_heap.heap uses a type in bex_engine.
sys_types uses internal_baml_ast.formatter, so a change to internal_baml_ast.formatter can break sys_types, while a change to sys_types can't break internal_baml_ast.formatter.
Position
Below the diagonal: sys_types uses a module listed above it, which is the healthy direction.
sys_types uses bex_vm_types.errors, so a change to bex_vm_types.errors can break sys_types, while a change to sys_types can't break bex_vm_types.errors.
Position
Below the diagonal: sys_types uses a module listed above it, which is the healthy direction.
sys_types uses baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result, so a change to baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result can break sys_types, while a change to sys_types can't break baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result.
Position
Below the diagonal: sys_types uses a module listed above it, which is the healthy direction.
sys_types uses bex_external_types.bex_external_value, so a change to bex_external_types.bex_external_value can break sys_types, while a change to sys_types can't break bex_external_types.bex_external_value.
Position
Below the diagonal: sys_types uses a module listed above it, which is the healthy direction.
sys_types uses baml_lsp_server.lsp_ingress, so a change to baml_lsp_server.lsp_ingress can break sys_types, while a change to sys_types can't break baml_lsp_server.lsp_ingress.
Position
Below the diagonal: sys_types uses a module listed above it, which is the healthy direction.
baml_compiler2_hir_ty.infer uses baml_type.interned, so a change to baml_type.interned can break baml_compiler2_hir_ty.infer, while a change to baml_compiler2_hir_ty.infer can't break baml_type.interned.
Position
Below the diagonal: baml_compiler2_hir_ty.infer uses a module listed above it, which is the healthy direction.
baml_compiler2_hir_ty.infer uses baml_compiler2_hir_ty.infer.unify, so a change to baml_compiler2_hir_ty.infer.unify can break baml_compiler2_hir_ty.infer, while a change to baml_compiler2_hir_ty.infer can't break baml_compiler2_hir_ty.infer.unify.
Position
Below the diagonal: baml_compiler2_hir_ty.infer uses a module listed above it, which is the healthy direction.
baml_compiler2_hir_ty.infer uses baml_compiler2_ast.ast, so a change to baml_compiler2_ast.ast can break baml_compiler2_hir_ty.infer, while a change to baml_compiler2_hir_ty.infer can't break baml_compiler2_ast.ast.
Position
Below the diagonal: baml_compiler2_hir_ty.infer uses a module listed above it, which is the healthy direction.
baml_compiler2_hir_ty.infer uses internal_baml_jinja.output_format.types, so a change to internal_baml_jinja.output_format.types can break baml_compiler2_hir_ty.infer, while a change to baml_compiler2_hir_ty.infer can't break internal_baml_jinja.output_format.types.
Position
Below the diagonal: baml_compiler2_hir_ty.infer uses a module listed above it, which is the healthy direction.
baml_compiler2_hir_ty.infer uses baml_base.core_types, so a change to baml_base.core_types can break baml_compiler2_hir_ty.infer, while a change to baml_compiler2_hir_ty.infer can't break baml_base.core_types.
Position
Below the diagonal: baml_compiler2_hir_ty.infer uses a module listed above it, which is the healthy direction.
baml_compiler2_hir_ty.infer uses baml_base.files, so a change to baml_base.files can break baml_compiler2_hir_ty.infer, while a change to baml_compiler2_hir_ty.infer can't break baml_base.files.
Position
Below the diagonal: baml_compiler2_hir_ty.infer uses a module listed above it, which is the healthy direction.
baml_compiler2_hir_ty.infer uses baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result, so a change to baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result can break baml_compiler2_hir_ty.infer, while a change to baml_compiler2_hir_ty.infer can't break baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result.
Position
Below the diagonal: baml_compiler2_hir_ty.infer uses a module listed above it, which is the healthy direction.
baml_compiler2_hir_ty.infer uses baml_compiler2_hir.loc, so a change to baml_compiler2_hir.loc can break baml_compiler2_hir_ty.infer, while a change to baml_compiler2_hir_ty.infer can't break baml_compiler2_hir.loc.
Position
Below the diagonal: baml_compiler2_hir_ty.infer uses a module listed above it, which is the healthy direction.
baml_compiler2_hir_ty.infer uses sys_types, so a change to sys_types can break baml_compiler2_hir_ty.infer, while a change to baml_compiler2_hir_ty.infer can't break sys_types.
Position
Below the diagonal: baml_compiler2_hir_ty.infer uses a module listed above it, which is the healthy direction.
bex_vm.vm uses baml_query.value.model, so a change to baml_query.value.model can break bex_vm.vm, while a change to bex_vm.vm can't break baml_query.value.model.
Position
Below the diagonal: bex_vm.vm uses a module listed above it, which is the healthy direction.
bex_vm.vm uses baml_runtime.internal.llm_client.primitive.google.types, so a change to baml_runtime.internal.llm_client.primitive.google.types can break bex_vm.vm, while a change to bex_vm.vm can't break baml_runtime.internal.llm_client.primitive.google.types.
Position
Below the diagonal: bex_vm.vm uses a module listed above it, which is the healthy direction.
bex_vm.vm uses bex_vm_types.errors, so a change to bex_vm_types.errors can break bex_vm.vm, while a change to bex_vm.vm can't break bex_vm_types.errors.
Position
Below the diagonal: bex_vm.vm uses a module listed above it, which is the healthy direction.
bex_vm.vm uses internal_baml_jinja.output_format.types, so a change to internal_baml_jinja.output_format.types can break bex_vm.vm, while a change to bex_vm.vm can't break internal_baml_jinja.output_format.types.
Position
Below the diagonal: bex_vm.vm uses a module listed above it, which is the healthy direction.
1 pair of types, where a type in bex_vm.vm uses a type in baml_base.core_types.
The types involved
bex_vm.vm.BexVm → baml_base.core_types.Literal
Direction
bex_vm.vm uses baml_base.core_types, so a change to baml_base.core_types can break bex_vm.vm, while a change to bex_vm.vm can't break baml_base.core_types.
Position
Below the diagonal: bex_vm.vm uses a module listed above it, which is the healthy direction.
bex_vm.vm uses baml_compiler2_hir.item_tree.functions, so a change to baml_compiler2_hir.item_tree.functions can break bex_vm.vm, while a change to bex_vm.vm can't break baml_compiler2_hir.item_tree.functions.
Position
Below the diagonal: bex_vm.vm uses a module listed above it, which is the healthy direction.
bex_vm.vm uses baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result, so a change to baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result can break bex_vm.vm, while a change to bex_vm.vm can't break baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result.
Position
Below the diagonal: bex_vm.vm uses a module listed above it, which is the healthy direction.
bex_vm.vm uses bex_vm_types.types.object, so a change to bex_vm_types.types.object can break bex_vm.vm, while a change to bex_vm.vm can't break bex_vm_types.types.object.
Position
Below the diagonal: bex_vm.vm uses a module listed above it, which is the healthy direction.
1 pair of types, where a type in bex_vm.vm uses a type in baml_compiler2_mir.ir.
The types involved
bex_vm.vm.BexVm → baml_compiler2_mir.ir.BinOp
Direction
bex_vm.vm uses baml_compiler2_mir.ir, so a change to baml_compiler2_mir.ir can break bex_vm.vm, while a change to bex_vm.vm can't break baml_compiler2_mir.ir.
Position
Below the diagonal: bex_vm.vm uses a module listed above it, which is the healthy direction.
bex_vm.vm uses bcs_api.diagnostics, so a change to bcs_api.diagnostics can break bex_vm.vm, while a change to bex_vm.vm can't break bcs_api.diagnostics.
Position
Below the diagonal: bex_vm.vm uses a module listed above it, which is the healthy direction.
bex_vm.vm uses bex_vm_types.heap_ptr, so a change to bex_vm_types.heap_ptr can break bex_vm.vm, while a change to bex_vm.vm can't break bex_vm_types.heap_ptr.
Position
Below the diagonal: bex_vm.vm uses a module listed above it, which is the healthy direction.
bex_engine uses baml_query.value.model, so a change to baml_query.value.model can break bex_engine, while a change to bex_engine can't break baml_query.value.model.
Position
Below the diagonal: bex_engine uses a module listed above it, which is the healthy direction.
bex_engine uses baml_runtime.internal.llm_client.primitive.google.types, so a change to baml_runtime.internal.llm_client.primitive.google.types can break bex_engine, while a change to bex_engine can't break baml_runtime.internal.llm_client.primitive.google.types.
Position
Below the diagonal: bex_engine uses a module listed above it, which is the healthy direction.
bex_engine uses bex_vm_types.errors, so a change to bex_vm_types.errors can break bex_engine, while a change to bex_engine can't break bex_vm_types.errors.
Position
Below the diagonal: bex_engine uses a module listed above it, which is the healthy direction.
bex_engine uses baml_compiler2_ast.ast, so a change to baml_compiler2_ast.ast can break bex_engine, while a change to bex_engine can't break baml_compiler2_ast.ast.
Position
Below the diagonal: bex_engine uses a module listed above it, which is the healthy direction.
1 pair of types, where a type in bex_engine uses a type in baml_base.core_types.
The types involved
bex_engine.BexEngine → baml_base.core_types.Path
Direction
bex_engine uses baml_base.core_types, so a change to baml_base.core_types can break bex_engine, while a change to bex_engine can't break baml_base.core_types.
Position
Below the diagonal: bex_engine uses a module listed above it, which is the healthy direction.
bex_engine uses baml_compiler2_hir.item_tree.functions, so a change to baml_compiler2_hir.item_tree.functions can break bex_engine, while a change to bex_engine can't break baml_compiler2_hir.item_tree.functions.
Position
Below the diagonal: bex_engine uses a module listed above it, which is the healthy direction.
bex_engine uses baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result, so a change to baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result can break bex_engine, while a change to bex_engine can't break baml_bridge.wire.baml_bridge.cffi.v1.baml_outbound_result.
Position
Below the diagonal: bex_engine uses a module listed above it, which is the healthy direction.
bex_engine uses bex_external_types.bex_external_value, so a change to bex_external_types.bex_external_value can break bex_engine, while a change to bex_engine can't break bex_external_types.bex_external_value.
Position
Below the diagonal: bex_engine uses a module listed above it, which is the healthy direction.
bex_engine uses baml_lsp_server.lsp_ingress, so a change to baml_lsp_server.lsp_ingress can break bex_engine, while a change to bex_engine can't break baml_lsp_server.lsp_ingress.
Position
Below the diagonal: bex_engine uses a module listed above it, which is the healthy direction.
bex_engine uses bcs_api.diagnostics, so a change to bcs_api.diagnostics can break bex_engine, while a change to bex_engine can't break bcs_api.diagnostics.
Position
Below the diagonal: bex_engine uses a module listed above it, which is the healthy direction.
bex_engine uses bex_vm_types.heap_ptr, so a change to bex_vm_types.heap_ptr can break bex_engine, while a change to bex_engine can't break bex_vm_types.heap_ptr.
Position
Below the diagonal: bex_engine uses a module listed above it, which is the healthy direction.
Findings mapped to OWASP categories; the specific CVEs/secrets are in the Security dimension cards below and findings.md (redacted only on the public version of this report).
OWASP category
Findings
Severity
A05:2025 — Injection
649
High / Critical
A03:2025 — Software Supply Chain Failures
304
High / Critical
A02:2025 — Security Misconfiguration
14
High / Critical
A07:2025 — Authentication Failures
10
High / Critical
A01:2025 — Broken Access Control
1
Medium
Roadmap
First, eliminate all production-to-test references by extracting shared helpers into a dedicated support library to ensure proper dependency direction. Next, correct import boundary violations by routing imports through public entry points and respecting layer order, while breaking circular dependencies by extracting shared logic into independent modules. Finally, address explicit debt by resolving write-only private fields and update the platform configuration to resolve end-of-life runtime warnings.
Ranked by impact ÷ effort. "Helps" is the estimated gain on the 0–100 health score.
Do this
Helps
Effort
Dimension
Resolve the 2 End-of-life runtime finding(s) in Platform End-of-Life — start with REDACTED (2).
Remove every production → test project reference: extract any shared test helper into a production support library (which the tests reference), or invert the dependency so the test project depends on production — not the reverse.
Fix the listed violations: import through the target package's declared public entry rather than a deep path into its internals or a relative path into its directory (12 rows); move the shared test helper into a source directory production code may depend on (9 rows); respect the layer/slice order — import only through a slice's public index and never upward into a higher layer (5 rows).
Dependency Vulnerabilities: High vulnerability: REDACTED
REDACTED
2.3
Slop
Static Analysis (SAST): High: REDACTED
REDACTED
2.3
Slop
Static Analysis (SAST): High: REDACTED
REDACTED
2.3
Slop
Static Analysis (SAST): High: REDACTED
REDACTED
2.5
Slop
Static Analysis (SAST): High: REDACTED
How the grades work
Every finding carries one of four grades. Three say how serious it is. The fourth says this
survey could not settle it — and it is a grade, not a gap.
Critical — 739
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 — 5055
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 — 279
Recorded, with no effect on how the codebase functions.
Present so the survey is complete, not because it needs doing.
Could not be resolved — 8
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. 93 of 93 evaluated dimensions are computed purely by tools and static analysis (confidence 1.0); none rely on LLM judgement. Overall confidence is 0.9 — the weighted average across measured dimensions; it falls as more of the score leans on LLM-assisted judgement and rises when it's fully tool-backed.
Every figure here is one of three kinds, and we label which: ✓ Measured — a deterministic fact (LoC, complexity, coverage); ~ Modeled — an estimate from a stated model (cost, effort, value-at-risk), always a range with its assumptions, never a precise fact; ◐ Advisory — an LLM prose judgement. We never present a modelled estimate as if it were measured. Perfect or absent scores carry their provenance too (ADR-0011): ✓ Tool-verified means the property itself was measured across the surface; ○ Nothing flagged means the probes came back clean — a claim bounded by what a repository can show; ⊘ Not evidenced means a working control (a tested restore, an automated rollback) showed no positive evidence — absence of evidence is not evidence of a control, so it's excluded from the score rather than awarded a spurious 10; ◐ Sampled · advisory marks an LLM verdict over a bounded sample — advisory, never a deterministic measurement.
What we checked — 93 dimensions across the health lenses
Each chip is a dimension scored from real signals across architecture, testing, dependencies, security & compliance, documentation, git-history and code quality — in one coherent pass. A surface report typically covers a handful.
How to trust any code-health report — three questions
Can you open the finding? Real findings cite a repo-relative file and line you can open at the cited line — never an absolute scratch path. Here, 6000 of 6073 do; the remainder are repo-wide signals — a dimension-level measurement, not a single line. (Every path in this report is repo-relative by construction: paths are normalized at the producer and the report is rejected if any rooted path leaks through.)
Is there a tool behind the number? Every score below names the method that produced it — Roslyn, git, a scanner, or (for a handful of documentation/naming dimensions) an LLM labelled sampled · advisory — not a narrative.
Does re-running give the same result? Run it again on the same commit and the score — and this report, byte for byte — is identical. A report whose numbers move between runs is describing the run, not the code.
This report answers yes to all three. That's the bar to hold any assessment to.
Tools & methods
The actual versions used this run (captured at analysis time) — re-run on the same commit for the identical score.
Method
Backs
Version
Evaluator
Roslyn static analysis
Complexity, cohesion, coupling, dead code, API surface, layering
What ran differently this time — a tool absent, degraded, or that fell back to an estimate. Named openly, not folded silently into the scores. A degraded run also records its exact cause in diagnostics.md.
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 1,364 test(s) behind this row are the ones the JavaScript/TypeScript census could read, and this repository also carries at least 698 test source file(s) (.py, .rs, .go, .swift) 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 SCORED: this repository's production source includes .rs, and the rust executor ran against the .rs half and did not finish re-running within its tier budget — so reliability was not measured for the repository as a whole. The JavaScript/TypeScript (vitest via `pnpm install --frozen-lockfile --ignore-scripts` in the repository root; vitest via `pnpm install --frozen-lockfile --ignore-scripts` in baml_language/sdks/typescript/bridge_typescript/; vitest via `pnpm install --frozen-lockfile --ignore-scripts` in baml_language/sdks/typescript/bridge_typescript_web/ (0 tests); vitest via `pnpm install --frozen-lockfile --ignore-scripts` in engine/generators/data/dynamic_types/typescript/; jest via `pnpm install --frozen-lockfile --ignore-scripts` in engine/language_client_typescript/; jest via `pnpm install --frozen-lockfile --ignore-scripts` in integ-tests/react/; jest via `pnpm install --frozen-lockfile --ignore-scripts` in integ-tests/typescript/; vitest via `pnpm install --frozen-lockfile --ignore-scripts` in typescript/apps/fiddle-web-app/; vitest via `pnpm install --frozen-lockfile --ignore-scripts` in typescript/apps/vscode-ext/; mocha via `pnpm install --frozen-lockfile --ignore-scripts` in typescript/packages/codemirror-lang-baml/; vitest via `pnpm install --frozen-lockfile --ignore-scripts` in typescript/packages/playground-common/; node:test via `pnpm install --frozen-lockfile --ignore-scripts` in typescript2/ (4 tests)): measured (0 flaky) suite(s) did re-run, and came back with 0 flaky across 1 measured tier(s) — but that is a figure for one half of the product, and we do not publish a partial one as if it were complete. This is OUR limitation, not a defect in the repo — test reliability is excluded from the score rather than counted. The half was driven by a runner we ship, so this is not a missing-runner gap.
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 vitest suite in the repository root was NOT MEASURED: the dependency install for the repository root failed in the analyzer sandbox (throw new Error(), 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.
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 vitest suite in baml_language/sdks/typescript/bridge_typescript/ was NOT MEASURED: the dependency install for baml_language/sdks/typescript/bridge_typescript/ failed in the analyzer sandbox (throw new Error(), 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.
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 vitest suite in engine/generators/data/dynamic_types/typescript/ was NOT MEASURED: the dependency install for engine/generators/data/dynamic_types/typescript/ failed in the analyzer sandbox (throw new Error(), 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.
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 engine/language_client_typescript/ was NOT MEASURED: the dependency install for engine/language_client_typescript/ failed in the analyzer sandbox (throw new Error(), 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.
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 integ-tests/react/ was NOT MEASURED: the dependency install for integ-tests/react/ failed in the analyzer sandbox (throw new Error(), 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.
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 integ-tests/typescript/ was NOT MEASURED: the dependency install for integ-tests/typescript/ failed in the analyzer sandbox (throw new Error(), 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.
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 vitest suite in typescript/apps/fiddle-web-app/ was NOT MEASURED: the dependency install for typescript/apps/fiddle-web-app/ failed in the analyzer sandbox (throw new Error(), 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.
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 vitest suite in typescript/apps/vscode-ext/ was NOT MEASURED: the dependency install for typescript/apps/vscode-ext/ failed in the analyzer sandbox (throw new Error(), 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.
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 mocha suite in typescript/packages/codemirror-lang-baml/ was NOT MEASURED: the dependency install for typescript/packages/codemirror-lang-baml/ failed in the analyzer sandbox (throw new Error(), 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.
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 vitest suite in typescript/packages/playground-common/ was NOT MEASURED: the dependency install for typescript/packages/playground-common/ failed in the analyzer sandbox (throw new Error(), 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.
D12 Dependency Hygiene — 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. `dotnet list package` did not return usable output (restore or query failed); no outdated/vulnerable/deprecated data to assess. The tool said: `dotnet list package` exited 1 with no output.
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 Go module (REDACTED/go.sum), but the licence verdict published here was taken over its NuGet package dependencies. Nothing was read about its Go 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 REDACTED, but the licence verdict published here was taken over its NuGet package 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.
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 REDACTED/requirements.txt (pip/uv/Poetry), but the licence verdict published here was taken over its NuGet package 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 a Cargo manifest, but the licence verdict published here was taken over its NuGet package dependencies. Nothing was read about its Cargo 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 a Gradle build (build.gradle/build.gradle.kts), but the licence verdict published here was taken over its NuGet package dependencies. Nothing was read about its Gradle dependencies' licensing in either direction, and a clean score on this card must not be read as covering them.
D15 Churn × Complexity Hotspots — 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. A hotspot's complexity is meant to be the worst body its churn actually touched. For baml_language/crates/bex_vm_types/src/head_walk.rs, baml_language/crates/baml_lsp/src/dispatch/mod.rs that could not be established — the complexity reader for the file reports no body extents, or the history carries no per-line attribution — so the row quotes the file's worst body, which the counted changes may never have touched. The churn count is unaffected.
D17 Explicit Debt — 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 65 deducted marker(s) and the 2.0/KLoC density on this row were taken over this repository's .NET projects ALONE: .rs (806,535 lines, 76% of production source) went unread, because every marker collector on this path is reached through a C# workspace. A read-only sweep of that source finds at least 410 task marker(s) (TODO/FIXME/HACK/XXX) across 195 file(s) that this score does not count — a floor, since only line comments are read there and D17's other eight marker kinds (suppressions, NoWarn, editorconfig severities, empty catches, commented-out code, Obsolete, dead code, preprocessor branches) need a compiler we do not have for that language. The debt in that source is UNMEASURED — its absence from the score above is a gap in this analyzer's language coverage, not a finding that the code carries none.
D19 Documentation Quality — measured, with a gap in what it reached — Watchdog measured this, but not all of it. What it did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. Each ecosystem's manifests (what makes a folder runnable or a published package) need their own proof before D19 judges its units. Until then those folders' READMEs are judged only as documents (boilerplate, structure), never counted as complete.
D19 Documentation Quality — measured, with a gap in what it reached — Watchdog measured this, but not all of it. What it did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. This kind did not reach the 95 % precision gate in three adjudicated runs (docs/plans/deterministic-engine/adjudication/D19-sample3-v3.md), so by the pre-registered fallback it publishes no row until a re-measurement shows it does. The candidates are counted here, not reported as findings, and the score does not include them.
D21 Naming Consistency — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. D21's deterministic naming rules are gated on C# first (docs/plans/deterministic-engine.md, P5): each other language is switched on only after its own concept suite and A/B gate pass. Until then its declarations carry no naming verdict this run — this says nothing about whether its names are consistent.
D21 Naming Consistency — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. PREREGISTRATION version 20's fallback (adjudication D21-sample3-v3): this rule kind was adjudicated below the 95 % precision gate, so its candidates are counted here and not published, and the score covers only the acronym-spelling and awaitable-suffix rules. The kind returns as rows only after it shows a measured precision; this says nothing about whether these names are consistent.
D21 Naming Consistency — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. PREREGISTRATION version 20's fallback (adjudication D21-sample3-v3): this rule kind was adjudicated below the 95 % precision gate, so its candidates are counted here and not published, and the score covers only the acronym-spelling and awaitable-suffix rules. The kind returns as rows only after it shows a measured precision; this says nothing about whether these names are consistent.
D22 Internal API Consistency — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. D22's deterministic call-shape rules are gated on C# first (docs/plans/deterministic-engine.md, P5): each other language is switched on only after its own concept suite and A/B gate pass. This says nothing about whether that surface is consistent.
D24 Comment Value — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. Each source language's comment syntax, and the code a comment annotates in it, needs its own proof before D24 judges it. Until then those comments are left unread, not counted as clean.
D27 Navigability — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. Navigability is taken over call sites whose callee resolved. For C# that population includes calls into referenced assemblies; for this language only calls declared inside the repository count, so the abstention threshold reads the repository's use of its standard library as a resolution failure. That is a limit of this analyzer, not a build problem in this repository.
D31 IaC & Container Security — 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. Checkov ran but its report could not be read (checkov produced no output — not a clean result). Every misconfiguration only checkov reports — most of its Terraform, CloudFormation, Bicep and Ansible policies — is absent from this card, so its absence here is not evidence those resources are configured correctly.
D32 Data Compliance (PII/GDPR) — 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. `baml_language/sdks/csharp/bridge_csharp/src/Cffi/HostCallDispatcher.cs`, `baml_language/sdks/csharp/bridge_csharp/src/Cffi/HostValueRegistry.cs`, `baml_language/sdks/csharp/bridge_csharp/src/Cffi/NativeApi.cs`, `baml_language/sdks/csharp/bridge_csharp/src/Generated/V1/BamlGeneratedArguments.cs`, `baml_language/sdks/csharp/bridge_csharp/src/Generated/V1/BamlGeneratedCanonicalCodecs.cs`, … (+33 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.
D39 IL Efficiency — 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. IL NOT MEASURED: the analyzer's own build of this repository failed for an ENVIRONMENT reason (exit 1) — MSBuild's engine or the CLR gave up, or our image does not carry the SDK band/targeting pack this repository needs. This is OUR limitation, not a defect in the repo, and it is not a statement that this repository fails to build. D18 owns the question of whether this repository builds; it was not answered here.
AXR1 Runtime accessibility — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. Render strategy: boot via REDACTED (REDACTED). docker build failed (exit 1) — ------ REDACTED:1 -------------------- 1 | >>> # syntax=docker/dockerfile:1 2 | FROM node:24-slim AS build 3 | WORKDIR /workspace -------------------- ERROR: failed to solve: failed to resolve source metadata for docker.io/docker/dockerfile:1: failed to do request: Head "https://registry-1.docker.io/v2/docker/dockerfile/manifests/1": Forbidden; runtime evidence skipped.
M4 Documentation accuracy — measured, with a gap in what it reached — Watchdog measured this, but not all of it. What it did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. M4 checks only the claim kinds adjudicated at or above 95 % precision: links and versions (PREREGISTRATION version 9). Paths, command arguments, installs, environment variables, settings, projects, packages, routes, cd targets, infrastructure products and removed modules are read but not checked, and none of them is reported or counted.
R10 Code Duplication — 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. 478 further occurrence(s) are not listed individually; the score already reflects all 518.
R3 Large Files — 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. 62 further occurrence(s) are not listed individually; the score already reflects all 102.
R4 Test Coverage — 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. 737 further occurrence(s) are not listed individually; the score already reflects all 777.
R7 Dead Code — 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. 399 further occurrence(s) are not listed individually; the score already reflects all 439.
Repo exclusion declarations: 3 pattern(s) declared (.gitattributes linguist-generated/vendored, .editorconfig generated_code) excluded 0 source file(s) from code-quality scoring. Declarations are the repo's own visible statement that a tree is machine-written or vendored — auditable in any diff, honored by GitHub the same way.
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.
D8 Code Coverage: Coverage is measured by building and running the test suite inside Watchdog's isolated image — the target repo is never modified, and nothing on your systems runs. So coverage exists only when the suite builds and runs within the inline time budget; one that needs external services, can't build, or exceeds the budget yields no coverage (D8 then degrades to not-measured, not a low score). Line coverage also says nothing about assertion quality.
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.
D13 REDACTED Scanning: REDACTED detection is signature- and entropy-based on the current tree — a secret that does not match a known pattern, or one already rotated, will not be flagged (a clean scan is "nothing matched", not "no secrets exist").
D14 License Compliance: License compatibility is checked against declared package metadata and a policy — mislabelled or missing license metadata, and obligations that depend on how you distribute, are not resolved here.
D15 Churn × Complexity Hotspots: Churn hotspots come from git history — a freshly imported or squashed repository has no churn signal, and recent rewrites can mask a historically risky file.
D16 Bus Factor: Bus-factor is a time-decayed model of commit attribution (who has recently, repeatedly worked a file), not comprehension — pairing, review and reading-without-committing spread knowledge it can't see; bot commits and shared accounts still distort it.
D17 Explicit Debt: Acknowledged-debt signals (TODO/FIXME, suppressions, dead code) are textual — undocumented debt that nobody marked, and debt that lives in design rather than annotations, is invisible. Committed machine-written code (scaffolded migrations, designer/codegen output, generated stubs) is excluded — it is never the team's dead code to delete.
D19 Documentation Quality: Documentation quality publishes two things only: a runnable or packaged unit with no example, and a multi-project root README that maps none of its parts. It does not judge clarity, and its other checks (overview, licence, boilerplate, structure, empty sections, XML-doc coverage) are withheld after adjudication: their candidates are counted in the card's gaps, not shown as rows. A false statement in a document is M4's; units are .NET projects only.
D20 ADR Quality: ADR quality is an LLM read of the decision records present — it cannot know about decisions made and never recorded, and its verdict is sampled and advisory.
D23 Boundary Type-Coupling: Boundary leakage is detected from type references across detected contexts — leaks that flow through primitives, serialization or shared infrastructure may not surface as a typed reference.
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.
D31 IaC & Container Security: IaC scanning checks Dockerfiles/Terraform/Kubernetes against best-practice rules — it cannot see the live cloud account, runtime configuration, or drift between the committed config and what is actually deployed.
D32 Data Compliance (PII/GDPR): PII/GDPR signals are heuristic pattern matches in code — they flag likely handling concerns, not legal compliance, and cannot trace where data actually flows at runtime.
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 REDACTED (D31's subject), in a CI workflow (D29's), or in a file this pass does not parse (REDACTED, 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.
DM4 Rich vs anemic domain model: Behaviour is detected as state mutation inside a method body — a method that enforces an invariant by validating-and-throwing without mutating reads as a query, and mutation delegated through an interface the scan can't resolve isn't credited; entities with zero public properties still drop out of the population. It detects that state changes, not whether the rule is correct.
M4 Documentation accuracy: Onboarding quality is an LLM read of the docs/setup present — it cannot run the onboarding or measure how long a real new joiner takes; the verdict is sampled and advisory.
P4 Deployment & Rollback: Approval/branch-protection rules live in repository settings the scan cannot see — only their in-repo evidence (config files, workflows) is checked, so a control enforced purely in the host's settings reads as "not evidenced".
P6 Release Hygiene: Rollback/observability controls are inferred from repo artefacts (pipelines, dashboards-as-code) — controls configured in external tooling, with no in-repo trace, cannot be credited.
What it measures: How tangled the control flow is — methods with many branches are hard to test and change.
Method: Cyclomatic complexity per method (1 + decision points), computed exhaustively across production source; test projects separated by convention. Deterministic.
848 method(s) exceeded the cyclomatic complexity threshold of 15; the worst was BexVm::run_compact at 331. A further 172 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 DiagnosticId::code at 149 — they are counted neither in the figure above nor in this dimension's score. 55 files carry no cyclomatic complexity row at all for this reason — every one of their over-threshold methods was excluded, so the exclusion is disclosed nowhere in the file itself: baml_language/crates/baml_compiler_diagnostics/src/diagnostic.rs (DiagnosticId::code at 149), baml_language/crates/baml_compiler_lexer/src/tokens.rs (TokenKind::fmt at 97), baml_language/sdks/csharp/bridge_csharp/src/Generated/V1/BamlGeneratedCanonicalCodecs.cs (BamlGeneratedTypeMetadata.Render at 42), baml_language/crates/bex_sap/src/deserializer/score.rs (Flag::score at 35), baml_language/sdks/go/sdkgen_go/src/rendering.rs (GeneratorIdent::as_str at 35), and 50 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.
+ 471 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Bring the 1 body over 240 down to 240 or less in Cyclomatic Complexity — start with BexVm::run_compact (cyclomatic 331). — Refactoring it lifts Cyclomatic Complexity from 4.3 to about 4.7/10.
Enforce Cyclomatic Complexity in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.
Detailed fixes: d1_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: How hard the code is for a person to follow, beyond raw branching.
Method: Cognitive complexity per method (Sonar-style nesting-penalized score), computed exhaustively over production code, excluding test projects. Deterministic.
+ 603 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Bring the 4 bodies over 240 down to 240 or less in Cognitive Complexity — start with BexVm::run_compact (cognitive 579), baml_compiler::thir::typecheck::typecheck_expression (cognitive 412), ReplArgs::run (cognitive 317). — This score is capped by its worst body, so a finding fixed alone moves it by almost nothing — the next one down takes its place. Refactoring these 4 together lifts Cognitive Complexity from 2.0 to about 3.1/10, projected with the scoring formula itself and assuming each lands exactly at 240; a cleaner split scores higher.
Enforce Cognitive Complexity in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.
Detailed fixes: d2_recommendation.md · top locations in Appendix A, every location in findings.md.
Do you agree with this assessment?
D3 · God Classes8.1 / 10Strong✓ Tool-verified
What it measures: Over-large classes that try to do too much ("god classes").
Method: God-class detection by line and method-count thresholds per logical type (partial classes unified), filtered for generated code and registration/contract false positives. Deterministic.
+ 2 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Resolve the 291 FunctionTooLong finding(s) in God Classes — start with lib.rs (20), REDACTED (11), semantic.rs (8). — One of this dimension's main actionable groups (291 warning-level).
Resolve the 223 FileTooLong finding(s) in God Classes — start with lib.rs (15), mod.rs (8), emit.rs (3). — One of this dimension's main actionable groups (223 warning-level).
Resolve the 157 MethodTooLong finding(s) in God Classes — start with lower.rs (15), infer.rs (14), vm.rs (8). — One of this dimension's main actionable groups (157 warning-level).
Enforce God Classes in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.
Detailed fixes: d3_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Copy-pasted code that should be shared instead.
Method: Code duplication via token-stream sliding windows with type-aware normalization (locals masked, type names preserved), density-scored per KLoC of production code. Deterministic.
1332 duplicated block group(s) detected. A further 72 rows report members as variants of one another; they aggregate block groups already counted above and are not themselves counted. 33 of the 1404 are in trees this repository does not ship — vendored, example/demo, project-template, fixture and benchmark code — and are ranked below the shipped groups rather than excluded from them: the duplication there is real and is still counted in this dimension's score. The dimensions that publish a production-file census leave those trees out of theirs, so this count is deliberately drawn over the wider population.
+ 264 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Resolve the 106 Duplicated block (8 lines × 2) finding(s) in Code Duplication — start with mod.rs (11), lib.rs (8), emit.rs (5). — One of this dimension's main actionable groups (106 warning-level).
Resolve the 91 Duplicated block (6 lines × 2) finding(s) in Code Duplication — start with mod.rs (8), lib.rs (5), lower.rs (3). — One of this dimension's main actionable groups (91 warning-level).
Resolve the 83 Duplicated block (9 lines × 2) finding(s) in Code Duplication — start with lib.rs (8), mod.rs (8), vm.rs (5). — One of this dimension's main actionable groups (83 warning-level).
Enforce Code Duplication in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Verified — provenance only; does not change the score.
Detailed fixes: d4_recommendation.md · top locations in Appendix A, every location in findings.md.
Do you agree with this assessment?
D5 · Coupling8.5 / 10Strong✓ Tool-verified
What it measures: Whether volatile projects sit underneath others that depend on them (so their churn ripples upward), and whether project dependencies form cycles. A widely-depended-on but stable shared/kernel project is healthy, not penalised.
Method: Dependency cycles via elementary-DFS over real .csproj references, plus Martin instability (afferent/efferent) per project. Exhaustive over the reference graph, deterministic.
Coverage: Exhaustive · type-level: afferent/efferent coupling + cycles computed over every production type — the population is all types, not a name convention.
239 production modules (Gradle+Cargo+npm+Go+Python+SwiftPM+RubyGems), 0 dependency cycle(s), 11 unstable depended-on module(s). Read from the build's own module declarations; edges a convention plugin adds from buildSrc or build-logic are not visible there; 33 module(s) off the main sequence, with abstractness counted on 189 of the 239 (the rest declare no modelled class or interface, export only macros, declare types in source no model reads, or have no source directory of their own).
Off the main sequence: @b/pkg-grammar · ×32
Unstable project baml_cffi
Unstable project baml_compiler2_rust
Unstable project baml_linker
Unstable project baml_lsp_server
+ 8 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Resolve the 32 Off the main sequence finding(s) in Coupling. — One of this dimension's main actionable groups (32 warning-level).
Resolve the 1 Unstable project baml_cffi finding(s) in Coupling. — One of this dimension's main actionable groups (1 warning-level).
Resolve the 1 Unstable project baml_compiler2_rust finding(s) in Coupling. — One of this dimension's main actionable groups (1 warning-level).
Enforce Coupling in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.
Detailed fixes: d5_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether a class's methods are focused on a single responsibility.
Method: LCOM4 cohesion per production class with at least two methods: connected components of methods sharing state or calls, computed syntactically. Deterministic, not a proxy.
Coverage: Exhaustive · type-level: LCOM4 cohesion computed over every production class — the population is all types, not a name convention.
Resolve the 15 Low cohesion finding(s) in Cohesion (LCOM4) — start with media.rs (4), mod.rs (3), lib.rs. — One of this dimension's main actionable groups (15 warning-level).
Enforce Cohesion (LCOM4) in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Verified — provenance only; does not change the score.
Detailed fixes: d6_recommendation.md · top locations in Appendix A, every location in findings.md.
Do you agree with this assessment?
D8 · Code Coverage4.6 / 10Weak✓ Tool-verified
What it measures: How much of the code is actually exercised by tests.
Method: Coverage from coverlet runs or committed reports (Cobertura/OpenCover/lcov), computed per-file with structured exclusions for generated, trivial, and glue code. When the suite can't be built/run in-image AND no report is committed, coverage is reported NOT-MEASURED (excluded from the score) with the precondition to make it measurable — never a LoC-ratio proxy folded in as if measured. Deterministic.
Line coverage 19.2% — read from a committed lcov report (engine/baml-lib/baml-types/src/ir_type/lcov.info); the in-image collector couldn't run the suite (commonly external-service dependencies). A real measurement, but from a committed artifact rather than a fresh in-image run.
Coverage read from a committed report
What to do
Enforce Code Coverage in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Verified — provenance only; does not change the score.
Detailed fixes: d8_recommendation.md · top locations in Appendix A, every location in findings.md.
Do you agree with this assessment?
D9 · Test Distribution9.8 / 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.
12304 test methods: 9888 unit, 2245 integration, 0 BDD, 171 e2e. The JavaScript/TypeScript suite contributes 1364 `it`/`test` case(s) across 200 test file(s) declaring at least one beside 161 .NET test method(s); its tier split is read from package names and paths only. The Rust suite contributes 8960 `#[test]` function(s) across 1006 file(s) declaring at least one; its unit/integration split is Cargo's own — 276 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 1089 test function(s) across 110 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. The Go suite contributes 730 test case(s) across 117 `_test.go` file(s) declaring at least one — every `func Test…(t *testing.T)` that `go test` would collect, plus the suite methods a testify-style runner reaches; a table-driven case list counts once, so this is a floor. Its tier split is INFERRED from file names, paths and build constraints, not declared: 42 of those file(s) use Go's external test package (`package x_test`), which is a visibility boundary rather than a pyramid tier and was not read as one.
✓ On the Gold path — maintain.
Detailed fixes: d9_recommendation.md.
Do you agree with this assessment?
D10 · Test Quality9.8 / 10Adequategated by 1 critical finding✓ Tool-verified
What it measures: Whether the tests truly assert behaviour rather than just running the code.
Method: Per-test assertions, skips, and mock references analyzed via Roslyn; structured skip-reason tags (BUG:/ENV:) separate documented deferrals from debt. Deterministic.
13 skipped (7 with a documented reason), 9 zero-assertion, no mocking-framework packages referenced (hand-written doubles or no mocking) across 1364 tests. Measured on the JavaScript/TypeScript suite only — at least 698 test source file(s) (.py, .rs, .go, .swift) went unread, so its test quality is unmeasured and is not in these counts.
Assertions commented out: should handle multiple async calls with nested gathersinteg-tests/typescript/tests/collector.test.ts:417
No assertions: marks contexts entered by dynamic rules as dynamic · ×8typescript2/pkg-grammar/tests/kde-syntax.test.ts:272
Skipped test: should extract and attempt to run test case · ×6typescript/packages/playground-common/src/sdk/__tests__/runtime-integration.test.ts:249
Test project verifies nothing: typescript/packages/codemirror-lang-bamltypescript/packages/codemirror-lang-baml/test/test.cjs:21
Resolve the 1 Assertions commented out finding(s) in Test Quality — start with collector.test.ts. — One of this dimension's main actionable groups (1 issue-level).
Resolve the 8 No assertions finding(s) in Test Quality — start with kde-syntax.test.ts, App.browser.test.tsx, App.test.tsx. — One of this dimension's main actionable groups (8 warning-level).
Resolve the 6 Skipped test finding(s) in Test Quality — start with selection-integration.test.ts (2), runtime-integration.test.ts, unified-selection-sync.test.ts. — One of this dimension's main actionable groups (6 warning-level).
Enforce Test Quality in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.
Detailed fixes: d10_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether 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.
Resolve the 2 Leaked secret finding(s) in REDACTED Scanning — start with REDACTED (2). — One of this dimension's main actionable groups (2 issue-level).
Enforce REDACTED Scanning in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.
Detailed fixes: d13_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether the licenses of third-party packages are compatible with your policy.
Method: Third-party package licenses resolved from declared package metadata and checked against the configured policy (allow/deny/copyleft). Deterministic; clean = no incompatible license found at metadata depth.
0 of 84 packages use a banned license. ★ DEPTH: this repository's MSBuild projects declare 5 direct `PackageReference`(s), and 78 further package(s) were reached beyond them by closing the graph over nuget.org's own nuspec dependency graph — so a banned licence pulled in only by a dependency's OWN dependencies is inside this verdict. A package whose licence nuget.org could not be asked for is not graded, and version ranges are taken at their lower bound, so this is the closure as that graph states it rather than a restored consumer's exact resolution. ★ COVERAGE OF THIS VERDICT: it grades this repository's NuGet package dependencies and nothing else. The repository also declares a Go module (REDACTED/go.sum), REDACTED, a Python REDACTED/requirements.txt (pip/uv/Poetry), a Cargo manifest and a Gradle build (build.gradle/build.gradle.kts), and the licences of those dependency graphs were NOT read by this pass — a gap in this engine's coverage, not a statement about them. So this result says the graded closure carries no banned licence; it does NOT say this repository's licensing is clear.
What it measures: Files that change often and are also complex — the riskiest hotspots.
Method: Per production file churn times cyclomatic complexity over a rolling window, computed from git and Roslyn/JS/Razor analysis. Exhaustive, deterministic per commit date.
Resolve the 183 Hotspot finding(s) in Churn × Complexity Hotspots — start with lib.rs (14), translate_ty.rs (5), emit.rs (3). — One of this dimension's main actionable groups (183 warning-level).
Resolve the 1 Repeated repair finding(s) in Churn × Complexity Hotspots — start with auth.rs. — One of this dimension's main actionable groups (1 warning-level).
Detailed fixes: d15_recommendation.md · top locations in Appendix A, every location in findings.md.
Do you agree with this assessment?
D16 · Bus Factor9.5 / 10Exemplary✓ 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.
107 source file(s) have their living knowledge concentrated in one author (≥90% of recent, decayed contribution). The largest is baml_language/crates/baml_ide/src/cfg.rs. Counted over 2223 of the 3400 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 · ×5
Further sole-owners (lower concentration)
✓ On the Gold path — maintain.
Detailed fixes: d16_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Acknowledged debt left in the code — TODOs, dead code, suppressed warnings.
Method: Roslyn syntactic debt markers (suppressions/TODO/FIXME/HACK/empty-catch/commented-code/Obsolete) plus SymbolFinder dead-code analysis; weighted-debt-per-KLoC density deducted 2.0x per unit. Deterministic, exhaustive.
65 deducted debt markers + 1 dead symbols across 29690 LoC in the .NET projects (2.0/KLoC) → score 6.0. Measured on the .NET source only: .rs (76% of production source) was not read, and carries at least 410 uncounted task marker(s) in 195 file(s).
Dead code: ReadHandleFieldsbaml_language/sdks/csharp/bridge_csharp/src/Generated/V1/BamlGeneratedCodec.cs:1700
What to do
Resolve the 53 WriteOnlyPrivateField finding(s) in Explicit Debt — start with REDACTED (53). — One of this dimension's main actionable groups (53 issue-level).
Resolve the 9 EmptyCatchBlock finding(s) in Explicit Debt — start with BamlStream.cs (4), REDACTED (2), NativeCallbacks.cs (2). — One of this dimension's main actionable groups (9 issue-level).
Resolve the 3 CommentedOutCode finding(s) in Explicit Debt — start with REDACTED (2), REDACTED. — One of this dimension's main actionable groups (3 warning-level).
Enforce Explicit Debt in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.
Detailed fixes: d17_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether the project's documentation is clear, complete, and useful.
Method: Every README, docs/ document and root guide parsed by its markup and measured in Unicode letters. Published: a runnable or packaged .NET project whose README (or a document it links, or a root guide) shows no example, and a root README naming none of three or more projects. Overview, licence, boilerplate, wall-of-text, empty-section and XML-doc rows are measured and withheld (counted in gaps) after adjudication. Deterministic, exhaustive, advisory.
1 of 2 documentation facets pass in full; short on: F2 example. 135 document(s) read across 19 unit(s).
Documentation: no build, run or usage example · ×3baml_language/sdks/csharp/bridge_csharp/tools/Baml.BytecodeCarrierEmitter/README.md:1
What to do
Resolve the 3 Documentation finding(s) in Documentation Quality — start with README.md (3). — One of this dimension's main actionable groups (3 recommendation-level).
Detailed fixes: d19_recommendation.md · top locations in Appendix A, every location in findings.md.
Do you agree with this assessment?
D20 · ADR Quality0.0 / 10Critical✓ Tool-verified
What it measures: Whether architecture decisions are recorded well (context, decision, consequences).
Method: 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.
What it measures: Whether domain types (IDs, enums, value objects) leak across bounded-context boundaries.
Method: Cross-context domain-type leakage via Roslyn structural classification (strongly-typed IDs / value objects) over every public surface. Exhaustive, deterministic, type-level aggregate-boundary check.
Coverage: Bounded contexts derived from NAMESPACE prefix (or graph-inferred where available); cross-boundary domain-type leakage then checked exhaustively over every public member of every type.
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.
7 finding(s): 0 critical, 7 high, 0 medium, 0 low. Remediation for historically-committed secrets is credential rotation — they remain in history regardless of later deletion.
REDACTED
REDACTED
REDACTED
What to do
Resolve the 4 REDACTED finding(s) in Secrets (history) — start with REDACTED (4). — One of this dimension's main actionable groups (4 issue-level).
Resolve the 3 High secret finding(s) in Secrets (history) — start with REDACTED (3). — One of this dimension's main actionable groups (3 issue-level).
Resolve the 1 Rotate the exposed credentials finding(s) in Secrets (history). — One of this dimension's main actionable groups (1 recommendation-level).
Detailed fixes: d28_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Real static-analysis (SAST) findings — likely security bugs in the code, any language.
Method: Polyglot static analysis via semgrep across the repo using the pinned, image-baked p/security-audit + p/owasp-top-ten rulesets (no scan-time registry fetch); severity rules (ERROR/WARNING/INFO) map to a full-band severity-weighted score. Exhaustive, deterministic; degrades on parse failure.
Coverage: semgrep pattern rules over all files — exhaustive for the rule set, blind to classes of bug without a rule (clean = no rule matched).
651 finding(s): 0 critical, 492 high, 69 medium, 90 low. 408 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 58 file(s) — `REDACTED`, `baml_language/.obsidian/core-plugins.json`, `baml_language/crates/bex_engine/src/lib.rs` (line 1772, line 1787, line 1791, …), `baml_language/crates/bex_heap/src/chunked_vec.rs` (line 153), `baml_language/crates/bex_vm/src/indexable.rs` (line 57), … (+53 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. In 9 of those file(s) — `baml_language/sdks/csharp/bridge_csharp/src/Cffi/HostCallDispatcher.cs`, `baml_language/sdks/csharp/bridge_csharp/src/Cffi/HostValueRegistry.cs`, `baml_language/sdks/csharp/bridge_csharp/src/Cffi/NativeApi.cs`, `baml_language/sdks/csharp/bridge_csharp/src/Generated/V1/BamlGeneratedArguments.cs`, `baml_language/sdks/csharp/bridge_csharp/src/Generated/V1/BamlGeneratedCanonicalCodecs.cs`, … (+4 more) — the break is a C# primary constructor, which semgrep's grammar cannot parse and which hides the type from every rule scoped to it; those files were re-scanned from a shadow copy with the constructor's parameter list blanked (line and column preserving), which restores the type to the rules, and 0 additional row(s) came from that pass. Only the header's own parameter list is unread in them. In 1 of those file(s) — `baml_language/sdks/csharp/bridge_csharp/src/Values/BamlValue.cs` — the break is at a TYPE DECLARATION (a C# primary constructor semgrep's grammar cannot parse), so the loss is wider than the named lines: rules scoped to that type see no type to scope to and are blind over its whole body, while rules matching statements keep working there. Absence of a type-scoped finding in those types is not evidence of anything. Separately, one or more rules could not re-parse an embedded snippet in 33 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
+ 35 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Resolve the 22 REDACTED finding(s) charged to Static Analysis (SAST) — the other 408 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 (430 issue-level, 22 of them charged here).
Resolve the 10 REDACTED finding(s) in Static Analysis (SAST) — start with REDACTED (4), REDACTED (4), REDACTED. — One of this dimension's main actionable groups (10 issue-level).
Resolve the 8 REDACTED finding(s) in Static Analysis (SAST) — start with REDACTED (8). — One of this dimension's main actionable groups (8 issue-level).
Detailed fixes: d29_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether any dependency has a known published vulnerability (CVE), direct or transitive, in ANY ecosystem the repository declares — Dart pub, Elixir and Erlang via Hex, Go modules, Java and Kotlin via Maven/Gradle, JavaScript/npm, .NET/NuGet, PHP/Composer, Python/PyPI, RubyGems, Rust/Cargo and Swift.
Method: Dependency-CVE scan across every ecosystem the repository declares, scored ONCE. Three sources are unioned and deduplicated by advisory identity (rule id + alias closure, CVE<->GHSA) scoped to package+version, keeping the worst severity: `osv-scanner --recursive` over osv.dev for Dart pub, Elixir/Hex (and Erlang, whose `rebar.lock` syft first converts to a CycloneDX SBOM the scanner reads, with rows attributed back to the lock), Go, Java and Kotlin via Maven/Gradle (and Scala, whose sbt build's pinned direct declarations are written into a CycloneDX SBOM the scanner reads, with rows attributed back to the build file), npm, PHP/Composer, Python/PyPI, RubyGems, Rust/Cargo and Swift; `trivy fs --scanners vuln` for npm lockfiles; and `dotnet list package --vulnerable --include-transitive` for NuGet (with per-advisory collapse of the project x target-framework fan-out), plus a DECLARED-dependency arm that resolves a published gem's gemspec against rubygems.org where no Gemfile.lock is committed. `SeverityScore(c,h,m,l, normalizer 8.0)`. NotApplicable only when NO ecosystem is readable; if any applicable ecosystem could not be scanned the findings are REPORTED and the score is withheld. Supersedes the npm and OSV arms, retired 2026-09-05.
+ 5 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Resolve the 113 High CVE finding(s) in Dependency Vulnerabilities — start with REDACTED (95), REDACTED (10), REDACTED (5). — One of this dimension's main actionable groups (113 issue-level).
Resolve the 19 Critical CVE finding(s) in Dependency Vulnerabilities — start with REDACTED (16), REDACTED (3). — One of this dimension's main actionable groups (19 issue-level).
Resolve the 9 Critical vulnerability finding(s) in Dependency Vulnerabilities — start with REDACTED (5), REDACTED (2), REDACTED (2). — One of this dimension's main actionable groups (9 issue-level).
Detailed fixes: d30_recommendation.md · top locations in Appendix A, every location in findings.md.
Resolve the 4 High IaC finding(s) in IaC & Container Security — start with REDACTED (2), REDACTED (2). — One of this dimension's main actionable groups (4 issue-level).
Resolve the 6 Medium IaC finding(s) in IaC & Container Security — start with REDACTED (5), REDACTED. — One of this dimension's main actionable groups (6 warning-level).
Resolve the 4 Low IaC finding(s) in IaC & Container Security — start with REDACTED (4). — One of this dimension's main actionable groups (4 recommendation-level).
Detailed fixes: d31_recommendation.md · top locations in Appendix A, every location in findings.md.
Do you agree with this assessment?
D32 · Data Compliance (PII/GDPR)9.0 / 10Stronggated by 1 serious finding✓ Tool-verified
What it measures: Likely personal-data (PII / GDPR) handling concerns — logging or storing data without safeguards.
Method: Heuristic PII/GDPR LEAK scan via semgrep across the repo, using Watchdog's own ruleset: personal data crossing a boundary it should not — reaching a log/console sink, a URL or query string, or unprotected browser storage. Matches map to severity and a 0-10 wide normalizer. A clean sweep is unscored rather than an unearned 10, and is a statement about the leak paths checked only — this dimension does not inventory the personal data a repository holds (the personal-data map and the C1-C5 compliance cards do that), so it never reports that a repository has no personal-data surface. Reported LOUDLY as a measurement gap if the ruleset is missing from the analyzer image. Exhaustive over the leak paths, advisory-leaning; degrades on parse failure.
1 finding(s): 0 critical, 0 high, 1 medium, 0 low. semgrep could not parse 38 file(s) — `baml_language/sdks/csharp/bridge_csharp/src/Cffi/HostCallDispatcher.cs`, `baml_language/sdks/csharp/bridge_csharp/src/Cffi/HostValueRegistry.cs`, `baml_language/sdks/csharp/bridge_csharp/src/Cffi/NativeApi.cs`, `baml_language/sdks/csharp/bridge_csharp/src/Generated/V1/BamlGeneratedArguments.cs`, `baml_language/sdks/csharp/bridge_csharp/src/Generated/V1/BamlGeneratedCanonicalCodecs.cs`, … (+33 more) — so the PII/GDPR sweep did not cover the unparsed regions of them; rows reported elsewhere in those files are real.
REDACTED
What to do
Resolve the 1 REDACTED finding(s) in Data Compliance (PII/GDPR) — start with REDACTED. — One of this dimension's main actionable groups (1 warning-level).
Detailed fixes: d32_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether anyone still has living knowledge of each file, or it has been orphaned — last understood long ago by someone now gone quiet. The sibling of the bus factor: D16 asks who owns it, D34 asks whether anyone still knows it.
Method: File orphaning as total living-knowledge decay below one focused-commit's worth within a year, computed per-file from the D16 decay model. Exhaustive, deterministic over fixed history.
81 of 2223 significant source file(s) are orphaned — their living knowledge has decayed to nothing, so no one currently understands them. The largest is engine/baml-runtime/src/optimize/tui.rs. Counted over 2223 of the 3400 production source files in this repository: the rest are under the ~2,400-byte size floor this dimension measures over.
Resolve the 13 Orphaned knowledge finding(s) in Knowledge Freshness — start with tui.rs, mermaid_debug.rs, async_interpreter_runtime.rs. — One of this dimension's main actionable groups (13 issue-level).
Resolve the 68 Orphaned file finding(s) in Knowledge Freshness — start with types.rs (2), index.tsx (2), watchers.rs (2). — One of this dimension's main actionable groups (68 recommendation-level).
Resolve the 1 Further orphaned files (smaller) finding(s) in Knowledge Freshness. — One of this dimension's main actionable groups (1 recommendation-level).
Detailed fixes: d34_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether files that change together actually belong together — pairs that repeatedly co-change in git history despite having no explicit code dependency, surfacing the hidden/logical coupling (and boundaries in the wrong place) a static scan can't see.
Method: Pairwise co-occurrence over the per-commit file sets in git history (production source only — tests and generated dropped): Degree-of-Coupling = shared ÷ min individual revisions, reported above noise floors (each file ≥10 revisions, ≥5 shared commits, ≥50% strength); sweeping commits excluded. Deterministic over fixed history.
Coverage: Population: PRODUCTION source files only — test and generated files are dropped before pairing, so a class co-changing with its own test (trivially ~100%) can't drown the real production↔production coupling. Pairs ranked by Degree-of-Coupling. A non-source file is never a coupling PARTICIPANT either: documentation, schemas, config and data files are dropped with the rest, so a code↔docs pair — a command and the reference page that restates it — is not reported however strongly the two co-change; nor is coupling that runs THROUGH a build step or config file.
Resolve the 6 Change coupling finding(s) in Change Coupling — start with completion.rs (2), mod.rs (2), ast.rs. — One of this dimension's main actionable groups (6 warning-level).
Resolve the 2 Change-coupling hub finding(s) in Change Coupling — start with chat.rs, llm_provider.rs. — One of this dimension's main actionable groups (2 warning-level).
Detailed fixes: d35_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether the build pipeline provides supply-chain integrity — generated provenance/attestation, signed artifacts (cosign/sigstore), an SBOM, and pinned build actions. Presence of the configuration, not a runtime guarantee.
Method: Supply-chain provenance/signing read deterministically from CI/build config (.github/workflows, .gitlab-ci.yml, azure-pipelines, Jenkinsfile, .circleci) + the release surface: four signals — generated provenance/attestation (SLSA/in-toto/actions-attest), artifact signing (cosign/sigstore/gitsign), an SBOM (syft/sbom-action/*.spdx.json/*.cdx.json), and SHA-pinned build actions — scored 10·present/denom. NotApplicable without a build pipeline. Detects configuration presence, not runtime enforcement.
+ 5 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Resolve the 6 REDACTED finding(s) in Supply-chain Provenance & Signing — start with REDACTED, REDACTED, REDACTED. — One of this dimension's main actionable groups (6 warning-level).
Resolve the 6 REDACTED finding(s) in Supply-chain Provenance & Signing — start with REDACTED, REDACTED, REDACTED. — One of this dimension's main actionable groups (6 warning-level).
Resolve the 2 REDACTED finding(s) in Supply-chain Provenance & Signing — start with REDACTED, REDACTED. — One of this dimension's main actionable groups (2 warning-level).
Detailed fixes: d36_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether any dependency the repository declares is published as MALICIOUS rather than merely vulnerable — a package that is an attacker's work, in any ecosystem osv-scanner reads. Scored apart from D30 because the answer is binary: there is no safe version to upgrade to, and the fix is to remove the package and rotate every credential it could have read.
Method: The same dependency scan D30 reads, partitioned on the scanner's own classification rather than rescanned: a row is MALICIOUS when its id is in the `MAL-` space (the ossf/malicious-packages feed) OR its `database_specific.cwe_ids` carries `CWE-506` ("Embedded Malicious Code"). Both channels are structural; the summary text is deliberately NOT read, because a malicious-package record whose summary says only "Critical severity vulnerability" is a real shape ([GHSA redacted]) and a text matcher misses it. Scored BINARY: any surviving row is 0, whatever its severity and however many CVEs sit beside it — a hostile dependency is not a quantity. Applicability and degradation are D30's: NotApplicable only when no ecosystem is readable, and an unscannable ecosystem degrades rather than reading clean. SCORED, not informational.
What it measures: Whether anyone still ships security patches for the platform this repository RUNS ON — the runtime it pins and the framework majors its own constraints hold it to. Separate from D12 because the question differs: a current Django on an end-of-life Python is perfectly up to date and completely unsupported, and the fix is a migration rather than a version bump. What the repository says it merely SUPPORTS is never charged.
Method: End-of-life PLATFORM read from the repository's own declarations and graded against a FROZEN, dated table of vendor support dates — no network, no feed, no API, so this dimension answers identically inside a closed scan fence. Two subjects: a RUNTIME the project pins (a single or all-end-of-life TargetFramework, a .nvmrc or .python-version, a requires-python CAP) and a FRAMEWORK major a dependency constraint cannot move off (a caret, tilde or exact version; `vue@^2.7.16` pins Vue 2). A FLOOR is deliberately never charged — `requires-python = ">=3.8"` states what a package SUPPORTS, not what it runs on — and a multi-target project is charged only when EVERY target is out of support. Runtime 4.0/product capped 8.0, framework 1.5 capped 4.5. The table is safe to freeze because a statement about support that ended in the past cannot become false: it loses recall as it ages, never precision, and a test asserts every entry predates the freeze date. Disjoint from D31 (a container image's OS layer) and D29 (the toolchain a CI workflow installs). Abstains when the repository declares no platform this pass reads — never scores it clean.
2 end-of-life runtime(s) and 0 end-of-life framework(s), read from 68 platform declaration(s) and 57 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.
Resolve the 2 End-of-life runtime finding(s) in Platform End-of-Life — start with REDACTED (2). — One of this dimension's main actionable groups (2 warning-level).
Detailed fixes: d44_recommendation.md · top locations in Appendix A, every location in findings.md.
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.
Method: Roslyn line-count by code ROLE: every source file classified Domain/Application/Infrastructure/Test/Generated by namespace + path convention (the shared CodeRoleClassifier), then significant lines summed per role. Deterministic; the advisory score is the business-logic (domain+application) share of production code.
Coverage: Population: ALL source files, each bucketed into ONE of five roles (Domain/Application/Infrastructure/Test/Generated) by namespace + path convention — a file whose layer isn't named in the convention falls to Application (the neutral default), and the split is line-count, not semantic depth or business value.
What to do
The domain core is a small share of production code, but most of the rest matched no layer vocabulary at all — so this is not yet an anemic-domain finding. The namespace/path convention could not place that code, which makes the composition above a statement about the naming, not about the design. Name the layers (or check that the repository's conventions differ from the ones this check knows) before reading a thin domain into it.
Other · Architecture — Whether the project-reference graph is acyclic (cycles block independent build/deploy and signal eroding boundaries).
Method: Project reference cycles via elementary-DFS over real .csproj references, using the engine shared with D5/D7; cyclic versus acyclic. Exhaustive, deterministic.
The namespaces Baml ↔ Baml.Cffi ↔ Baml.Generated.V1 ↔ Baml.Proto ↔ Baml.Runtime depend on each other. The lightest dependency in the cycle is Baml.Cffi → Baml (Baml.Cffi.NativeApi → Baml.MediaPayload, 1 type pair(s)); cut that one first, e.g. by moving the shared type to a namespace both can use or inverting it behind an interface. — baml_language/sdks/csharp/bridge_csharp/src/Cffi/NativeApi.cs:5
What to do
Break namespace cycles inside a project by moving the shared type to a namespace both sides can use, or by inverting the back edge behind an interface.
Other · Architecture — Whether dependencies point inward (Domain ← Application ← Infrastructure/Web) — the clean-architecture dependency rule, checked across the project graph.
Method: Layer violations by name-segment inference (Domain/Core to Application to Infrastructure/Web) over the project-reference graph. Exhaustive over all projects, deterministic.
Other · Architecture — Whether the codebase has a recognisable, scale-appropriate structure (a named architectural style, or modular enough for its size) rather than being an ad-hoc ball of mud.
Method: Roslyn plus csproj analysis: architecture style detection (DDD, clean, vertical-slice, CQRS) and structure fitness for repo size. Deterministic.
Other · Architecture — Whether interfaces stay focused rather than fat — the Interface-Segregation principle (SOLID 'I').
Method: Roslyn scan: public interface declared-member counts (accessors fold into their property/event); fat-interface threshold (over 15 declared members) flagged per type. Each finding also reports the distinct-OPERATION count — members counted by name, so an overload group counts once — which decides whether it states the caller-side ISP harm or the implementer-side burden of an overload set. TypeScript: exported interfaces that declare behaviour, counted over their REQUIRED operations (method signatures and function-typed properties with no `?`, once per signature) — data-shape interfaces and ambient .d.ts declarations are outside the population; JavaScript declares no interfaces and is not applicable. Deterministic, type-level.
`SDKStorage` declares 78 required operations: `setWasm`, `getWasm`, `setRuntime`, `getRuntime`, `setWorkflows`, `getWorkflows`, `setActiveWorkflowId`, `getActiveWorkflowId`, `addExecution`, `getExecutions`, `updateExecution`, `setNodeState`, `getNodeState`, `clearAllNodeStates`, `setNodeIteration`, `getNodeIteration`, `incrementNodeIteration`, `getLoopOrdinals`, `setLoopOrdinal`, `clearAllNodeIterations`, `addNodeExecution`, `getNodeExecution`, `setCacheEntry`, `getCacheEntry`, `clearCache`, `getVersion`, `setWasmRuntime`, `getWasmRuntime`, `getDiagnostics`, `getFunctions`, `getGeneratedFiles`, `setWasmPanic`, `getWasmPanic`, `setFeatureFlags`, `getFeatureFlags`, `setEnvVars`, `getEnvVars`, `setBAMLFiles`, `getBAMLFiles`, `setParsedBAMLFiles`, and 38 more. Counted over its REQUIRED operations — a method signature or a function-typed property with no `?`, once per signature; optional members and data properties are not counted, because no implementer is forced to write them. A wide interface forces every implementer and caller to depend on methods they don't use (the Interface-Segregation 'I' in SOLID). Split it into focused role-interfaces. — typescript/packages/playground-common/src/sdk/storage/SDKStorage.ts:44
`RunStoreClient` declares 17 required operations: `startRun`, `startPreviewRun`, `startTestRun`, `cancelRun`, `respondToInput`, `respondToEnv`, `listRuns`, `listHistory`, `listExecutions`, `openExecution`, `readTelemetryMedia`, `openHistory`, `snapshot`, `readValue`, `subscribe`, `unsubscribe`, `dispose`. Counted over its REQUIRED operations — a method signature or a function-typed property with no `?`, once per signature; optional members and data properties are not counted, because no implementer is forced to write them. A wide interface forces every implementer and caller to depend on methods they don't use (the Interface-Segregation 'I' in SOLID). Split it into focused role-interfaces. — typescript2/pkg-playground/src/run-store-client.ts:56
`ExecutionStore` declares 17 required operations: `getSnapshot`, `subscribe`, `startRun`, `startPreviewRun`, `startTestRun`, `cancelRun`, `respondToInput`, `respondToEnv`, `listRuns`, `listHistory`, `openHistory`, `snapshotRun`, `followRun`, `applySnapshot`, `applyPatch`, `selectRun`, `dispose`. Counted over its REQUIRED operations — a method signature or a function-typed property with no `?`, once per signature; optional members and data properties are not counted, because no implementer is forced to write them. A wide interface forces every implementer and caller to depend on methods they don't use (the Interface-Segregation 'I' in SOLID). Split it into focused role-interfaces. — typescript2/pkg-playground/src/execution-store.ts:27
What to do
Split fat interfaces into focused role-interfaces so clients depend only on what they use.
Do you agree with this assessment?
AX8 · Test isolation0.0 / 10Critical✓ 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.
`generators-go` (production) references the test project `type_test_spec`. Production must never depend on test code — it pulls a unit-test framework and test fixtures into the shipped product and inverts the only correct direction (tests depend on production, never the reverse). Move any shared helper into a production support library, or invert the reference.
`generators-python` (production) references the test project `type_test_spec`. Production must never depend on test code — it pulls a unit-test framework and test fixtures into the shipped product and inverts the only correct direction (tests depend on production, never the reverse). Move any shared helper into a production support library, or invert the reference.
`generators-rust` (production) references the test project `type_test_spec`. Production must never depend on test code — it pulls a unit-test framework and test fixtures into the shipped product and inverts the only correct direction (tests depend on production, never the reverse). Move any shared helper into a production support library, or invert the reference.
`generators-typescript` (production) references the test project `type_test_spec`. Production must never depend on test code — it pulls a unit-test framework and test fixtures into the shipped product and inverts the only correct direction (tests depend on production, never the reverse). Move any shared helper into a production support library, or invert the reference.
What to do
Remove every production → test project reference: extract any shared test helper into a production support library (which the tests reference), or invert the dependency so the test project depends on production — not the reverse.
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.
Other · Domain Modelling — Whether an aggregate references another aggregate by identity rather than embedding it by object reference.
Method: Roslyn (DDD-gated): aggregate roots identified by convention; each aggregate field checked for direct references to other aggregates versus id-only. Deterministic, DDD-native.
Coverage: Population: aggregate roots identified by AggregateRoot/IAggregateRoot base/interface NAME convention; reference-by-identity then checked exhaustively within that set — a root not using those names is invisible.
Other · Domain Modelling — Whether domain identifiers are strongly typed (a newtype wrapper) rather than raw primitives — consistency once an idiom exists.
Method: Roslyn (DDD-gated): strongly-typed id adoption on domain entities/events; raw Guid/int/string ids counted versus wrapped types. An id wrapper is recognised by VALUE SEMANTICS, not by being a struct — a record struct, a record class (`record ApartmentId(Guid Value)`) or a class declared by a typed-id base (`class MemberId : TypedIdValueBase`) all count, while a plain mutable class (reference equality) and a verb-phrase query record (`GetCustomerById`) do not. Deterministic, adoption percentage.
Coverage: Population: id-like members by *Id/*Key NAME suffix; strongly-typed-ID shape then checked semantically — non-suffixed identifiers are not seen.
Do you agree with this assessment?
DM4 · Rich vs anemic domain model10.0 / 10Exemplary✓ Tool-verified
Other · Domain Modelling — Whether domain entities own their behaviour (invariant-enforcing commands) rather than being data-only structs driven by a foreign service.
Method: Roslyn (DDD-gated): entity method BODIES classified mutator-vs-query — only methods that mutate the entity's own declared state count as invariant-protecting behaviour, so a getter/passthrough doesn't rescue an anemic class. Deterministic, exhaustive over domain-layer entities.
Coverage: Population: entities by name/base convention; rich-vs-anemic judged by classifying each method body mutator-vs-query — logic-bearing domain types outside the convention are invisible.
Other · Domain Modelling — Whether a domain type's identity-bearing field stays immutable — a `pub` mutable field under a hand-rolled Hash/PartialEq breaks the value-identity invariant.
Method: Roslyn (DDD-gated): entities scanned for publicly writable state — public setters, and (C#/VB) own mutable collections handed out through an auto-property, a public field or a bare-field expression getter, where a computed/copying getter is never charged. One finding per entity; score softened when Marten/EF rehydration frameworks present. Deterministic, framework-aware.
Coverage: Population: entities by convention; encapsulation (setter shape) checked exhaustively within the set.
Other · Domain Modelling — Whether repositories are per aggregate root (not per child entity) and keep the persistence query handle behind the contract, so the root's invariants can't be bypassed.
Method: Roslyn (DDD-gated): repository abstraction detection; repositories over non-aggregate-root entities flagged, and (C#/VB) repository INTERFACES whose members return a live persistence query handle (IQueryable/DbSet/IMongoQueryable) — implementations and specification evaluators are out of population by design, since composing a query internally is what an implementation is for. Deterministic, DDD-native.
Coverage: Population: repositories + aggregate roots by NAME convention; per-root repository rule checked within the set.
Other · Event Sourcing — Whether the recovery-replay fold is deterministic — state derived purely from each event's own fields, no clock/random/IO on the replay path.
Method: Roslyn syntax scan (event-sourcing gated): Apply/When folds checked for forbidden tokens (DateTime.Now, Guid.NewGuid, Random, IO), stripped of comments/strings. Deterministic, hard fact per fold.
Other · Event Sourcing — Whether domain events stay immutable (private fields, set once) rather than carrying mutable state.
Method: Roslyn scan (event-sourcing gated): persisted events checked for public setters; immutability verified per property/field. Deterministic, hard fact.
Other · Code Health — Unreviewed-generation residue: shipped members still throwing NotImplementedException, and placeholder string literals left in non-test, non-generated code. Scored as a quality signature, never as a claim about authorship.
Method: Roslyn syntax scan: NotImplementedException throws and placeholder string literals in non-test, non-generated shipped code. Deterministic, code-shape signature.
Other · Code Health — Unfinished work detected by code SHAPE, not keywords: members that only throw a "not implemented" exception, methods that take inputs and return a constant, async methods that never await, dead `if (false)` / `#if false` branches, and skeleton types most of whose members are holes. A real, objective slice of technical debt.
Method: Roslyn syntax scan: incompleteness by code shape (constant-returning methods, async-never-await, #if false branches, guards that return what the code already falls through to, tests an earlier guard already decided, comparisons against NaN, skeleton types), not keyword-gated. Deterministic, code-shape heuristic.
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 build/run (quick start) section to the root README — the first thing a newcomer needs.
Explain in the README how to run the tests. Add a section called Testing to the README in the repository's top folder, saying how to run the test suite.
Add an 'Architecture' / 'How it works' section to the root README — the high-level shape.
Add a README to the 14 of 18 project(s) that lack one — worth up to 1.6 pts.
Maturity · Maturity — Whether key decisions (ADRs) and the high-level shape (C4/diagrams) are written down.
Method: Filesystem scan: ADR folder/naming conventions or content, plus Mermaid/PlantUML/C4/architecture.md discovery. Exhaustive, deterministic.
No Architecture Decision Records found — no conventional ADR directory, no numbered `NNNN-title` documents in any markup this check reads, and nothing ADR-shaped by content. Design rationale recorded elsewhere (a design-notes tree, a mailing list, pull-request discussion) is not visible to this check and is not re-findable per decision, so a future maintainer cannot ask why one choice was made and get an answer.
What to do
Record your significant design decisions. Write one short document per decision, giving its date, the situation, the decision and its consequences, and keep them together with your other design documents. A docs/adr folder with each file named by number and title is the easiest place to find them.
Maturity · Maturity — Whether the 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.
Only 6/18 projects share a common root namespace — the code's module identity is inconsistent.
What to do
Adopt a consistent root-namespace convention (a shared prefix, e.g. Acme.*); short project-file/directory names are fine as long as the RootNamespace is uniform.
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.
engine/vendored/minijinja/README.md links to `CONTRIBUTING.md#ai-disclosure`, but `engine/vendored/minijinja/CONTRIBUTING.md` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every REDACTED, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong. — engine/vendored/minijinja/README.md:157
engine/vendored/minijinja/README.md links to `UPDATING.md`, but `engine/vendored/minijinja/UPDATING.md` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every REDACTED, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong. — engine/vendored/minijinja/README.md:166
What to do
Reconcile the README with reality: engine/vendored/minijinja/README.md links to `CONTRIBUTING.md#ai-disclosure`, but `engine/vendored/minijinja/CONTRIBUTING.md` does not exist; engine/vendored/minijinja/README.md links to `UPDATING.md`, but `engine/vendored/minijinja/UPDATING.md` does not exist.
Readiness · Readiness — Whether an automated pipeline builds and tests every change.
Method: Filesystem scan: CI workflow files (.github/workflows, .gitlab-ci.yml, etc.) for build and test stages. Exhaustive, deterministic.
Do you agree with this assessment?
P10 · Library API & versioning10.0 / 10Exemplary○ Nothing flagged
Readiness · Readiness — For a library: a deliberate (small) public API surface and explicit semantic versioning so consumers can depend on it safely.
Method: Roslyn scan: public API surface area and semantic-versioning markers (SemVer attributes, changelog entries) for libraries; off .NET, a library is the ecosystem's publication act (an npm package that is not private and names an entry point, a PyPI distribution with a build system, a Rust library crate, a Maven/Gradle module that publishes, a Go module with no package main, a gemspec, a Composer library, a SwiftPM library product, a pub.dev or Hex package), its surface is the share of types the language model records as public (Rust, Swift, Java, Kotlin, Go, Dart; not measured where the model records no type visibility or, as in TypeScript, only module-level export), and its version is read from the manifest, a semver CHANGELOG, release tooling or semver git tags. Exhaustive, deterministic.
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
Dependabot is configured but does not watch `nuget`, `cargo`, `gomod`, `gradle`, `bundler` — add those `package-ecosystem` entries to .github/dependabot.yml so those dependencies get the same automatic update and advisory pressure as the ones it already covers.
Add gitleaks/trufflehog in CI to block PRs that introduce committed secrets.
Readiness · Readiness — Whether releases are automated and safely reversible (probes, rolling updates, approval gates) — from manifests/pipeline files, not the live environment.
Method: Filesystem scan: deployment manifests/IaC (K8s YAML, Helm, Terraform) for rolling updates, probes, approval gates, migration hooks. Exhaustive, deterministic.
Readiness · Readiness — Whether database schema changes go through versioned migrations rather than being auto-created from the model at startup.
Method: Roslyn scan: EF Core DbContext for a versioned migrations directory versus bare EnsureCreated usage; off .NET, a file scan of dependency manifests, migration histories (Flyway, Liquibase, Alembic, Django, Rails, Prisma, TypeORM, Knex/Sequelize, golang-migrate, goose, Laravel, Doctrine, Diesel/sqlx) and schema auto-create in production source or config. Exhaustive, deterministic.
Readiness · Performance — Whether the code protects its performance with benchmarks — a benchmark suite, allocation/memory measurement, and (ideally) a CI gate. Presence is credited as a bonus, never a deduction.
Method: Repo + source scan: BenchmarkDotNet referenced (csproj/source), [Benchmark]/[MemoryDiagnoser] attribute counts, and a benchmark step in CI; off .NET, the same ladder over Go testing.B, Rust criterion/#[bench]/divan, JMH/kotlinx-benchmark, pytest-benchmark/asv/pyperf, tinybench/mitata/vitest bench/benchmark.js and Swift package-benchmark — scored as a bonus ladder (absence is neutral, never a deduction). Deterministic, presence detection.
No benchmark suite was found by the two searches this check runs. FIRST, a BenchmarkDotNet package reference in any project file — every project the workspace loaded, plus a walk of project files on disk that never loaded, because a benchmark suite is exactly the project a partial load drops. SECOND, a script harness: a file whose name contains `benchmark` and ends `.py`, `.sh`, `.ps1`, `.bash`, `.rb`, `.js` or `.mjs`, credited ONLY when this repository's CI text also mentions benchmarks — a harness no pipeline runs is read as a fixture, deliberately. Neither search can see a benchmark suite in another ecosystem's idiom (a Go `testing.B` file, a JMH or criterion project, a pytest-benchmark run), so this is 'no benchmark found by those two searches', not a verdict that the repository has none. Where code is performance-sensitive, a benchmark guards against silent regressions — but it's a bonus here, not a deduction.
What to do
Add a benchmarking harness for the hot paths and run it in CI to catch regressions (for .NET, a BenchmarkDotNet project with [MemoryDiagnoser] to track allocations).
Readiness · Performance — Whether the code is written to minimise allocations so it doesn't pressure its host's memory manager — buffer/slice views over copies, object pooling, stack or value-type allocation, and buffer writers. Reward-only: credited where present, never penalised where a simpler style is fine.
Method: Production-source scan: density (per 1k LoC) of allocation-aware APIs — in .NET Span/Memory, ArrayPool/ObjectPool, stackalloc, ValueTask, value-type structs, IBufferWriter, string.Create, SkipLocalsInit; off .NET, with comments and strings blanked, Go's sync.Pool, preallocated slices/maps, Grow, strconv.Append* and buf[:0] reuse; the JVM's NIO buffer views, MemorySegment, primitive collections, pools and literal presizes (plus Kotlin primitive arrays and value classes, Scala AnyVal and @specialized); Swift's reserveCapacity, ContiguousArray, withUnsafe* access and ~Copyable. Activated off .NET on the same floor (400 lines, and benchmarks or 8 uses); Rust and garbage-collected scripting languages are not applicable. Reward-only. Deterministic, syntax/text detection.
What to do
Raise allocation-aware density on the hot paths — currently 165 use(s) across 30,263 production line(s) (~5.5/1k). More Span/Memory, pooling (ArrayPool/ObjectPool), stackalloc and ValueTask on the allocation-heavy paths climbs this toward 10.
Readiness · Performance — Whether asynchronous code stays responsive — it avoids sync-over-async blocking (a .NET .Wait()/.GetAwaiter().GetResult(), a time.sleep or blocking HTTP call inside a Python coroutine, a *Sync call inside an async JavaScript function, block_on inside a Rust async fn, runBlocking inside a Kotlin suspend function, block() inside a Reactor publisher) that stalls a thread or event loop and risks deadlock, and, where the code is a reusable library on .NET, awaits with ConfigureAwait(false) so it never captures and stalls its caller's context.
Method: Production-source scan: sync-over-async blocking counted everywhere — .Wait()/.GetAwaiter().GetResult() in .NET; off .NET, read from the language model, a blocking call inside an async function (Python, TS/JS, Rust, Kotlin, Swift, Dart) or inside a Java method returning a Reactor Mono/Flux or a Scala method returning a Future or effect — and, for a .NET library with ≥5 awaits, the share of awaits using ConfigureAwait(false). Deterministic, syntax/text detection.
`main` is async and calls time.sleep — a blocking call inside async code stalls the event loop — every other task on it waits for as long as it runs. — integ-tests/python/baml_example_tracing.py:50
`run` is async and calls thread::sleep — a blocking call inside async code stalls the executor thread, and every task scheduled on it for as long as it runs. — engine/baml-runtime/src/cli/optimize.rs:167
`existsSync` in `loadRuns` blocks the event loop until it finishes — a blocking call inside async code stalls the event loop — every other request waits for as long as it runs. (×4) — typescript2/app-speedtest/api-server.mjs:29, typescript2/app-speedtest/api-server.mjs:34, typescript2/app-speedtest/api-server.mjs:44, …
13 blocking call(s) on async work (.Wait()/.GetAwaiter().GetResult()) — these waste a thread and can deadlock wherever a synchronization context is in play (a UI thread, or a caller that has one).
`.GetAwaiter().GetResult()` blocks this thread until the async work completes — it wastes a thread-pool thread for as long as the work runs and can deadlock wherever a synchronization context is in play (a UI thread, or a caller that has one). (×13) — baml_language/sdks/csharp/bridge_csharp/src/Generated/V1/BamlGeneratedProgram.cs:32, baml_language/sdks/csharp/bridge_csharp/src/Generated/V1/BamlGeneratedProgram.cs:160, baml_language/sdks/csharp/bridge_csharp/src/Values/BamlFunctionSpec.cs:27, …
`await using … = new FileStream( path, FileMode.Open, FileAccess.Read, FileShare.Rea...` resumes on the caller's captured context. In library code that context belongs to the host application, so a host that blocks on this call (or runs on a UI thread) can stall or deadlock — append `.ConfigureAwait(false)`. — baml_language/sdks/csharp/bridge_csharp/src/Values/BamlMedia.cs:74
`await Task.Yield()` resumes on the caller's captured context. In library code that context belongs to the host application, so a host that blocks on this call (or runs on a UI thread) can stall or deadlock — append `.ConfigureAwait(false)`. — baml_language/sdks/csharp/bridge_csharp/src/Values/BamlStream.cs:533
What to do
Python: await the async equivalent (asyncio.sleep, an async HTTP client such as httpx.AsyncClient or aiohttp, asyncio.create_subprocess_exec), or move the blocking call off the loop with `await asyncio.to_thread(...)`; never call asyncio.run inside a coroutine — await the coroutine.
Rust: `.await` the future instead of `block_on` (on a Tokio runtime thread it panics outright) and use `tokio::time::sleep(..).await` instead of `std::thread::sleep`; where synchronous code must run, move it to `tokio::task::spawn_blocking` or `block_in_place`.
TypeScript/JavaScript: use the promise APIs (fs/promises, a promisified child_process.execFile, the async zlib/crypto functions) and await them instead of the *Sync variants.
Make the call chain async end-to-end and await it — never block on a Task with .Wait()/.GetAwaiter().GetResult().
Do you agree with this assessment?
R1 · Type Safety10.0 / 10Exemplary✓ Tool-verified
React / JS · Code Health — How much of the frontend is typed TypeScript vs untyped JavaScript.
Method: Frontend file inventory: the share of typed TypeScript vs untyped JavaScript across the source tree. Deterministic, exhaustive over frontend files.
React / JS · Code Health — 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.
82 duplicated blocks under the repository root have copies in at least two of the sibling directories baml_language, typescript, typescript2 — 58 of them are reported below, and 24 are counted here but not reported individually: those copies match on shape but no longer clear R10's bar for an individually reported row — either they kept neither their own names nor their values, or what was copied is too small to stand on its own (it reports near-exact duplication only, and only of substantial extent). What this row states is the concentration, which the detector measured over all 82 and which does not depend on how exactly each block's copies still match. That concentration is one structural fact, not 82 local ones: the siblings replicate behaviour none of them owns, which is the shape of a missing shared module — a common library every sibling imports — rather than 82 separate extractions. Check first whether the siblings are deliberately standalone deliverables (scaffold templates, demo apps that must stay copy-pasteable); where they are, the duplication is the design and the per-block rows are the ones to act on. — typescript/packages/ui/src/components/carousel.tsx:3
44 duplicated blocks under typescript2/ have copies in at least two of the sibling directories app-beps, app-developer-docs, app-feedback, app-type-quiz, app-vscode-ext, app-vscode-webview (+6 more sibling(s) not listed) — 20 of them are reported below, and 24 are counted here but not reported individually: those copies match on shape but no longer clear R10's bar for an individually reported row — either they kept neither their own names nor their values, or what was copied is too small to stand on its own (it reports near-exact duplication only, and only of substantial extent). What this row states is the concentration, which the detector measured over all 44 and which does not depend on how exactly each block's copies still match. That concentration is one structural fact, not 44 local ones: the siblings replicate behaviour none of them owns, which is the shape of a missing shared module — a common library every sibling imports — rather than 44 separate extractions. Check first whether the siblings are deliberately standalone deliverables (scaffold templates, demo apps that must stay copy-pasteable); where they are, the duplication is the design and the per-block rows are the ones to act on. — typescript2/app-beps/src/components/ui/select.tsx:3
21 duplicated blocks under typescript2/app-website/app/ have copies in at least two of the sibling directories atb, baml-intro, bamlcode, eap, fight-slop-with-slop, learn2 (+6 more sibling(s) not listed) — 9 of them are reported below, and 12 are counted here but not reported individually: those copies match on shape but no longer clear R10's bar for an individually reported row — either they kept neither their own names nor their values, or what was copied is too small to stand on its own (it reports near-exact duplication only, and only of substantial extent). What this row states is the concentration, which the detector measured over all 21 and which does not depend on how exactly each block's copies still match. That concentration is one structural fact, not 21 local ones: the siblings replicate behaviour none of them owns, which is the shape of a missing shared module — a common library every sibling imports — rather than 21 separate extractions. Check first whether the siblings are deliberately standalone deliverables (scaffold templates, demo apps that must stay copy-pasteable); where they are, the duplication is the design and the per-block rows are the ones to act on. — typescript2/app-website/app/learn2/_deck/Deck.tsx:3
19 duplicated blocks under engine/generators/data/ have copies in at least two of the sibling directories array_types, edge_cases, literal_types, map_types, mixed_complex_types, nested_structures (+3 more sibling(s) not listed) — 8 of them are reported below, and 11 are counted here but not reported individually: those copies match on shape but no longer clear R10's bar for an individually reported row — either they kept neither their own names nor their values, or what was copied is too small to stand on its own (it reports near-exact duplication only, and only of substantial extent). What this row states is the concentration, which the detector measured over all 19 and which does not depend on how exactly each block's copies still match. That concentration is one structural fact, not 19 local ones: the siblings replicate behaviour none of them owns, which is the shape of a missing shared module — a common library every sibling imports — rather than 19 separate extractions. Check first whether the siblings are deliberately standalone deliverables (scaffold templates, demo apps that must stay copy-pasteable); where they are, the duplication is the design and the per-block rows are the ones to act on. — engine/generators/data/edge_cases/typescript/index.ts:213
13 duplicated blocks under typescript2/app-website/ have copies in at least two of the sibling directories app, components, lib — 6 of them are reported below, and 7 are counted here but not reported individually: those copies match on shape but no longer clear R10's bar for an individually reported row — either they kept neither their own names nor their values, or what was copied is too small to stand on its own (it reports near-exact duplication only, and only of substantial extent). What this row states is the concentration, which the detector measured over all 13 and which does not depend on how exactly each block's copies still match. That concentration is one structural fact, not 13 local ones: the siblings replicate behaviour none of them owns, which is the shape of a missing shared module — a common library every sibling imports — rather than 13 separate extractions. Check first whether the siblings are deliberately standalone deliverables (scaffold templates, demo apps that must stay copy-pasteable); where they are, the duplication is the design and the per-block rows are the ones to act on. — typescript2/app-website/app/blog/_components/newsletter-form.tsx:4
13 duplicated blocks under typescript2/app-website/app/atb/ have copies in at least two of the sibling directories _components, agents, arena, builds, issues, runs — 10 of them are reported below, and 3 are counted here but not reported individually: those copies match on shape but no longer clear R10's bar for an individually reported row — either they kept neither their own names nor their values, or what was copied is too small to stand on its own (it reports near-exact duplication only, and only of substantial extent). What this row states is the concentration, which the detector measured over all 13 and which does not depend on how exactly each block's copies still match. That concentration is one structural fact, not 13 local ones: the siblings replicate behaviour none of them owns, which is the shape of a missing shared module — a common library every sibling imports — rather than 13 separate extractions. Check first whether the siblings are deliberately standalone deliverables (scaffold templates, demo apps that must stay copy-pasteable); where they are, the duplication is the design and the per-block rows are the ones to act on. — typescript2/app-website/app/atb/_components/runs-table.tsx:50
10 of the duplicated blocks reported below have copies in at least two of the sibling directories bep, comments, decisions, issues, ui under typescript2/app-beps/src/components/. That concentration is one structural fact, not 10 local ones: the siblings replicate behaviour none of them owns, which is the shape of a missing shared module — a common library every sibling imports — rather than 10 separate extractions. Check first whether the siblings are deliberately standalone deliverables (scaffold templates, demo apps that must stay copy-pasteable); where they are, the duplication is the design and the per-block rows are the ones to act on. — typescript2/app-beps/src/components/decisions/decision-form.tsx:73
7 duplicated blocks under typescript2/app-beps/src/ have copies in at least two of the sibling directories app, components, hooks, lib — 5 of them are reported below, and 2 are counted here but not reported individually: those copies match on shape but no longer clear R10's bar for an individually reported row — either they kept neither their own names nor their values, or what was copied is too small to stand on its own (it reports near-exact duplication only, and only of substantial extent). What this row states is the concentration, which the detector measured over all 7 and which does not depend on how exactly each block's copies still match. That concentration is one structural fact, not 7 local ones: the siblings replicate behaviour none of them owns, which is the shape of a missing shared module — a common library every sibling imports — rather than 7 separate extractions. Check first whether the siblings are deliberately standalone deliverables (scaffold templates, demo apps that must stay copy-pasteable); where they are, the duplication is the design and the per-block rows are the ones to act on. — typescript2/app-beps/src/app/api/agent/beps/[number]/comments/route.ts:95
5 of the duplicated blocks reported below have copies in at least two of the sibling directories apps, packages under typescript/. That concentration is one structural fact, not 5 local ones: the siblings replicate behaviour none of them owns, which is the shape of a missing shared module — a common library every sibling imports — rather than 5 separate extractions. Check first whether the siblings are deliberately standalone deliverables (scaffold templates, demo apps that must stay copy-pasteable); where they are, the duplication is the design and the per-block rows are the ones to act on. — typescript/apps/vscode-ext/src/webview-to-vscode-rpc.ts:1
typescript2/app-website/app/blog/_components/newsletter-form.tsx:4 · typescript2/app-website/components/NewsletterForm.tsx:3 — these 2 files are line-for-line copies of one another — 178 lines are identical, in the same order, in every one of them — so this is one fact about the file set, not a block to extract. An edit made to one file and not the others changes behaviour silently, which is the failure a wholesale copy guarantees. Pick one file as the single source and derive the others from it (re-export it, spread it into the local overrides each variant genuinely needs, or generate the copies at build time) — the few lines that differ between the files are exactly the part each variant should still own. Check first whether the copies are deliberately standalone deliverables (a translation file seeded from its sibling and waiting to be translated); where they are, the duplication is the design, and the honest move is to mark the seeded file as untranslated rather than to let it pass as done. — typescript2/app-website/app/blog/_components/newsletter-form.tsx:4
typescript2/app-promptfiddle/src/playground/vfs.ts:147 · typescript2/app-website/playground/vfs.ts:159 — the 2 copies are spread across 2 files, 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. — typescript2/app-promptfiddle/src/playground/vfs.ts:147
typescript2/app-promptfiddle/src/playground/baml-lsp-worker.ts:856 · typescript2/app-website/playground/baml-worker.ts:641 — the two spans are one implementation copied and then locally edited — 773 tokens are still identical, in the same order in both files, 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. — typescript2/app-promptfiddle/src/playground/baml-lsp-worker.ts:856
REDACTED:15 · REDACTED:188 — the two spans are one implementation copied and then locally edited — 712 tokens are still identical, in the same order in both files, 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. — REDACTED:15
typescript2/app-beps/convex/decisions.ts:8 · typescript2/app-beps/convex/issues.ts:8 — the two spans are one implementation copied and then locally edited — 998 tokens are still identical, in the same order in both files, 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. — typescript2/app-beps/convex/decisions.ts:8
typescript/packages/playground-common/src/features/detail-panel/components/DetailPanel.tsx:324 · typescript/packages/playground-common/src/features/detail-panel/components/DetailPanel.tsx:654 — all 2 copies are in the same file, and the SHAPE of this repetition could not be determined. It is not a run of declarations, a listing, a declaration header, a type body or a slice through a construct — and it was not measured as a run of executable statements either, so this row cannot tell you whether a function can stand where these lines are. Read the two spans before acting, because the move is opposite in the two cases. Where they are statements, the ordinary answer holds: give the shared part one home and call it from each site. Where they turn out to be declarations, a literal's entries, or the cases of an enumeration, there is no call site to call anything from, and collapsing them would delete what each copy pins — a shared base type, a generated set, or one exported constant each site refers to is the move instead, and sometimes the honest answer is that there is nothing to extract at all. Reported because the copies drift apart the first time only one of them is edited, which is true whichever of those they are. — typescript/packages/playground-common/src/features/detail-panel/components/DetailPanel.tsx:324
typescript2/app-beps/src/components/decisions/decision-form.tsx:73 · typescript2/app-beps/src/components/issues/issue-form.tsx:63 — the two spans are one implementation copied and then locally edited — 693 tokens are still identical, in the same order in both files, 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. — typescript2/app-beps/src/components/decisions/decision-form.tsx:73
typescript2/pkg-playground/src/worker-protocol.ts:863 · typescript2/pkg-playground/src/worker-protocol.ts:1060 — the two spans are one implementation copied and then locally edited — 620 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. — typescript2/pkg-playground/src/worker-protocol.ts:863
typescript/packages/ui/src/components/carousel.tsx:3 · typescript2/app-website/components/ui/carousel.tsx:4 — these 2 files are line-for-line copies of one another — 128 lines are identical, in the same order, in every one of them — so this is one fact about the file set, not a block to extract. An edit made to one file and not the others changes behaviour silently, which is the failure a wholesale copy guarantees. Pick one file as the single source and derive the others from it (re-export it, spread it into the local overrides each variant genuinely needs, or generate the copies at build time) — the few lines that differ between the files are exactly the part each variant should still own. Check first whether the copies are deliberately standalone deliverables (a translation file seeded from its sibling and waiting to be translated); where they are, the duplication is the design, and the honest move is to mark the seeded file as untranslated rather than to let it pass as done. — typescript/packages/ui/src/components/carousel.tsx:3
engine/language_client_typescript/errors.js:148 · engine/language_client_typescript/typescript_src/errors.ts:194 — the two spans are one implementation copied and then locally edited — 635 tokens are still identical, in the same order in both files, 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. — engine/language_client_typescript/errors.js:148
typescript/packages/ui/src/components/context-menu.tsx:110 · typescript/packages/ui/src/components/menubar.tsx:87 — the 2 copies are spread across 2 files, 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. — typescript/packages/ui/src/components/context-menu.tsx:110
typescript2/app-beps/src/components/comments/comment-feed-view.tsx:225 · typescript2/app-beps/src/components/comments/comment-feed-view.tsx:565 — the two spans are one implementation copied and then locally edited — 675 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. — typescript2/app-beps/src/components/comments/comment-feed-view.tsx:225
typescript2/app-beps/src/components/ui/select.tsx:3 · typescript2/app-feedback/src/components/ui/select.tsx:3 — these 2 files are line-for-line copies of one another — 106 lines are identical, in the same order, in every one of them — so this is one fact about the file set, not a block to extract. An edit made to one file and not the others changes behaviour silently, which is the failure a wholesale copy guarantees. Pick one file as the single source and derive the others from it (re-export it, spread it into the local overrides each variant genuinely needs, or generate the copies at build time) — the few lines that differ between the files are exactly the part each variant should still own. Check first whether the copies are deliberately standalone deliverables (a translation file seeded from its sibling and waiting to be translated); where they are, the duplication is the design, and the honest move is to mark the seeded file as untranslated rather than to let it pass as done. — typescript2/app-beps/src/components/ui/select.tsx:3
typescript/packages/playground-common/src/shared/baml-project-panel/codemirror-panel/code-mirror-viewer.tsx:175 · typescript2/app-website/lib/mdx/baml-block/baml-project-panel/codemirror-panel/code-mirror-viewer.tsx:105 — the two spans are one implementation copied and then locally edited — 505 tokens are still identical, in the same order in both files, 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. — typescript/packages/playground-common/src/shared/baml-project-panel/codemirror-panel/code-mirror-viewer.tsx:175
typescript2/app-beps/src/components/decisions/decision-card.tsx:47 · typescript2/app-beps/src/components/issues/issue-card.tsx:52 — the two spans are one implementation copied and then locally edited — 555 tokens are still identical, in the same order in both files, 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. — typescript2/app-beps/src/components/decisions/decision-card.tsx:47
typescript2/app-beps/src/lib/export-all-utils.ts:48 · typescript2/app-beps/src/lib/export-utils.ts:39 — the two spans are one implementation copied and then locally edited — 647 tokens are still identical, in the same order in both files, 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. — typescript2/app-beps/src/lib/export-all-utils.ts:48
typescript2/app-beps/src/components/bep/bep-list.tsx:47 · typescript2/app-feedback/src/components/issues/issue-list.tsx:114 — the two spans are one implementation copied and then locally edited — 555 tokens are still identical, in the same order in both files, 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. — typescript2/app-beps/src/components/bep/bep-list.tsx:47
typescript/packages/playground-common/src/features/detail-panel/components/DetailPanel.tsx:200 · typescript/packages/playground-common/src/features/detail-panel/components/DetailPanel.tsx:534 — 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. — typescript/packages/playground-common/src/features/detail-panel/components/DetailPanel.tsx:200
typescript/apps/vscode-ext/src/webview-to-vscode-rpc.ts:1 · typescript/packages/playground-common/src/shared/baml-project-panel/webview-to-vscode-rpc.ts:1 — these 2 files are line-for-line copies of one another — 92 lines are identical, in the same order, in every one of them — so this is one fact about the file set, not a block to extract. An edit made to one file and not the others changes behaviour silently, which is the failure a wholesale copy guarantees. Pick one file as the single source and derive the others from it (re-export it, spread it into the local overrides each variant genuinely needs, or generate the copies at build time) — the few lines that differ between the files are exactly the part each variant should still own. Check first whether the copies are deliberately standalone deliverables (a translation file seeded from its sibling and waiting to be translated); where they are, the duplication is the design, and the honest move is to mark the seeded file as untranslated rather than to let it pass as done. — typescript/apps/vscode-ext/src/webview-to-vscode-rpc.ts:1
typescript2/app-promptfiddle/src/playground/baml-lsp-worker.ts:280 · typescript2/app-website/playground/baml-worker.ts:123 — the 2 copies are spread across 2 files, 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. — typescript2/app-promptfiddle/src/playground/baml-lsp-worker.ts:280
typescript2/app-website/app/learn2/_deck/Deck.tsx:3 · typescript2/app-website/app/learn3/_deck/Deck.tsx:3 — these 2 files are line-for-line copies of one another — 84 lines are identical, in the same order, in every one of them — so this is one fact about the file set, not a block to extract. An edit made to one file and not the others changes behaviour silently, which is the failure a wholesale copy guarantees. Pick one file as the single source and derive the others from it (re-export it, spread it into the local overrides each variant genuinely needs, or generate the copies at build time) — the few lines that differ between the files are exactly the part each variant should still own. Check first whether the copies are deliberately standalone deliverables (a translation file seeded from its sibling and waiting to be translated); where they are, the duplication is the design, and the honest move is to mark the seeded file as untranslated rather than to let it pass as done. — typescript2/app-website/app/learn2/_deck/Deck.tsx:3
typescript/packages/ui/src/components/select.tsx:3 · typescript2/app-website/components/ui/select.tsx:4 — these 2 files are line-for-line copies of one another — 80 lines are identical, in the same order, in every one of them — so this is one fact about the file set, not a block to extract. An edit made to one file and not the others changes behaviour silently, which is the failure a wholesale copy guarantees. Pick one file as the single source and derive the others from it (re-export it, spread it into the local overrides each variant genuinely needs, or generate the copies at build time) — the few lines that differ between the files are exactly the part each variant should still own. Check first whether the copies are deliberately standalone deliverables (a translation file seeded from its sibling and waiting to be translated); where they are, the duplication is the design, and the honest move is to mark the seeded file as untranslated rather than to let it pass as done. — typescript/packages/ui/src/components/select.tsx:3
typescript2/app-beps/src/components/decisions/decision-card.tsx:176 · typescript2/app-beps/src/components/issues/issue-card.tsx:218 — the two spans are one implementation copied and then locally edited — 360 tokens are still identical, in the same order in both files, 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. — typescript2/app-beps/src/components/decisions/decision-card.tsx:176
typescript2/app-developer-docs/app/baml/packages/[version]/[[...fqn]]/page.tsx:30 · typescript2/app-developer-docs/app/cli/[version]/[[...path]]/page.tsx:28 — the two spans are one implementation copied and then locally edited — 469 tokens are still identical, in the same order in both files, 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. — typescript2/app-developer-docs/app/baml/packages/[version]/[[...fqn]]/page.tsx:30
typescript/apps/vscode-ext/src/panels/vscode-to-webview-rpc.ts:4 · typescript/packages/playground-common/src/baml_wasm_web/vscode-to-webview-rpc.ts:4 — the 2 copies are spread across 2 files, and the CITED SPAN is a run of DECLARATIONS inside a construct — the members of a type, or the entries of an object or array literal — with no statement anywhere in it. Do not read this as an extract-a-helper row: nothing here executes, so there is no call site, and a call expression cannot stand where a member declaration or a literal's entry was. What repeats is a SHAPE, and which shape decides the move. Where the copies declare the same members, the repetition is a missing common ancestor: give it a base type, an interface both extend, a generic instantiated twice, or — where the copies are a literal's entries rather than a type's members — one shared constant each site spreads or refers to, so the set is written once. Where they declare DIFFERENT members and only the form is shared — a decorator and its options, an annotation, a registration table's keys — the form is prescribed by a framework or a schema rather than copied, and the only collapse available is to generate the declarations from that schema; where you do not own the generator, this is the cost of the framework and there is nothing to extract. Check which of the two it is before acting: these copies still drift apart the first time only one of them is edited, which is why the repetition is reported, but the sentence to act on is not the same in both cases. — typescript/apps/vscode-ext/src/panels/vscode-to-webview-rpc.ts:4
typescript2/app-promptfiddle/src/playground/vfs.ts:13 · typescript2/app-website/playground/vfs.ts:12 — the 2 copies are spread across 2 files, 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. — typescript2/app-promptfiddle/src/playground/vfs.ts:13
typescript2/app-beps/src/components/ui/theme-toggle.tsx:3 · typescript2/app-feedback/src/components/ui/theme-toggle.tsx:3 — these 2 files are line-for-line copies of one another — 67 lines are identical, in the same order, in every one of them — so this is one fact about the file set, not a block to extract. An edit made to one file and not the others changes behaviour silently, which is the failure a wholesale copy guarantees. Pick one file as the single source and derive the others from it (re-export it, spread it into the local overrides each variant genuinely needs, or generate the copies at build time) — the few lines that differ between the files are exactly the part each variant should still own. Check first whether the copies are deliberately standalone deliverables (a translation file seeded from its sibling and waiting to be translated); where they are, the duplication is the design, and the honest move is to mark the seeded file as untranslated rather than to let it pass as done. — typescript2/app-beps/src/components/ui/theme-toggle.tsx:3
engine/language_client_typescript/stream.js:65 · engine/language_client_typescript/typescript_src/stream.ts:81 — the two spans are one implementation copied and then locally edited — 384 tokens are still identical, in the same order in both files, 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. — engine/language_client_typescript/stream.js:65
typescript2/app-beps/src/components/ui/card.tsx:5 · typescript2/app-feedback/src/components/ui/card.tsx:5 — the 2 copies are spread across 2 directories, so the shared home is a decision rather than an obvious spot: check first whether one of them already owns this behaviour, and otherwise put the extracted module somewhere all of the sites already reach rather than making one of them depend on another. — typescript2/app-beps/src/components/ui/card.tsx:5
engine/language_client_typescript/audio.js:2 · engine/language_client_typescript/image.js:2 · engine/language_client_typescript/pdf.js:2 · engine/language_client_typescript/video.js:2 — the 4 copies sit in sibling files in one directory, so check first whether one of them (or an existing module there) already owns this behaviour and the others should call it; otherwise extract it into one module in that directory and have each site call it. There is one copy in each of 4 separate files rather than several in one place, so check first whether these are sibling modules that each declare their own version of one shape — one per entity, per provider, per language. Where they are, no single extracted module collapses them: each module still has to be written, and what recurs is the TEMPLATE. The moves that do collapse a template are to generate these modules from the set they enumerate, or to replace the repeated construction with one factory each site calls with its own values — and where the set is the point, each module pinning one distinct thing, the repetition IS the enumeration and there is nothing to delete. — engine/language_client_typescript/audio.js:2
typescript2/app-website/convex/discord.ts:48 · typescript2/app-website/convex/loops.ts:83 — the two spans are one implementation copied and then locally edited — 388 tokens are still identical, in the same order in both files, 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. — typescript2/app-website/convex/discord.ts:48
What to do
Act on each finding's own remediation rather than one rule: the move depends on what recurs. Where the copies are executable blocks, give the shared part one home and call it from each site; where they are declarations, a listing, a specialisation already delegating to its base, or one shape repeated per entity, there is no call site and the move is a shared type, a generated set or a factory — sometimes there is nothing to extract.
React / JS · Architecture — Conformance to the detected frontend architecture layout (feature-sliced / layered src) plus cross-package deep-import rules (D-386).
Method: Conformance to the detected frontend layout (feature-sliced / layered src) plus cross-package deep-import rules, over the module graph. Deterministic.
baml_language/sdks/typescript/bridge_typescript_web/typescript_src/index.ts:8 reaches into another package with a relative path (./shared/stream.js) — import the package by name instead. — baml_language/sdks/typescript/bridge_typescript_web/typescript_src/index.ts:8
baml_language/sdks/typescript/bridge_typescript_web/typescript_src/index.ts:17 reaches into another package with a relative path (./shared/errors.js) — import the package by name instead. — baml_language/sdks/typescript/bridge_typescript_web/typescript_src/index.ts:17
baml_language/sdks/typescript/bridge_typescript_web/typescript_src/native.ts:40 reaches into another package with a relative path (./shared/errors.js) — import the package by name instead. — baml_language/sdks/typescript/bridge_typescript_web/typescript_src/native.ts:40
baml_language/sdks/typescript/bridge_typescript_web/typescript_src/platform.ts:2 reaches into another package with a relative path (./shared/errors.js) — import the package by name instead. — baml_language/sdks/typescript/bridge_typescript_web/typescript_src/platform.ts:2
baml_language/sdks/typescript/sdkgen_typescript_shared/src/invocation_facade.ts:1 reaches into another package with a relative path (./vendor/trace/index.js) — import the package by name instead. — baml_language/sdks/typescript/sdkgen_typescript_shared/src/invocation_facade.ts:1
baml_language/sdks/typescript/sdkgen_typescript_shared/src/invocation_facade.ts:2 reaches into another package with a relative path (./baml/spawn/index.js) — import the package by name instead. — baml_language/sdks/typescript/sdkgen_typescript_shared/src/invocation_facade.ts:2
tools/stdlib-matrix/extractors/ts-surface.mjs:181 imports typescript/lib/typescript.js, reaching past a declared dependency's public entry into its build output — that path is the package's toolchain layout, not its API, and a minor version bump can relocate it with no semver signal. Import from the package's documented entry point instead. — tools/stdlib-matrix/extractors/ts-surface.mjs:181
typescript/apps/fiddle-web-app/app/[project_id]/_components/ProjectView.tsx:26 imports @baml/playground-common/lib/feedback_widget, which the target package's REDACTED `exports` does not declare — use a declared entry or declare the subpath. — typescript/apps/fiddle-web-app/app/[project_id]/_components/ProjectView.tsx:26
REDACTED:15 imports typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/prompt-preview/test-panel/test-runner.ts, a module inside the test suite — test helpers carry no compatibility contract and are maintained for the suite, not as an API, so production code that depends on one is coupled to a module nobody keeps stable. Move the shared helper into a source directory both layers may depend on. — REDACTED:15
typescript/packages/playground-common/src/features/detail-panel/components/DetailPanel.tsx:26 imports typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/prompt-preview/test-panel/test-runner.ts, a module inside the test suite — test helpers carry no compatibility contract and are maintained for the suite, not as an API, so production code that depends on one is coupled to a module nobody keeps stable. Move the shared helper into a source directory both layers may depend on. — typescript/packages/playground-common/src/features/detail-panel/components/DetailPanel.tsx:26
typescript/packages/playground-common/src/features/graph/layout/node/algorithms/elk-mermaid.ts:1 imports elkjs/lib/elk.bundled.js, reaching past a declared dependency's public entry into its build output — that path is the package's toolchain layout, not its API, and a minor version bump can relocate it with no semver signal. Import from the package's documented entry point instead. — typescript/packages/playground-common/src/features/graph/layout/node/algorithms/elk-mermaid.ts:1
typescript/packages/playground-common/src/features/index.ts:3 imports typescript/packages/playground-common/src/features/detail-panel/index.ts against the feature-sliced rules. — typescript/packages/playground-common/src/features/index.ts:3
typescript/packages/playground-common/src/features/index.ts:6 imports typescript/packages/playground-common/src/features/debug-panel/index.ts against the feature-sliced rules. — typescript/packages/playground-common/src/features/index.ts:6
typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/prompt-preview/adaptive-bottom-panel.tsx:6 imports typescript/packages/playground-common/src/features/detail-panel/index.ts against the feature-sliced rules. — typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/prompt-preview/adaptive-bottom-panel.tsx:6
typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/prompt-preview/graph-view.tsx:23 imports typescript/packages/playground-common/src/features/graph/components/index.ts against the feature-sliced rules. — typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/prompt-preview/graph-view.tsx:23
typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/prompt-preview/graph-view.tsx:27 imports typescript/packages/playground-common/src/features/graph/hooks/index.ts against the feature-sliced rules. — typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/prompt-preview/graph-view.tsx:27
typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/side-bar/function-item.tsx:9 imports typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/prompt-preview/test-panel/atoms.ts, a module inside the test suite — test helpers carry no compatibility contract and are maintained for the suite, not as an API, so production code that depends on one is coupled to a module nobody keeps stable. Move the shared helper into a source directory both layers may depend on. — typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/side-bar/function-item.tsx:9
typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/side-bar/function-item.tsx:13 imports typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/prompt-preview/test-panel/testStateUtils.ts, a module inside the test suite — test helpers carry no compatibility contract and are maintained for the suite, not as an API, so production code that depends on one is coupled to a module nobody keeps stable. Move the shared helper into a source directory both layers may depend on. — typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/side-bar/function-item.tsx:13
typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/side-bar/index.tsx:36 imports typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/prompt-preview/test-panel/test-runner.ts, a module inside the test suite — test helpers carry no compatibility contract and are maintained for the suite, not as an API, so production code that depends on one is coupled to a module nobody keeps stable. Move the shared helper into a source directory both layers may depend on. — typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/side-bar/index.tsx:36
typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/side-bar/index.tsx:37 imports typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/prompt-preview/test-panel/atoms.ts, a module inside the test suite — test helpers carry no compatibility contract and are maintained for the suite, not as an API, so production code that depends on one is coupled to a module nobody keeps stable. Move the shared helper into a source directory both layers may depend on. — typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/side-bar/index.tsx:37
typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/side-bar/test-item.tsx:21 imports typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/prompt-preview/test-panel/atoms.ts, a module inside the test suite — test helpers carry no compatibility contract and are maintained for the suite, not as an API, so production code that depends on one is coupled to a module nobody keeps stable. Move the shared helper into a source directory both layers may depend on. — typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/side-bar/test-item.tsx:21
typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/side-bar/test-item.tsx:25 imports typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/prompt-preview/test-panel/test-runner.ts, a module inside the test suite — test helpers carry no compatibility contract and are maintained for the suite, not as an API, so production code that depends on one is coupled to a module nobody keeps stable. Move the shared helper into a source directory both layers may depend on. — typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/side-bar/test-item.tsx:25
typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/side-bar/test-item.tsx:26 imports typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/prompt-preview/test-panel/testStateUtils.ts, a module inside the test suite — test helpers carry no compatibility contract and are maintained for the suite, not as an API, so production code that depends on one is coupled to a module nobody keeps stable. Move the shared helper into a source directory both layers may depend on. — typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/side-bar/test-item.tsx:26
typescript2/app-promptfiddle/src/playground/baml-lsp-worker.ts:20 imports @b/pkg-playground/wasm-panic, which the target package's REDACTED `exports` does not declare — use a declared entry or declare the subpath. — typescript2/app-promptfiddle/src/playground/baml-lsp-worker.ts:20
typescript2/app-type-quiz/src/highlight.ts:9 imports highlight.js/lib/core, reaching past a declared dependency's public entry into its build output — that path is the package's toolchain layout, not its API, and a minor version bump can relocate it with no semver signal. Import from the package's documented entry point instead. — typescript2/app-type-quiz/src/highlight.ts:9
typescript2/pkg-playground/src/graph/layout.ts:1 imports elkjs/lib/elk.bundled.js, reaching past a declared dependency's public entry into its build output — that path is the package's toolchain layout, not its API, and a minor version bump can relocate it with no semver signal. Import from the package's documented entry point instead. — typescript2/pkg-playground/src/graph/layout.ts:1
What to do
Fix the listed violations: import through the target package's declared public entry rather than a deep path into its internals or a relative path into its directory (12 rows); move the shared test helper into a source directory production code may depend on (9 rows); respect the layer/slice order — import only through a slice's public index and never upward into a higher layer (5 rows).
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.
ExecutionPanel has cyclomatic complexity 105 and cognitive complexity 85; 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 sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. 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. — typescript2/pkg-playground/src/ExecutionPanel.tsx:494
BepRouteShell has cyclomatic complexity 103 and cognitive complexity 97; 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 sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. 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. — typescript2/app-beps/src/components/bep/bep-route-shell.tsx:74
onmessage has cyclomatic complexity 96 and cognitive complexity 137; 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. — typescript2/app-website/playground/baml-worker.ts:394
onmessage has cyclomatic complexity 88 and cognitive complexity 130; 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. — typescript2/app-promptfiddle/src/playground/baml-lsp-worker.ts:567
(anonymous) has cyclomatic complexity 56 and cognitive complexity 49; 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 sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. 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. — typescript2/pkg-playground/src/ExecutionPanel.tsx:1108
WebviewMedia has cyclomatic complexity 50 and cognitive complexity 48; 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 sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. 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. — typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/prompt-preview/webview-media.tsx:138
OverviewTab has cyclomatic complexity 47 and cognitive complexity 41; 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 sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. 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. — typescript2/pkg-playground/src/telemetry/TelemetryView.tsx:915
App has cyclomatic complexity 46 and cognitive complexity 66; 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. — typescript2/app-speedtest/src/App.tsx:63
RunPage has cyclomatic complexity 45 and cognitive complexity 42; 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 sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. 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. — typescript2/app-website/app/atb/runs/[id]/page.tsx:27
testKitchenSink has cyclomatic complexity 44 and cognitive complexity 42; 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 sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. 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. — engine/generators/data/mixed_complex_types/typescript/index.ts:3
(anonymous) has cyclomatic complexity 43 and cognitive complexity 61; 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. — typescript2/pkg-playground/src/run-store-client.ts:244
BepImportDialog has cyclomatic complexity 39 and cognitive complexity 37; 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 sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. 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. — typescript2/app-beps/src/components/bep/bep-import-dialog.tsx:59
fromServer has cyclomatic complexity 39 and cognitive complexity 28; 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 sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. 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. — typescript2/pkg-playground/src/ports/WebSocketRuntimePort.ts:463
walkLibFile has cyclomatic complexity 38 and cognitive complexity 81; 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. — tools/stdlib-matrix/extractors/ts-surface.mjs:337
(anonymous) has cyclomatic complexity 35 and cognitive complexity 48; 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. — typescript2/app-product-metrics/src/http.ts:94
testSimpleNested has cyclomatic complexity 34 and cognitive complexity 33; 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 sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. 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. — engine/generators/data/nested_structures/typescript/index.ts:3
ContextInspector has cyclomatic complexity 34 and cognitive complexity 32; 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 sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. 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. — typescript2/pkg-playground/src/telemetry/TelemetryView.tsx:3192
matches has cyclomatic complexity 34 and cognitive complexity 27; 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 sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. 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. — typescript2/pkg-playground/src/args-form-model.ts:232
parseWatchValue has cyclomatic complexity 33 and cognitive complexity 79; 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. — typescript/packages/playground-common/src/sdk/sdk.ts:1036
(anonymous) has cyclomatic complexity 32 and cognitive complexity 51; 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. — typescript2/app-website/components/HistoryOfLanguages/useParticleEngine.ts:89
What to do
Break down the listed branch-heavy functions; aim P95 cyclomatic ≤ 5.
Do you agree with this assessment?
R3 · Large Files6.9 / 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.
typescript2/pkg-playground/src/ExecutionPanel.tsx has 3614 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — typescript2/pkg-playground/src/ExecutionPanel.tsx:1
typescript2/pkg-playground/src/telemetry/TelemetryView.tsx has 3339 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — typescript2/pkg-playground/src/telemetry/TelemetryView.tsx:1
typescript2/app-website/components/icons.tsx has 2463 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — typescript2/app-website/components/icons.tsx:1
typescript2/pkg-grammar/src/baml.ts has 2425 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — typescript2/pkg-grammar/src/baml.ts:1
REDACTED has 1701 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — REDACTED:1
typescript2/app-website/components/landing/vs-client.tsx has 1656 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — typescript2/app-website/components/landing/vs-client.tsx:1
typescript/packages/playground-common/src/sdk/sdk.ts has 1337 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — typescript/packages/playground-common/src/sdk/sdk.ts:1
typescript2/pkg-editor/src/MonacoEditor.tsx has 1316 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — typescript2/pkg-editor/src/MonacoEditor.tsx:1
typescript2/app-website/app/baml-intro/_components/article.tsx has 1263 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — typescript2/app-website/app/baml-intro/_components/article.tsx:1
typescript2/app-website/components/landing/incremental-adoption.tsx has 1217 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — typescript2/app-website/components/landing/incremental-adoption.tsx:1
typescript2/pkg-playground/src/worker-protocol.ts has 1186 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — typescript2/pkg-playground/src/worker-protocol.ts:1
typescript2/pkg-grammar-treesitter/grammar.js has 1161 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — typescript2/pkg-grammar-treesitter/grammar.js:1
typescript2/app-website/lib/mdx/bfcl/_components/TestResultsTable.tsx has 1131 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — typescript2/app-website/lib/mdx/bfcl/_components/TestResultsTable.tsx:1
typescript2/app-website/app/learn4/_components/story.tsx has 1118 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — typescript2/app-website/app/learn4/_components/story.tsx:1
typescript2/pkg-playground/src/telemetry/evidence.ts has 1064 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — typescript2/pkg-playground/src/telemetry/evidence.ts:1
typescript/packages/playground-common/src/sdk/runtime/BamlRuntime.ts has 1050 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — typescript/packages/playground-common/src/sdk/runtime/BamlRuntime.ts:1
typescript2/app-beps/src/components/bep/bep-route-shell.tsx has 1044 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — typescript2/app-beps/src/components/bep/bep-route-shell.tsx:1
typescript/apps/vscode-ext/src/plugins/language-server-client/index.ts has 979 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — typescript/apps/vscode-ext/src/plugins/language-server-client/index.ts:1
typescript2/app-website/app/learn2/_deck/slides.tsx has 979 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — typescript2/app-website/app/learn2/_deck/slides.tsx:1
typescript2/app-website/components/landing/variant-home.tsx has 962 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — typescript2/app-website/components/landing/variant-home.tsx:1
typescript2/app-beps/src/components/comments/comment-feed-view.tsx has 941 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — typescript2/app-beps/src/components/comments/comment-feed-view.tsx:1
typescript2/app-beps/src/components/comments/comment-sidebar.tsx has 906 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — typescript2/app-beps/src/components/comments/comment-sidebar.tsx:1
typescript2/app-website/app/learn3/_deck/slides.tsx has 896 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — typescript2/app-website/app/learn3/_deck/slides.tsx:1
typescript2/app-beps/src/lib/export-utils.ts has 873 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — typescript2/app-beps/src/lib/export-utils.ts:1
typescript2/app-type-quiz/src/app.tsx has 820 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — typescript2/app-type-quiz/src/app.tsx:1
typescript/packages/playground-common/src/sdk/atoms/core.atoms.ts has 818 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — typescript/packages/playground-common/src/sdk/atoms/core.atoms.ts:1
typescript2/pkg-playground/src/graph/GraphView.tsx has 817 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — typescript2/pkg-playground/src/graph/GraphView.tsx:1
typescript2/app-website/app/what-is-baml/page.tsx has 805 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — typescript2/app-website/app/what-is-baml/page.tsx:1
typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/prompt-preview/webview-media.tsx has 800 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/prompt-preview/webview-media.tsx:1
typescript/packages/playground-common/src/features/detail-panel/components/DetailPanel.tsx has 793 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — typescript/packages/playground-common/src/features/detail-panel/components/DetailPanel.tsx:1
typescript2/app-website/app/learn2/_lib/baml-monarch.ts has 792 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — typescript2/app-website/app/learn2/_lib/baml-monarch.ts:1
typescript2/app-website/app/baml-intro/_components/TenetsAccordion.tsx has 789 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — typescript2/app-website/app/baml-intro/_components/TenetsAccordion.tsx:1
typescript2/app-beps/convex/beps.ts has 775 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — typescript2/app-beps/convex/beps.ts:1
typescript2/app-website/app/baml-intro/_components/snippets.ts has 763 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — typescript2/app-website/app/baml-intro/_components/snippets.ts:1
typescript2/app-website/app/_lib/config.tsx has 755 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — typescript2/app-website/app/_lib/config.tsx:1
typescript/packages/playground-common/src/sdk/mock-config/config.ts has 751 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — typescript/packages/playground-common/src/sdk/mock-config/config.ts:1
REDACTED has 727 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — REDACTED:1
typescript2/pkg-playground/src/ArgsForm.tsx has 714 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — typescript2/pkg-playground/src/ArgsForm.tsx:1
typescript/packages/ui/src/components/sidebar.tsx has 673 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — typescript/packages/ui/src/components/sidebar.tsx:1
typescript2/pkg-playground/src/FunctionSidebar.tsx has 671 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — typescript2/pkg-playground/src/FunctionSidebar.tsx:1
What to do
Split each oversized file along the responsibilities already in it, into smaller focused modules in the same package.
Do you agree with this assessment?
R4 · Test Coverage3.5 / 10Weak✓ 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. (×40) — typescript2/pkg-grammar/src/baml.ts:1, typescript2/app-website/components/icons.tsx:1, REDACTED:1, …
What to do
Add tests that import the unreached modules (directly or through their public entry).
React / JS · Readiness — How outdated the npm dependencies are (a maturity signal). JS/npm CVEs are scored separately in D30 (JS/npm Dependency Vulnerabilities).
Method: npm dependency staleness from manifest/registry metadata (a maturity signal; JS/npm CVEs are scored separately in D30, which answers dependency vulnerabilities for every ecosystem). Deterministic.
Do you agree with this assessment?
R6 · Tooling10.0 / 10Exemplary✓ Tool-verified
React / JS · Readiness — Whether the project wires up test, lint and typecheck — detected from each REDACTED 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: REDACTED scanned for test/lint/typecheck script wiring. Deterministic presence check.
Do you agree with this assessment?
R7 · Dead Code2.5 / 10Critical✓ 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.
73 file(s) (~2312 LoC) were excluded from dead-code analysis. This package's entry point(s) resolved, but the walk stopped one hop in: baml_language/sdks/typescript/sdkgen_typescript_shared/src/experimental_facade.ts imports './_invocation.js', which is not in the scanned tree. That is usually a generated or build-output module, so reachability cannot see past it and no dead-code claim is made about this package. Nothing is necessarily wrong here.
14 file(s) (~1875 LoC) were excluded from dead-code analysis. This package DOES declare main/module/exports — but every declared target is missing from the scanned tree, which is what a build-output entry (dist/, lib/, out/) looks like before the package is built. Point a declared target at the source entry, or build the package before scanning, so reachability can follow it. — baml_language/sdks/typescript/bridge_typescript
20 file(s) (~1744 LoC) were excluded from dead-code analysis. This package's entry point(s) resolved, but the walk stopped one hop in: baml_language/sdks/typescript/bridge_typescript_web/typescript_src/index.ts imports './shared/proto.js', which is not in the scanned tree. That is usually a generated or build-output module, so reachability cannot see past it and no dead-code claim is made about this package. Nothing is necessarily wrong here. — baml_language/sdks/typescript/bridge_typescript_web
Unreachable from the 371 application, 97 tooling and 220 test entry point(s) detected in this repo. Gate removals on `pnpm run build` — an undetected custom entry would make these reachable.
no import path from any entry point (371 application, 97 tooling, 220 test roots considered), and no other file in the scanned tree imports it — nothing in-repo names this module at all, which is the strongest form of this claim the import graph can make (×16) — REDACTED, typescript2/app-website/components/landing/vs-client.tsx, typescript2/pkg-grammar-treesitter/grammar.js, …
no import path from any entry point (371 application, 97 tooling, 220 test roots considered), but 1 in-repo import(s) from 1 other file(s) do name it (typescript2/app-website/app/learn2/_deck/Deck.tsx) — every one of those referrers is itself unreachable, so this file is dead only as a member of that cluster: if any referrer is in fact alive, this row falls with it — typescript2/app-website/app/learn2/_deck/slides.tsx
no import path from any entry point (371 application, 97 tooling, 220 test roots considered), but 1 in-repo import(s) from 1 other file(s) do name it (typescript2/app-website/app/learn3/_deck/Deck.tsx) — every one of those referrers is itself unreachable, so this file is dead only as a member of that cluster: if any referrer is in fact alive, this row falls with it — typescript2/app-website/app/learn3/_deck/slides.tsx
no import path from any entry point (371 application, 97 tooling, 220 test roots considered), but 2 in-repo import(s) from 2 other file(s) do name it (typescript/packages/playground-common/src/graph-primitives/edges/EdgeController/index.tsx, typescript/packages/playground-common/src/graph-primitives/edges/EdgeController/useEdgeDraggable.tsx) — every one of those referrers is itself unreachable, so this file is dead only as a member of that cluster: if any referrer is in fact alive, this row falls with it — typescript/packages/playground-common/src/graph-primitives/edges/EdgeController/smart-edge.ts
no import path from any entry point (371 application, 97 tooling, 220 test roots considered), but 2 in-repo import(s) from 2 other file(s) do name it (typescript2/app-developer-docs/tools/oxlint/anti-slop/rules/no-known-value-widening.ts, typescript2/app-developer-docs/tools/oxlint/anti-slop/rules/no-unsafe-dictionary-type.ts) — every one of those referrers is itself unreachable, so this file is dead only as a member of that cluster: if any referrer is in fact alive, this row falls with it — typescript2/app-developer-docs/tools/oxlint/anti-slop/shared/dictionary-types.ts
no import path from any entry point (371 application, 97 tooling, 220 test roots considered), but 1 in-repo import(s) from 1 other file(s) do name it (typescript2/app-developer-docs/tools/oxlint/anti-slop/index.ts) — every one of those referrers is itself unreachable, so this file is dead only as a member of that cluster: if any referrer is in fact alive, this row falls with it (×2) — typescript2/app-developer-docs/tools/oxlint/anti-slop/rules/no-known-value-widening.ts, typescript2/app-developer-docs/tools/oxlint/anti-slop/rules/no-widen-then-assert.ts
no import path from any entry point (371 application, 97 tooling, 220 test roots considered), but 2 in-repo import(s) from 2 other file(s) do name it (engine/language_client_typescript/typescript_src/index.ts, engine/language_client_typescript/typescript_src/stream.ts) — every one of those referrers is itself unreachable, so this file is dead only as a member of that cluster: if any referrer is in fact alive, this row falls with it — engine/language_client_typescript/typescript_src/errors.ts
no import path from any entry point (371 application, 97 tooling, 220 test roots considered), but 1 in-repo import(s) from 1 other file(s) do name it (typescript2/app-website/components/magicui/reasoning.tsx) — every one of those referrers is itself unreachable, so this file is dead only as a member of that cluster: if any referrer is in fact alive, this row falls with it — typescript2/app-website/components/magicui/response-stream.tsx
no import path from any entry point (371 application, 97 tooling, 220 test roots considered), but 2 in-repo import(s) from 2 other file(s) do name it (typescript2/app-website/components/HistoryOfLanguages/ParticleCanvas.tsx, typescript2/app-website/components/landing/story-timeline.tsx) — every one of those referrers is itself unreachable, so this file is dead only as a member of that cluster: if any referrer is in fact alive, this row falls with it — typescript2/app-website/components/ParticleImage.tsx
no import path from any entry point (371 application, 97 tooling, 220 test roots considered), but 4 in-repo import(s) from 3 other file(s) do name it (typescript2/app-website/components/HistoryOfLanguages/ParticleCanvas.tsx, typescript2/app-website/components/HistoryOfLanguages/constants.ts, typescript2/app-website/components/HistoryOfLanguages/useParticleEngine.ts) — every one of those referrers is itself unreachable, so this file is dead only as a member of that cluster: if any referrer is in fact alive, this row falls with it — typescript2/app-website/components/HistoryOfLanguages/shapes.ts
no import path from any entry point (371 application, 97 tooling, 220 test roots considered), but 1 in-repo import(s) from 1 other file(s) do name it (typescript2/app-website/components/landing/feature-animations/index.tsx) — every one of those referrers is itself unreachable, so this file is dead only as a member of that cluster: if any referrer is in fact alive, this row falls with it (×5) — typescript2/app-website/components/landing/feature-animations/parser-animation.tsx, typescript2/app-website/components/landing/feature-animations/typed-errors-animation.tsx, typescript2/app-website/components/landing/feature-animations/streaming-animation.tsx, …
no import path from any entry point (371 application, 97 tooling, 220 test roots considered), but 1 in-repo import(s) from 1 other file(s) do name it (typescript2/app-website/components/landing/playground-showcase.tsx) — every one of those referrers is itself unreachable, so this file is dead only as a member of that cluster: if any referrer is in fact alive, this row falls with it — typescript2/app-website/playground/BamlPlayground.tsx
no import path from any entry point (371 application, 97 tooling, 220 test roots considered), but 5 in-repo import(s) from 5 other file(s) do name it (typescript2/app-developer-docs/tools/oxlint/anti-slop/rules/no-object-parameters.ts, typescript2/app-developer-docs/tools/oxlint/anti-slop/rules/no-unknown-returns.ts, typescript2/app-developer-docs/tools/oxlint/anti-slop/rules/no-unknown-type-aliases.ts and 2 more) — every one of those referrers is itself unreachable, so this file is dead only as a member of that cluster: if any referrer is in fact alive, this row falls with it — typescript2/app-developer-docs/tools/oxlint/anti-slop/shared/type-alias-resolution.ts
no import path from any entry point (371 application, 97 tooling, 220 test roots considered), but 2 in-repo import(s) from 1 other file(s) do name it (typescript2/app-website/components/HistoryOfLanguages/ParticleCanvas.tsx) — every one of those referrers is itself unreachable, so this file is dead only as a member of that cluster: if any referrer is in fact alive, this row falls with it — typescript2/app-website/components/HistoryOfLanguages/useParticleEngine.ts
no import path from any entry point (371 application, 97 tooling, 220 test roots considered), but 2 in-repo import(s) from 2 other file(s) do name it (typescript2/app-website/components/landing/variant-home.tsx, typescript2/app-website/playground/BamlPlayground.tsx) — every one of those referrers is itself unreachable, so this file is dead only as a member of that cluster: if any referrer is in fact alive, this row falls with it — typescript2/app-website/playground/homepage-example.ts
no import path from any entry point (371 application, 97 tooling, 220 test roots considered), but 2 in-repo import(s) from 2 other file(s) do name it (typescript2/app-website/app/learn3/_deck/slides.tsx, typescript2/app-website/app/learn4/_components/story.tsx) — every one of those referrers is itself unreachable, so this file is dead only as a member of that cluster: if any referrer is in fact alive, this row falls with it — typescript2/app-website/app/learn3/_components/MetricsDag.tsx
What to do
Delete the dead files and unused exports — every line is maintenance cost and rebuild-estimate inflation with zero runtime value.
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.
Imported but not declared in any reachable REDACTED — installs work only by hoisting accident. — typescript/apps/playground/src/stories/api-keys-dialog.stories.tsx:1
Declared in the root REDACTED 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.
Declared in baml_language/sdks/typescript/bridge_typescript_web/REDACTED 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.
Declared in engine/language_client_typescript/REDACTED 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.
Every import is type-only — move it to devDependencies. — typescript/apps/vscode-ext/src/webview-to-vscode-rpc.ts:1
What to do
Remove unused dependencies, declare unlisted imports explicitly, and demote type-/test-only packages to devDependencies.
Do you agree with this assessment?
R9 · Circular Imports4.8 / 10Weak✓ 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.
Other · Code Health — Whether the code avoids sync-over-async (deadlock-prone blocking on tasks) and async void.
Method: Roslyn syntax scan: async methods scanned for .Wait()/.GetAwaiter().GetResult() and async-void outside event handlers. Deterministic, hard fact per invocation.
`File.WriteAllText` blocks the thread on I/O while `File.WriteAllTextAsync` exists to wait without one — inside a method that is already `async`, await the twin. (×2) — baml_language/sdk_tests/crates/csharp/streaming/Program.cs:472, baml_language/sdk_tests/crates/csharp/streaming/Program.cs:502
Blocking on a Task with `.Wait()`/`.GetAwaiter().GetResult()` can deadlock (and wastes a thread). Prefer awaiting it: make the caller `async` and `await` instead. Where a synchronous entry point must stay — a public sync API you cannot break, or a process entry point that must not return until the work finishes — the block belongs in ONE documented bridge and never inside code that is already async; and where it already is that bridge, give the wait a TIMEOUT so a hung task fails the call instead of hanging the process. (×4) — baml_language/sdks/csharp/bridge_csharp/src/Generated/V1/BamlGeneratedProgram.cs:32, baml_language/sdks/csharp/bridge_csharp/src/Generated/V1/BamlGeneratedProgram.cs:160, baml_language/sdks/csharp/bridge_csharp/src/Values/BamlPrompt.cs:37, …
What to do
Blocking `File.WriteAllText` inside an `async` method
Other · Code Health — Whether any branch is dead by construction — a switch arm whose label can never equal a case-normalised subject, or an `else if` whose predicate the arm above has already swallowed.
Method: Roslyn syntax + semantics: switch labels compared against the subject's own case normaliser, and if/else-if chains checked for a literal an earlier arm's containment test already swallows. Deterministic, provable per finding. Advisory.
Do you agree with this assessment?
X13 · Undrained process stream10.0 / 10Exemplary○ Nothing flagged
Other · Code Health — Whether a child process that has BOTH standard streams redirected drains both — reading one to the end while the other is never read deadlocks once the child fills the unread pipe.
Method: Roslyn syntax + semantics: ProcessStartInfo launches with both streams redirected, checked for a drain of each stream across the enclosing type. On a repository with no .NET source it reads JavaScript/TypeScript off the engine’s own token stream (test, vendored and minified paths not) with the same rule: a `spawn` imported from `child_process` whose stdout and stderr are both pipes (no options, no `stdio`, or `stdio` of `'pipe'`), bound to a local that never leaves its scope, where exactly one of the two streams is read, the other never, and the child’s `close`/`exit` (or the read stream’s end) is awaited; a shell redirect in the call’s arguments or a `kill` of the child suppresses it. The same rule reads Python’s `subprocess.Popen`, Dart’s `Process.start`, Ruby’s `Open3.popen3`, and Scala’s JDK process starts (`new ProcessBuilder(…).start()` with no `redirectErrorStream`/`redirectError`/`redirectOutput`/`inheritIO`, `Runtime.getRuntime.exec`) where one of `getInputStream`/`getErrorStream` is read and the other never while `waitFor()` is called or the read stream is read to its end. Deterministic, provable per finding. Advisory.
Other · Security — Whether a hand-rolled public/private IP check can be walked past — a method that unwraps IPv4-mapped IPv6 but returns the opposite verdict for the same host written as IPv4-compatible, 6to4 or NAT64.
Method: Roslyn syntax + semantics: methods that unwrap IPv4-mapped IPv6 and hand-roll IPv4 range carve-outs, checked for whether the IPv6 branch also accounts for the IPv4-compatible, 6to4 and NAT64 embeddings. Deterministic, provable per finding. Advisory.
Do you agree with this assessment?
X15 · Unvalidated length from an untrusted reader10.0 / 10Exemplary○ Nothing flagged
Other · Security — Whether a length read out of the stream being parsed is bounded before it is allocated or read — an unchecked count taken from the input lets the input choose the allocation.
Method: Roslyn syntax + semantics: integer lengths read from a BinaryReader and spent on a bulk read or an array allocation, checked for any comparison or bounding call on the value anywhere in the method. Deterministic, provable per finding. Advisory.
Other · Code Health — Whether a loop that shortens a string until it fits a length budget has a floor — one with none grinds the value down to the empty string, or past it into a negative-length `Substring`.
Method: Roslyn syntax + semantics: while/do loops whose body's only effect on a string is to drop its last character, checked for whether anything — a direct comparison on the length, a body guard, a break — bounds that length below. On a repository with no .NET source it reads JavaScript/TypeScript off the engine’s own token stream (test, vendored and minified paths not) with the same rule: a `while`/`do` loop whose body’s one assignment to a value is `x = x.slice(0, -1)` or `x = x.slice|substring|substr(0, x.length - 1)`, driven by a condition that reads `x.length` only as a term of a larger expression — never compared directly, never tested for truthiness, and with no other read of `x` — and whose body has no `break`, `return`, `throw` or `if` naming `x`. Deterministic, provable per finding. Advisory.
Do you agree with this assessment?
X17 · Uncapped recursion over a caller-supplied document10.0 / 10Exemplary○ Nothing flagged
Other · Security — Whether a walk that recurses through a JSON/XML tree handed in by its caller bounds how deep it will go — an uncapped walk lets the document's nesting choose the stack depth, and the resulting StackOverflowException cannot be caught.
Method: Roslyn syntax + semantics: methods that take a JSON/XML document node and call themselves with a child of it, reachable from an externally-callable member of the same type that accepts a document, checked for any depth parameter, descent counter or threaded arithmetic anywhere in the walk. On a repository with no .NET source it reads TypeScript off the engine’s own token stream (test, vendored, generated and minified paths and `.d.ts` not) with the same rule: a function or method with a parameter typed as a document value — `unknown`, `any`, `object`, `Record<string, unknown|any>`, a JSON alias (`JsonValue`, `JSONObject`, …) or a DOM node global the file does not rebind — that calls itself (bare, or through `this` for a method, or hands itself to a call over the value as in `value.map(walk)`) with something it took out of that value and never through an ancestor accessor such as `closest()` or `parentElement`, that is exported or reached from an exported function (a public method of the same exported class) taking such a value, and that names no depth, level, nesting, recursion, remaining or budget anywhere and threads no `+`/`-` arithmetic through a self-call. Plain JavaScript is not read: with no annotation nothing tells a parsed document from a tree the code built itself. Deterministic, provable per finding. Advisory.
Other · Code Health — Whether a type's disposal matches what it OWNS — releasing what it created, leaving alone what it was handed, and not declaring a finalizer for state that has nothing unmanaged to finalize.
Method: Roslyn syntax + semantics: every assignment to a disposable field is read to decide whether the type CREATED the value or was handed it, and the type's disposal is checked against that answer — an injected interface it disposes, a value it constructed and never releases, a finalizer on a type holding nothing unmanaged, and a disposable local whose every reference is a plain member read. A value handed to a container that disposes its contents (a parent control's `Controls` collection, a component `IContainer`) is released by that container and is not reported; generated code is out of population. On a repository with no .NET source the same ownership questions are read in JavaScript/TypeScript off the engine’s own token stream (test, vendored, generated and minified paths not): a class declaring `dispose()`, `[Symbol.dispose]()` or `[Symbol.asyncDispose]()` that disposes a field it was handed through a constructor parameter typed as a repository interface or resolved by a dependency-injection container; that assigns a field only ever from `new X(…)` of a disposable class and neither releases it anywhere in the class nor names it in its disposal member or a method that member calls, nor hands it to anything else; and a `const`/`let` local built from literals only whose every reference opens a statement operating on a non-release member of it. A class is disposable when every repository declaration of its name declares or inherits a disposal member, or when it is a documented library disposable (`vscode` EventEmitter, CancellationTokenSource and Disposable; three.js geometries, materials, textures, render targets, renderers, controls and composers). The finalizer arm has no JavaScript counterpart: a class cannot declare one. Dart is read for the owned-and-never-released arm: a Flutter `State` (or a class declaring `dispose()`/`close()`) whose library-private field is written only with direct creations of a framework controller, `FocusNode`, `StreamController` or periodic `Timer` (or a `.listen(…)` into a field declared `StreamSubscription`), which nothing in the class or its library releases (`dispose`/`close`/`cancel`) and which is never handed on except as a named argument. Ruby is read for the owned-and-never-released arm and the abandoned-local arm: a class declaring an instance `close`, `dispose`, `shutdown`, `stop`, `disconnect` or `terminate` whose instance variable is written only with a blockless core descriptor creation (`File.open`/`new`, `Tempfile`, `Dir.open`, `IO.popen`, the `socket` and `openssl` socket classes) that no method of the class closes and that is never handed on (passed, returned, stored, exposed by `attr_reader`, delegated) — a class whose superclass or mixin lies outside the repository is not judged — and a blockless creation read through and dropped (`File.open(path).read`) or held in a local that is never closed, returned, passed or stored (a `&:read` block-pass, an `autoclose: false` borrow and a `fileno` hand-over are not abandonment). PHP is read for the same two arms: a class (not a trait, and not one using a trait) declaring an instance `close`, `dispose`, `shutdown`, `stop`, `disconnect` or `terminate` whose `private` property (or a `final` class's `protected` one) is written only with a direct core `fopen`, `tmpfile`, `popen`, `proc_open`, `fsockopen`, `stream_socket_client`/`server` or `opendir` that nothing in the class closes (`fclose`, `pclose`, `closedir`, `unset`, a reset to `null`) and that is never handed on, and a handle held in a function's local, or read through as the argument of a reader, that is never closed, returned, passed, captured or stored; a `php://` stream, `curl_init`, `SplFileObject`, `PDO` and a function the repository declares under the core name are not read. Deterministic, provable per finding. Advisory.
Other · Code Health — Whether a method that temporarily changes state belonging to the whole process — the working directory, an environment variable — puts it back on EVERY path: a restore reached only when nothing throws leaks the change to the rest of the process.
Method: Roslyn syntax + semantics: method bodies that write the process working directory or an environment variable and write it back in the same body, checked for whether that restore sits in a `finally`/`catch` or only on the straight-line path. On a repository with no .NET source the same rule reads production JavaScript/TypeScript off the engine’s own token stream (test, vendored and minified paths not): `process.chdir`, `process.env.NAME =`/`["NAME"] =` and `delete process.env.NAME`, and Deno’s `Deno.chdir`/`Deno.env.set`/`Deno.env.delete`, paired per function body (a nested function or arrow is its own body, and module top-level code is none), where the last write puts back a local the body captured from the same global or deletes a variable the first write set, with at least one statement between them; a write in a `catch`/`finally` of that body silences it. Deterministic, provable per finding. Advisory.
Other · Code Health — Whether async methods accept a CancellationToken so work can be cancelled (adoption curve).
Method: Roslyn scan: every async method (excluding framework-fixed overrides/Blazor handlers) checked for CancellationToken parameter presence. Deterministic, adoption percentage. On a repository with no .NET source it reads JavaScript/TypeScript off the engine’s own token stream (test, vendored and minified paths not) with the same question: every named async function that itself makes a request an AbortSignal can cancel (global `fetch`, axios and its file-local instances, ky, ofetch) counts, and it is compliant when its parameters or body name a signal or it hands one of its own parameters to the request as options; signatures a framework fixes (JSX event handlers, route and lifecycle exports, request-first handlers, `override`, `'use server'` modules, TanStack `mutationFn`) are exempt unless they take a signal. Deterministic, adoption percentage.
Only 16/32 async methods accept a CancellationToken, so in-flight work can't be stopped early when the caller gives up — whatever ends it in your host (shutdown signal, timeout, abandoned request, user cancel). Thread a token through the call chain and honour it at each await and loop; where a method genuinely cannot be interrupted, omitting it is a deliberate choice — judge against your hosting model.
No CancellationToken parameter — this work can't be stopped early once started. (×7) — baml_language/sdk_tests/crates/csharp/basic_calls/TestInvocation.cs:16, baml_language/sdk_tests/crates/csharp/basic_calls/TestInvocation.cs:57, baml_language/sdks/csharp/bridge_csharp/src/Cffi/HostCallDispatcher.cs:11, …
Neither takes a CancellationToken nor reads the one of the function it sits in, while it calls something that takes one — this work can't be stopped early once started. Take the token, or pass on the enclosing one. (×2) — REDACTED:492, REDACTED:504
No CancellationToken parameter — the body observes an ambient token instead (a field or a context object), so the work does stop on cancellation, but a caller cannot cancel this call independently of the owner that created that token. (×7) — baml_language/sdk_tests/crates/csharp/streaming/Program.cs:409, baml_language/sdks/csharp/bridge_csharp/src/Generated/V1/BamlGeneratedProgram.cs:34, baml_language/sdks/csharp/bridge_csharp/src/Generated/V1/BamlGeneratedProgram.cs:135, …
What to do
Thread a CancellationToken through async methods so work stops promptly on cancellation.
Other · Code Health — Whether an argument guard throws the exception its own condition describes — a guard that rejects a value for being EMPTY and reports it as `ArgumentNullException` tells the caller a parameter was null when it provably was not.
Method: Roslyn syntax: `throw new ArgumentNullException(nameof(p))` statements controlled by an `if`, whose condition is read for a test that is true of a NON-null `p` — an emptiness test that dereferences it (`p.Count == 0`, `!p.Any()`) or a BCL predicate documented true of the empty value (`string.IsNullOrEmpty(p)`). Deterministic, provable per finding. Advisory.
Other · Code Health — Whether a `when` guard is free of side effects — a guard that increments a counter or assigns while deciding whether its arm matches applies that change during PATTERN MATCHING, on an arm that may not be selected, and skips it entirely when a short-circuit to its left answers first.
Method: Roslyn syntax: `when` guards on case labels and switch-expression arms, read for a mutation (`++`/`--`/assignment) sitting in a position the guard's own `&&`/`||`/`??`/`?:`/`?.` can skip. Deterministic, provable per finding. Advisory.
Other · Code Health — Whether a method that TAKES a lock or semaphore and gives it back from a flag-guarded `finally` returns the value that flag implies — reporting success while the guard hands the primitive back admits a second caller the exclusion was there to keep out, and reporting failure while the guard keeps it leaves nothing to ever give it back.
Method: Roslyn syntax: `try` statements whose `finally` releases a synchronisation primitive under a bare local-bool guard, where the method also TOOK that same primitive before the `try`, checked for a `return` of a bool literal whose value disagrees with the flag state the method's own straight-line assignments put it in. Deterministic, provable per finding. Advisory.
Other · Code Health — Whether the work a diagnostic log line costs is paid only when that line is wanted — C# evaluates a call's arguments BEFORE the call, so a trace/debug message joined or projected out of a collection is built in full on every pass, and then discarded by a sink the shipped configuration leaves switched off.
Method: Roslyn syntax: log calls at a diagnostic level (a `Log`-prefixed method naming Trace/Debug/Verbose, or a bare `Debug`/`Trace`/`Verbose` on a receiver named for a logger), whose argument list is read for a call whose cost scales with a sequence — a LINQ operator, a materialisation, `string.Join`, a serializer — with no enclosing level check or conditional-compilation region. On a repository with no .NET source it reads JavaScript/TypeScript off the engine’s own token stream (test, vendored and minified paths not) with the same rule: a `debug`/`trace`/`verbose` call on a receiver named for a logger, or a `log`-prefixed method naming the level, whose argument calls an array operator (`map`/`filter`/`reduce`/`sort`/…), `Array.from`, `Object.keys/values/entries`, `JSON.stringify`/`util.inspect` over anything but a literal, or an array `join` — outside any arrow or function passed as an argument, which the logger calls only when the level is on — with no enclosing `if`, `&&` or `?:` whose condition names a level, a level string, or the `NODE_ENV`/`__DEV__`/`DEV` build switch. Deterministic, provable per finding. Advisory.
Do you agree with this assessment?
X24 · Document value interpolated into markup unescaped5.8 / 10Adequate✓ Tool-verified
Other · Security — Whether text read out of the document being converted is escaped before it is written into generated markup — a value the document's author chose, interpolated into an attribute the surrounding literal delimits, can close that attribute and open another.
Method: Roslyn semantic model over the whole compilation: a string-typed `Value`/`InnerText`/`InnerXml`/`Text` member declared inside `DocumentFormat.OpenXml` or `System.Xml` is a taint SOURCE, propagated through assignments, returns, arguments, tuple elements and string composition to its transitive closure, then read at interpolated-string holes that sit in a markup position the surrounding literal itself delimits. Escaper/encoder calls and enclosing validator conditions cut the flow. Flow- and container-insensitive by construction. A second arm needs no provenance at all and reports a type that CONTRADICTS ITSELF — the same expression escaped at one delimited markup hole and interpolated raw at another hole in the same markup position of the same type, which the type's own escaping proves is a defect without knowing where the value came from. On a repository with no .NET source it reads JavaScript/TypeScript off the token stream with the same rule: a DOM read of raw document text (`getAttribute`, `textContent`, `innerText`, `nodeValue`) is the source, propagated through local bindings and string composition, and judged at template-literal and concatenation holes in the same two delimited markup positions; escapers and validating conditions cut it, and documentation-site, test, vendored and minified scripts are not read. Deterministic, provable per finding. Advisory.
`svg` is text this program did not author, and it is written into the text of an element through `dangerouslySetInnerHTML` with nothing encoding it for that place. Whoever controls the value controls the markup: it can close the element or attribute it sits in and open a script of its own. Encode it for HTML at this site, render it through the framework's escaping output, or sanitise it if it must stay markup. (×2) — engine/baml-runtime/src/control_flow/mermaid-sandbox/app/components/MermaidDiagram.tsx:75, typescript2/app-beps/src/components/ui/mermaid-diagram.tsx:78
``* { cursor: ${cursorStyle} !important; }`` is text this program did not author, and it is written into the text of an element through `innerHTML` with nothing encoding it for that place. Whoever controls the value controls the markup: it can close the element or attribute it sits in and open a script of its own. Encode it for HTML at this site, render it through the framework's escaping output, or sanitise it if it must stay markup. — typescript/packages/playground-common/src/graph-primitives/edges/EdgeController/useEdgeDraggable.tsx:144
`finalHtml` is text this program did not author, and it is written into the text of an element through `dangerouslySetInnerHTML` with nothing encoding it for that place. Whoever controls the value controls the markup: it can close the element or attribute it sits in and open a script of its own. Encode it for HTML at this site, render it through the framework's escaping output, or sanitise it if it must stay markup. — typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/prompt-preview/prompt-preview-curl.tsx:378
`url` is text this program did not author, and it is written into a script or style context through `innerHTML` with nothing encoding it for that place. Whoever controls the value controls the markup: it can close the element or attribute it sits in and open a script of its own. A script or style context needs its own escaping (or a JSON serialiser that escapes `<`); better, pass the value through a data attribute. — typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/prompt-preview/webview-media.tsx:615
`Object.entries(THEMES).map(([theme,prefix])=>`
${prefix} [data-chart=${id}] {
${colorConfig.map(([key,itemConfig])=>{…` is text this program did not author, and it is written into the text of an element through `dangerouslySetInnerHTML` with nothing encoding it for that place. Whoever controls the value controls the markup: it can close the element or attribute it sits in and open a script of its own. Encode it for HTML at this site, render it through the framework's escaping output, or sanitise it if it must stay markup. — REDACTED:84
`html` is text this program did not author, and it is written into the text of an element through `dangerouslySetInnerHTML` with nothing encoding it for that place. Whoever controls the value controls the markup: it can close the element or attribute it sits in and open a script of its own. Encode it for HTML at this site, render it through the framework's escaping output, or sanitise it if it must stay markup. (×2) — REDACTED:213, typescript2/app-website/app/atb/_components/code-view.tsx:107
`file` is text this program did not author, and it is written into the text of an element through `innerHTML` with nothing encoding it for that place. Whoever controls the value controls the markup: it can close the element or attribute it sits in and open a script of its own. Encode it for HTML at this site, render it through the framework's escaping output, or sanitise it if it must stay markup. — typescript2/app-website/app/baml-intro/_components/TenetsAccordion.tsx:115
`text` is text this program did not author, and it is written into the text of an element through `innerHTML` with nothing encoding it for that place. Whoever controls the value controls the markup: it can close the element or attribute it sits in and open a script of its own. Encode it for HTML at this site, render it through the framework's escaping output, or sanitise it if it must stay markup. — typescript2/app-website/app/baml-intro/_components/TenetsAccordion.tsx:145
`name` is text this program did not author, and it is written into the text of an element through `innerHTML` with nothing encoding it for that place. Whoever controls the value controls the markup: it can close the element or attribute it sits in and open a script of its own. Encode it for HTML at this site, render it through the framework's escaping output, or sanitise it if it must stay markup. — typescript2/app-website/app/baml-intro/_components/TenetsAccordion.tsx:491
`s.name` is text this program did not author, and it is written into the text of an element through `innerHTML` with nothing encoding it for that place. Whoever controls the value controls the markup: it can close the element or attribute it sits in and open a script of its own. Encode it for HTML at this site, render it through the framework's escaping output, or sanitise it if it must stay markup. — typescript2/app-website/app/baml-intro/_components/TenetsAccordion.tsx:508
`COLOR[s.cat]` is text this program did not author, and it is written into a script or style context through `innerHTML` with nothing encoding it for that place. Whoever controls the value controls the markup: it can close the element or attribute it sits in and open a script of its own. A script or style context needs its own escaping (or a JSON serialiser that escapes `<`); better, pass the value through a data attribute. — typescript2/app-website/app/baml-intro/_components/TenetsAccordion.tsx:509
`highlighted` is text this program did not author, and it is written into the text of an element through `dangerouslySetInnerHTML` with nothing encoding it for that place. Whoever controls the value controls the markup: it can close the element or attribute it sits in and open a script of its own. Encode it for HTML at this site, render it through the framework's escaping output, or sanitise it if it must stay markup. — REDACTED:103
`highlightedCode` is text this program did not author, and it is written into the text of an element through `dangerouslySetInnerHTML` with nothing encoding it for that place. Whoever controls the value controls the markup: it can close the element or attribute it sits in and open a script of its own. Encode it for HTML at this site, render it through the framework's escaping output, or sanitise it if it must stay markup. — typescript2/app-website/components/magicui/syntax-typing-animation.tsx:94
`JSON.stringify(data)` is text this program did not author, and it is written into the text of an element through `dangerouslySetInnerHTML` with nothing encoding it for that place. Whoever controls the value controls the markup: it can close the element or attribute it sits in and open a script of its own. Encode it for HTML at this site, render it through the framework's escaping output, or sanitise it if it must stay markup. — REDACTED:45
`highlightedText` is text this program did not author, and it is written into the text of an element through `dangerouslySetInnerHTML` with nothing encoding it for that place. Whoever controls the value controls the markup: it can close the element or attribute it sits in and open a script of its own. Encode it for HTML at this site, render it through the framework's escaping output, or sanitise it if it must stay markup. — REDACTED:65
`badge.className` is text this program did not author, and it is written into a quoted attribute value through markup built here with nothing encoding it for that place. Whoever controls the value controls the markup: it can close the element or attribute it sits in and open a script of its own. Encode it for HTML at this site, render it through the framework's escaping output, or sanitise it if it must stay markup. — REDACTED:391
`kind` is text this program did not author, and it is written into a quoted attribute value through markup built here with nothing encoding it for that place. Whoever controls the value controls the markup: it can close the element or attribute it sits in and open a script of its own. Encode it for HTML at this site, render it through the framework's escaping output, or sanitise it if it must stay markup. — REDACTED:410
`side` is text this program did not author, and it is written into a quoted attribute value through markup built here with nothing encoding it for that place. Whoever controls the value controls the markup: it can close the element or attribute it sits in and open a script of its own. Encode it for HTML at this site, render it through the framework's escaping output, or sanitise it if it must stay markup. — REDACTED:456
`location` is text this program did not author, and it is written into the text of an element through markup this function returns with nothing encoding it for that place. Whoever controls the value controls the markup: it can close the element or attribute it sits in and open a script of its own. Encode it for HTML at this site, render it through the framework's escaping output, or sanitise it if it must stay markup. — REDACTED:494
What to do
Each finding names the expression, the attribute it lands in and the line. Confirm the value's origin from the read this analyzer traced, then escape it at the sink or validate it against the shape the attribute accepts before interpolating.
Other · Code Health — Whether a value the caller is invited to supply is the value the type actually uses — a constructor parameter stored in a private field that nothing ever reads while the default it was given is spelled out a second time at the site that should have read it, a keyed lookup that falls back to a different setting than the one its key names while the same type falls back to the matching one for that same key, or a culture-sensitive parse given no format provider by a type that feeds its own settable culture to the same kind of parse elsewhere, or a number an entry point writes to standard output under the host's culture while the same entry point formats with the invariant culture elsewhere. Either way, every caller who supplies a value silently gets something else.
Method: Roslyn syntax: private instance fields of a non-partial type assigned in a constructor from one of its own parameters with a `??` fallback, checked for whether anything in the type body reads the field and whether that same fallback expression is spelled out again outside the constructor; and `??` fallbacks onto a member access from a lookup call carrying exactly one string literal, grouped by that key across the type and checked for a fallback member whose folded name disagrees with the key while a sibling site for the same key agrees with it. On a repository with no .NET source the first two arms read JavaScript/TypeScript off the engine’s own token stream (tests included, bundles and vendored paths not): a `#x`, `private` or `private` parameter-property instance field filled in the constructor from a parameter (or one member of one) through `??`/`||` or a parameter default, never read anywhere in the file by name, whose constructed default is spelled again in the class body; and `lookup("key") ?? s.member` grouped by key per class, or per module outside every class. The culture arm has no JavaScript counterpart: its parses take no locale. Deterministic, provable per finding. Advisory.
Other · Code Health — Whether a value handed from a callback to the body that waits on it crosses on something built to be crossed — a `Queue<T>`/`List<T>`/`Dictionary<K,V>` written inside an event handler and read back outside it is mutated by two flows at once, and the semaphore or completion source beside it orders how MANY items exist while leaving the collection's own head, tail and backing array unprotected.
Method: Roslyn syntax: method, accessor, local-function and lambda bodies that declare BOTH a non-thread-safe generic collection (`Queue`/`Stack`/`List`/`Dictionary`/`HashSet`/`Sorted*`/`LinkedList`) and a synchronisation primitive (`SemaphoreSlim`/`TaskCompletionSource`/`ManualResetEvent(Slim)`/`AutoResetEvent`/`CountdownEvent`) as locals, then read for a `+=`-registered lambda that raises that primitive while the body outside every lambda waits on it — and, in that scope, a mutating call on the collection inside the lambda paired with a mention of it outside. Any `lock` in the scope abstains it. On a repository with no .NET source the same handoff is read in Java off the engine’s own token stream (test source sets, vendored and demonstration paths not): an `ArrayList`/`LinkedList`/`ArrayDeque`/`PriorityQueue`/`Hash*`/`LinkedHash*`/`Tree*` local and a `CountDownLatch`/`Semaphore`/`CompletableFuture` local, a lambda or anonymous class that raises the primitive and mutates the collection, and a wait outside it; any `synchronized` or `lock()` abstains the body. Because each of those primitives orders what the callback wrote before raising it, only a touch that provably overlaps the callback is convicted: one after the registration and before the next wait, or one in a loop registered-before, waiting on every pass and not declaring the collection. Deterministic, provable per finding. Advisory.
Do you agree with this assessment?
X27 · Collection changed while being enumerated10.0 / 10Exemplary○ Nothing flagged
Other · Code Health — Whether a `foreach` leaves the collection it is walking alone — a body that adds to or removes from the very collection the loop is enumerating invalidates the enumerator it is holding, so the next `MoveNext` throws `InvalidOperationException` and the remaining items are never seen.
Method: Roslyn syntax + semantics: `foreach` statements whose body calls a structural mutator (`Add`/`Remove`/`Clear`/`Insert`/…) on the very expression the loop is enumerating. Two arms. ARM A — the source is a concrete fragile BCL collection, or a live `Keys`/`Values` view over one, and the mutator resolves to that same collection's own member; concurrent and immutable collections and arrays are outside the population by construction, since their enumerators survive a structural change. ARM B — the source is an argument-less accessor CALL on a receiver whose body is in source: the accessor must return a stored field VERBATIM and a sibling member must structurally change that same field, both read off the implementations rather than from the members' names. A mutation the loop provably exits immediately after (`break`/`return`/`throw`/`goto`), or one written inside a nested loop or a lambda, is counted and never reported. Deterministic, provable per finding. Advisory.
Do you agree with this assessment?
X28 · Index access outside its own emptiness guard10.0 / 10Exemplary○ Nothing flagged
Other · Code Health — Whether a condition that tests a value for emptiness indexes that same value only where the test holds — an `||` written one parenthesis too far to the left leaves an index access outside the guard beside it, so the empty case the guard exists to anticipate reaches the index and throws.
Method: Roslyn syntax only, no semantic model: the OUTERMOST `&&`/`||` of every boolean condition, read for a symbol the condition tests for emptiness (`string.IsNullOrEmpty`/`IsNullOrWhiteSpace`, a `Length`/`Count` comparison against a literal, `Any()`, a `Length`/`Count` pattern, or a comparison against `""`) and ALSO indexes. Each `symbol[...]` access is placed by a boolean-reachability walk from the access up to the outermost connective: an access is COVERED when some enclosing step has it in the right operand and the left operand, under the truth value that step forces, proves the symbol non-empty — a recursion over `&&`/`||` whose true- and false-directions are asymmetric. A finding needs BOTH an uncovered access and a covered one on the same symbol in the same condition, which is the agreeing twin that separates a misplaced parenthesis from an unrelated length test. Bare index accesses with no emptiness test in the condition are neither counted nor reported; a non-identifier receiver and a lambda nested inside the condition are outside the population. Deterministic, provable per finding. Advisory.
Do you agree with this assessment?
X29 · Per-element action decided by a fixed element10.0 / 10Exemplary○ Nothing flagged
Other · Code Health — Whether a decision taken once per element is taken ABOUT that element — a test inside a counted loop that reads a fixed subscript of the very collection its guarded statement indexes by the loop variable applies element zero's answer to all of them, so the elements that differ from it are all handled wrongly, and in the same direction.
Method: Roslyn syntax only, no semantic model: every `for` statement declaring exactly ONE loop variable, and every `if` inside its body that is not under a nested loop or a lambda. A site enters the population when the `if`’s condition never mentions the loop variable while the statement it guards indexes some collection by that variable ALONE (`c[i]`; `c[i + 1]` and `c[i, j]` are outside it). A finding additionally needs the AGREEING TWIN at the same-collection grain: the condition must read THAT SAME collection at a subscript that does not move — written into the condition, or reached through a local declared BEFORE the loop, so an alias bound inside the body is not followed. Both collection expressions must be simple identifiers. On a repository with no .NET source the same rule reads JavaScript/TypeScript off the engine’s own token stream (tests included, bundles and vendored paths not): a `for (let|var|const x = …; …; …)` with one declarator and a braced body, an alias followed only when it is declared before the loop in a block that encloses it and never assigned inside the loop. Deterministic, provable per finding. Advisory.
Other · Code Health — Whether exceptions are handled rather than silently swallowed or rethrown with lost stack traces.
Method: Roslyn syntax scan: every catch clause counted; empty catches and bare rethrows flagged. Population is all catch clauses, not estimated. Deterministic, hard fact.
An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it. (×9) — baml_language/sdk_tests/crates/csharp/dynamic_values/Program.cs:333, baml_language/sdks/csharp/bridge_csharp/src/Cffi/HostValueRegistry.cs:559, baml_language/sdks/csharp/bridge_csharp/src/Cffi/NativeCallbacks.cs:133, …
`catch (TException)` does nothing with the exception it caught — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch. Log it through whatever this codebase already uses to report problems, or let it propagate; if one specific failure genuinely cannot matter, catch exactly that exception type and say why in a comment on the catch. (×3) — baml_language/sdk_tests/crates/csharp/generics/Program.cs:166, baml_language/sdk_tests/crates/csharp/primitive_edges/Program.cs:167, baml_language/sdk_tests/crates/csharp/type_roundtrips/Program.cs:153
`catch (SocketException) when (…)` does nothing with the exception it caught — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch. Log it through whatever this codebase already uses to report problems, or let it propagate; if one specific failure genuinely cannot matter, catch exactly that exception type and say why in a comment on the catch. — baml_language/sdk_tests/crates/csharp/streaming/Program.cs:418
`catch (InvalidDataException)` does nothing with the exception it caught — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch. Log it through whatever this codebase already uses to report problems, or let it propagate; if one specific failure genuinely cannot matter, catch exactly that exception type and say why in a comment on the catch. — baml_language/sdks/csharp/bridge_csharp/tools/Baml.NuGetNormalizer/Program.cs:664
What to do
Swallowed exception (empty catch)
Do you agree with this assessment?
X30 · Support guard that admits what it rejects10.0 / 10Exemplary○ Nothing flagged
Other · Code Health — Whether a guard written as a NEGATED `||` says what its author meant — `!(a || b || x != k)` is `!a && !b && x == k` by De Morgan, so a bail-out that mixes capabilities the code needs with a fault it refuses turns inside out: it fires only where the capabilities are ABSENT, and lets every value the fault term names walk straight into the body that cannot handle it.
Method: Roslyn syntax only, no semantic model: every logical-not whose operand is a parenthesised `||` chain of two or more disjuncts, flattened (a left-nested `a || b || c` read once would see `(a || b)` as one disjunct). A site enters the population on that shape alone. A finding additionally needs the disjuncts to DISAGREE in polarity: at least one bare boolean read — an identifier or member access, never an invocation, which is a predicate rather than a capability flag — and at least one `x != <constant>`, the only form that negates into an exact-value pin (`== null` negates into a looser requirement and is outside the fault set). Consistently-polarised disjunctions, all-fault or all-capability, are counted and never reported; a negated `&&` is outside the population entirely. No same-receiver gate: it was measured to cost a real defect and remove no false positive. Deterministic, provable per finding. Advisory.
Do you agree with this assessment?
X32 · Type resolved by simple name across every loaded assembly10.0 / 10Exemplary○ Nothing flagged
Other · Code Health — Whether a plugin lookup names the type it means — searching every assembly loaded into the process for a candidate whose SIMPLE name equals a string supplied at runtime, and taking the first one found, is decided by assembly LOAD ORDER rather than by this source, so the same name can resolve to a different type on the next run.
Method: Roslyn syntax only, no semantic model: every invocation of `First`/`FirstOrDefault`/`Single`/`SingleOrDefault` whose OWN expression subtree contains both a `GetAssemblies()` call and a `GetTypes()`/`GetExportedTypes()` call — a single-element pick out of every type loaded into the process. A nested selector in the same chain sees no `GetAssemblies()` in its own subtree and is outside the population, so one lookup counts once however many links its chain has. A finding additionally needs both remaining halves: the selector must be `First`/`FirstOrDefault` (`Single`/`SingleOrDefault` reports the ambiguity rather than resolving it, and is counted and never reported), and the chain must carry an `==` comparison of `<lambda parameter>.Name` against something that is not a literal. The receiver must be a plain identifier bound by one of the chain’s own lambdas, which places `assembly.GetName().Name == "X"` outside the rule by construction. One exemption: a `.Name` test joined by `&&` to a `FullName`/`AssemblyQualifiedName` test on the same identifier is spared; joined by `||` it is not. Deterministic, provable per finding. Advisory.
Other · Code Health — Whether log calls use message templates (queryable) rather than interpolated strings.
Method: Roslyn syntax scan: every log call-site counted; interpolated-string first-argument violations flagged. Population is all log calls, not estimated. On a repository with no .NET source it reads JavaScript/TypeScript off the engine’s own token stream (test, vendored and minified paths not) with the same rule: a `trace`/`debug`/`info`/`warn`/`error`/`fatal`/`verbose`/`silly`/`http`/`log` call on a receiver named for a logger, in a package whose own or an enclosing `REDACTED` declares a logger that carries values as fields (pino, pino-http, nestjs-pino, Fastify, winston, bunyan, tslog, LogTape, roarr), whose first deciding argument is a template literal with substitutions; an object-literal fields argument is stepped over, a plain string message clears the call. Python is read the same way: a `debug`/`info`/`warning`/`error`/`exception`/`critical`/`log` call on a logger in a file that imports the standard library’s `logging` or structlog (loguru, which formats at the call, is not judged), whose message is a whole f-string with a non-constant field; a `%`-formatted, `.format()`-ed or concatenated message is not convicted, as in C#. PHP is read the same way: a PSR-3 level call (`emergency`…`debug`, `log`) on a logger (`$logger`, `$this->logger`, Laravel’s `Log::`, `logger()`, `\Drupal::logger()`) in a package whose `composer.json` requires a PSR-3 logger or a framework that hands one out (psr/log, Monolog, Laravel, Symfony, Drupal, CakePHP), or a file that imports one, whose message is a double-quoted string interpolating a variable; a single-quoted message clears the call, and `sprintf` or `.` concatenation is not convicted, as in C#. Dart is read the same way: a `trace`/`debug`/`info`/`warn`/`error`/`fatal` call on Sentry’s structured logger (`Sentry.logger`) whose message is a whole string literal interpolating a value (`$name`, `${…}`); the `Sentry.logger.fmt` template API clears the call. Dart that logs only through loggers with one message and no fields (package:logging, package:logger, talker, dart:developer) is not applicable rather than a reach gap. Ruby is read the same way: a `trace`/`debug`/`info`/`warn`/`error`/`fatal` call on the console gem’s `Console` (declared by a Gemfile, gemspec or Gemfile.lock, or required) or, where SemanticLogger, Ougai or dry-logger is declared or required, on a receiver named for a logger (`logger`, `@logger`, `Rails.logger`, `log`), whose first deciding argument is, as the whole argument, a double-quoted string interpolating a non-constant value (`#{…}`, `#@ivar`); a plain literal clears the call, keyword arguments are the fields, and a block, `%`-format or `+` concatenation is not convicted. Ruby that logs only through the standard Logger (Rails.logger) is not applicable rather than a reach gap. Deterministic.
Other · Code Health — Whether nullable reference types are enabled and not undermined by heavy `!` suppression.
Method: Roslyn compiler-options scan: NullableContextOptions per project; null-forgiving (!) suppression density per 1k syntax nodes. Deterministic, adoption plus suppression penalty.
17/18 NRT-eligible project(s) enable <Nullable>enable</Nullable> (projects targeting a pre-C#-8 framework are excluded — NRTs aren't available there). NRTs catch a whole class of null-deref bugs at compile time.
~49.6 `!` suppressions per 1k syntax nodes — 11527 suppression(s) across the 232167 syntax node(s) in code where nullable warnings are ENABLED, which is the only code a `!` can suppress anything in (a `!` under `#nullable disable` is inert and is not counted, and its file's nodes are not in the denominator). Each one tells the compiler to trust you about null, suppressing the very safety NRTs provide.
What to do
Enable <Nullable>enable</Nullable> across all projects and resolve warnings rather than suppressing with `!`.
Do you agree with this assessment?
Reference — by lens
The score is the rank-weighted fold of these lenses (worst-heaviest), each including its meta-dimensions; a lens with a Critical contributor is capped at Fair (its band reads "gated by …") and is never the strongest area however high its average.
Unscored — 5 check(s) recorded observations but carry no score
These checks ran and found something, but they do not carry a score — either by design (an advisory check reports evidence rather than grading it) or because they could not be scored here. They are excluded from the score for that reason, not because there was nothing to see.
P12 CI test-gate honesty — 4 observation(s) recorded · Reported, not scored — this card publishes what the CI gate does with the test inventory rather than grading it. The findings above are its output.
SC1 Supply-chain hygiene — 1 observation(s) recorded · Advisory — this card reports evidence and never carries a score, so there is nothing missing here.
X10 Duplicated predicate — 25 observation(s) recorded · Advisory — this card reports evidence and never carries a score.
X7 Silent fallback defaults — 34 observation(s) recorded · Advisory — this card reports evidence and never carries a score.
X9 Subsumed condition operand — 3 observation(s) recorded · Advisory — this card reports evidence and never carries a score.
Not evidenced — 1 control(s) we could not find positive evidence for
These checks grade a working control, and the repository shows no evidence of one. That is deliberately not scored as a zero: a repository cannot show an ops runbook, a database TTL or an infrastructure-side audit log, so absence of evidence here is not evidence the control is missing. It is also not a statement that the check is irrelevant to this codebase — the thing it grades applies; we just could not see it. Excluded from the score either way.
P5 DR & Backup — not evidenced — repo shows no backup/RTO/RPO controls; absence of evidence is not evidence of a working control
Not included — 41 check(s) not relevant to this codebase
These checks had nothing to measure here (no tests, no git history, the codebase is small, or the architecture style doesn't apply), so they're omitted above rather than scored low.
AC1 Text alternatives — No user-facing web UI (the repo is a library/CLI/worker/headless service) — accessibility is not applicable.
AC2 Forms & labels — No user-facing web UI (the repo is a library/CLI/worker/headless service) — accessibility is not applicable.
AC3 Page structure — No user-facing web UI (the repo is a library/CLI/worker/headless service) — accessibility is not applicable.
AC4 Keyboard semantics — No user-facing web UI (the repo is a library/CLI/worker/headless service) — accessibility is not applicable.
AC5 ARIA correctness — No user-facing web UI (the repo is a library/CLI/worker/headless service) — accessibility is not applicable.
AC6 Visual & motion safety — No user-facing web UI (the repo is a library/CLI/worker/headless service) — accessibility is not applicable.
AC7 A11y enforcement — No user-facing web UI (the repo is a library/CLI/worker/headless service) — accessibility is not applicable.
AX1 Captive dependencies — no DI registrations detected
AX2 Stateful singletons — no singleton implementations detected
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 — docker build failed (exit 1) — ------ REDACTED:1 -------------------- 1 | >>> # syntax=docker/dockerfile:1 2 | FROM node:24-slim AS build 3 | WORKDIR /workspace -------------------- ERROR: failed to solve: failed to resolve source metadata for docker.io/docker/dockerfile:1: failed to do request: Head "https://registry-1.docker.io/v2/docker/dockerfile/manifests/1": Forbidden; runtime evidence skipped This is a statement about this run, not a statement about your application: nothing here says the surface is inaccessible, only that it was never rendered.
C1 Data Protection — No personal data detected in the analyzed source — no PII-typed entity/column names (Email, FirstName, DateOfBirth, …), no ASP.NET Identity / user-account model, and no stored user credentials. GDPR data-protection controls are therefore N/A here. If this is intentional, record the no-PII posture in an ADR; if the app does process personal data, name those fields conventionally so this dimension activates.
C2 Access Controls — No access-control surface detected in the analyzed source — no web/app surface to authorize (no HTTP API or web-UI project) and no authorization code at all (no [Authorize]/policies, no imperative guard methods). Access control is therefore N/A here — this is a library/CLI, which is authorized by its CALLER, not by itself. If this codebase grows request handlers, the dimension reactivates and a default-deny posture is expected then.
C3 Audit Trail — No personal data detected in the analyzed source — no PII-typed entity/column names (Email, FirstName, DateOfBirth, …), no ASP.NET Identity / user-account model, and no stored user credentials. GDPR data-protection controls are therefore N/A here. If this is intentional, record the no-PII posture in an ADR; if the app does process personal data, name those fields conventionally so this dimension activates.
C4 Data Retention — No personal data detected in the analyzed source — no PII-typed entity/column names (Email, FirstName, DateOfBirth, …), no ASP.NET Identity / user-account model, and no stored user credentials. GDPR data-protection controls are therefore N/A here. If this is intentional, record the no-PII posture in an ADR; if the app does process personal data, name those fields conventionally so this dimension activates.
C5 Data-Subject Rights — No personal data detected in the analyzed source — no PII-typed entity/column names (Email, FirstName, DateOfBirth, …), no ASP.NET Identity / user-account model, and no stored user credentials. GDPR data-protection controls are therefore N/A here. If this is intentional, record the no-PII posture in an ADR; if the app does process personal data, name those fields conventionally so this dimension activates.
D11 Test Reliability — Test reliability not scored — polyglot repository, one half's runner produced no measurement
D12 Dependency Hygiene — Dependency hygiene not measured
D18 Solution Shape — D18 scores the shape of a C#/VB .NET solution, but this repository's production source is mostly .c, .cc, .go, .java, .kt, .py, .rb, .rs, .swift, .ts, .tsx, which the C#/VB workspace does not load — the projects that loaded are an immaterial minority, so solution shape was not assessed for this repository. Not scored — this is a gap in the analyzer's reach, not a verdict about this repository.
D21 Naming Consistency — Naming consistency is measured on C# only; Go, Java, JavaScript, Kotlin, Python, Ruby, Rust, Swift, TypeScript, html not measured.
D22 Internal API Consistency — API consistency is measured on C# only; the exposed JavaScript, Python, Ruby, Rust, Swift, TypeScript surface was not measured.
D24 Comment Value — D24 reads C# and Visual Basic comments only; comments in this repository's .go, .java, .kt, .py, .rb, .rs, .swift, .ts, .tsx source were not judged.
D25 ADR Conformance — no ADRs to check
D27 Navigability — D27 counts a call into the standard library or a dependency as unresolved for this repository's language (.rs), so too few call sites counted as resolved to assess navigability. Not scored: this is a gap in the analyzer, not a verdict about this repository.
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 — IL not measured — the analyzer's build of the target did not succeed
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 dependency cycles — architectural integrity not assessed
DM3 Integration-event coupling — no integration events detected — coupling check not applicable
DM6 Domain ↔ infrastructure boundary — this Rust crate maps no type to a persistence framework (diesel/sea-orm/sqlx), so DM6's domain↔infrastructure fusion read has no population to be taken over
ED2 Event/command shape — not scored — deciding whether a command has more than one competing handler requires resolving the call graph, and this analysis resolves a call's owner only where the receiver's type is written down in the source. Reported as guidance rather than measured
ED2 Event/command shape — not scored — deciding whether a command has more than one competing handler requires resolving the call graph, and a call made through an inferred or generic receiver has no resolvable owner in the source. Reported as guidance rather than measured
ED5 Idempotency — no mutating command handlers or message consumers detected — idempotency check not applicable
P2 Observability — This repo is a library, not a deployed service — it has no process to operate, so production observability (structured logging, tracing/metrics, health checks) is N/A. A library may log via an injected ILogger, but the absence of operational telemetry is not a defect here. If it grows a host (web API, worker), the dimension reactivates.
P7 Outbound HTTP resilience — not applicable — this isn't a service/API/worker
P9 Domain vs controller coverage — coverage data present for 14 file(s), but no domain-layer files were identified: no covered file's path contains any of the markers this check keys on (/domain/, /aggregates/, /valueobjects/, /domainmodel/, .domain/, /entities/), which are matched case-insensitively anywhere in the path. With no domain partition there is nothing to compare the web/controller layer against — if this repository keeps its business rules under a folder named none of those, that naming is what the check cannot see, not the domain logic.
S1 Web-Security Posture — No web surface detected in the analyzed source — no HTTP API or web-UI project (no controllers/minimal-API endpoints, no Razor/Blazor views) and no web middleware (HTTPS redirection, HSTS, security headers, cookies). Transport security, security headers, secure cookies, CSRF/input-validation and middleware-order controls are therefore N/A here — this is a library/CLI/worker, not a web app. Crypto hygiene was still checked and found nothing to flag. If this codebase becomes web-facing, the dimension reactivates automatically.
X6 Hand-rolled structured-format parsing — 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.
WriteOnlyPrivateField baml_language/sdks/csharp/bridge_csharp/tools/Baml.Union.LayoutProbe/Program.cs:323— private T1? _value1 — assigned 1 time(s), read never — this field is written and never read anywhere its type can be reached from, so the state it keeps answers no question: every assignment to it computes a value that nothing observes, on every instance, for the lifetime of each one. It reads as a flag the code branches on, and nothing branches on it. Delete the field and its assignments — or, if the value was MEANT to be consulted, the missing read is the defect this row is pointing at, and the branch that should have depended on it is not there.
WriteOnlyPrivateField baml_language/sdks/csharp/bridge_csharp/tools/Baml.Union.LayoutProbe/Program.cs:356— private T1? _value1 — assigned 1 time(s), read never — this field is written and never read anywhere its type can be reached from, so the state it keeps answers no question: every assignment to it computes a value that nothing observes, on every instance, for the lifetime of each one. It reads as a flag the code branches on, and nothing branches on it. Delete the field and its assignments — or, if the value was MEANT to be consulted, the missing read is the defect this row is pointing at, and the branch that should have depended on it is not there.
WriteOnlyPrivateField baml_language/sdks/csharp/bridge_csharp/tools/Baml.Union.LayoutProbe/Program.cs:406— private T1? _value1 — assigned 1 time(s), read never — this field is written and never read anywhere its type can be reached from, so the state it keeps answers no question: every assignment to it computes a value that nothing observes, on every instance, for the lifetime of each one. It reads as a flag the code branches on, and nothing branches on it. Delete the field and its assignments — or, if the value was MEANT to be consulted, the missing read is the defect this row is pointing at, and the branch that should have depended on it is not there.
WriteOnlyPrivateField baml_language/sdks/csharp/bridge_csharp/tools/Baml.Union.LayoutProbe/Program.cs:324— private T2? _value2 — assigned 1 time(s), read never — this field is written and never read anywhere its type can be reached from, so the state it keeps answers no question: every assignment to it computes a value that nothing observes, on every instance, for the lifetime of each one. It reads as a flag the code branches on, and nothing branches on it. Delete the field and its assignments — or, if the value was MEANT to be consulted, the missing read is the defect this row is pointing at, and the branch that should have depended on it is not there.
WriteOnlyPrivateField baml_language/sdks/csharp/bridge_csharp/tools/Baml.Union.LayoutProbe/Program.cs:357— private T2? _value2 — assigned 1 time(s), read never — this field is written and never read anywhere its type can be reached from, so the state it keeps answers no question: every assignment to it computes a value that nothing observes, on every instance, for the lifetime of each one. It reads as a flag the code branches on, and nothing branches on it. Delete the field and its assignments — or, if the value was MEANT to be consulted, the missing read is the defect this row is pointing at, and the branch that should have depended on it is not there.
WriteOnlyPrivateField baml_language/sdks/csharp/bridge_csharp/tools/Baml.Union.LayoutProbe/Program.cs:407— private T2? _value2 — assigned 1 time(s), read never — this field is written and never read anywhere its type can be reached from, so the state it keeps answers no question: every assignment to it computes a value that nothing observes, on every instance, for the lifetime of each one. It reads as a flag the code branches on, and nothing branches on it. Delete the field and its assignments — or, if the value was MEANT to be consulted, the missing read is the defect this row is pointing at, and the branch that should have depended on it is not there.
WriteOnlyPrivateField baml_language/sdks/csharp/bridge_csharp/tools/Baml.Union.LayoutProbe/Program.cs:325— private T3? _value3 — assigned 1 time(s), read never — this field is written and never read anywhere its type can be reached from, so the state it keeps answers no question: every assignment to it computes a value that nothing observes, on every instance, for the lifetime of each one. It reads as a flag the code branches on, and nothing branches on it. Delete the field and its assignments — or, if the value was MEANT to be consulted, the missing read is the defect this row is pointing at, and the branch that should have depended on it is not there.
WriteOnlyPrivateField baml_language/sdks/csharp/bridge_csharp/tools/Baml.Union.LayoutProbe/Program.cs:358— private T3? _value3 — assigned 1 time(s), read never — this field is written and never read anywhere its type can be reached from, so the state it keeps answers no question: every assignment to it computes a value that nothing observes, on every instance, for the lifetime of each one. It reads as a flag the code branches on, and nothing branches on it. Delete the field and its assignments — or, if the value was MEANT to be consulted, the missing read is the defect this row is pointing at, and the branch that should have depended on it is not there.
WriteOnlyPrivateField baml_language/sdks/csharp/bridge_csharp/tools/Baml.Union.LayoutProbe/Program.cs:408— private T3? _value3 — assigned 1 time(s), read never — this field is written and never read anywhere its type can be reached from, so the state it keeps answers no question: every assignment to it computes a value that nothing observes, on every instance, for the lifetime of each one. It reads as a flag the code branches on, and nothing branches on it. Delete the field and its assignments — or, if the value was MEANT to be consulted, the missing read is the defect this row is pointing at, and the branch that should have depended on it is not there.
WriteOnlyPrivateField baml_language/sdks/csharp/bridge_csharp/tools/Baml.Union.LayoutProbe/Program.cs:326— private T4? _value4 — assigned 1 time(s), read never — this field is written and never read anywhere its type can be reached from, so the state it keeps answers no question: every assignment to it computes a value that nothing observes, on every instance, for the lifetime of each one. It reads as a flag the code branches on, and nothing branches on it. Delete the field and its assignments — or, if the value was MEANT to be consulted, the missing read is the defect this row is pointing at, and the branch that should have depended on it is not there.
WriteOnlyPrivateField baml_language/sdks/csharp/bridge_csharp/tools/Baml.Union.LayoutProbe/Program.cs:359— private T4? _value4 — assigned 1 time(s), read never — this field is written and never read anywhere its type can be reached from, so the state it keeps answers no question: every assignment to it computes a value that nothing observes, on every instance, for the lifetime of each one. It reads as a flag the code branches on, and nothing branches on it. Delete the field and its assignments — or, if the value was MEANT to be consulted, the missing read is the defect this row is pointing at, and the branch that should have depended on it is not there.
WriteOnlyPrivateField baml_language/sdks/csharp/bridge_csharp/tools/Baml.Union.LayoutProbe/Program.cs:409— private T4? _value4 — assigned 1 time(s), read never — this field is written and never read anywhere its type can be reached from, so the state it keeps answers no question: every assignment to it computes a value that nothing observes, on every instance, for the lifetime of each one. It reads as a flag the code branches on, and nothing branches on it. Delete the field and its assignments — or, if the value was MEANT to be consulted, the missing read is the defect this row is pointing at, and the branch that should have depended on it is not there.
WriteOnlyPrivateField baml_language/sdks/csharp/bridge_csharp/tools/Baml.Union.LayoutProbe/Program.cs:327— private T5? _value5 — assigned 1 time(s), read never — this field is written and never read anywhere its type can be reached from, so the state it keeps answers no question: every assignment to it computes a value that nothing observes, on every instance, for the lifetime of each one. It reads as a flag the code branches on, and nothing branches on it. Delete the field and its assignments — or, if the value was MEANT to be consulted, the missing read is the defect this row is pointing at, and the branch that should have depended on it is not there.
WriteOnlyPrivateField baml_language/sdks/csharp/bridge_csharp/tools/Baml.Union.LayoutProbe/Program.cs:360— private T5? _value5 — assigned 1 time(s), read never — this field is written and never read anywhere its type can be reached from, so the state it keeps answers no question: every assignment to it computes a value that nothing observes, on every instance, for the lifetime of each one. It reads as a flag the code branches on, and nothing branches on it. Delete the field and its assignments — or, if the value was MEANT to be consulted, the missing read is the defect this row is pointing at, and the branch that should have depended on it is not there.
WriteOnlyPrivateField baml_language/sdks/csharp/bridge_csharp/tools/Baml.Union.LayoutProbe/Program.cs:410— private T5? _value5 — assigned 1 time(s), read never — this field is written and never read anywhere its type can be reached from, so the state it keeps answers no question: every assignment to it computes a value that nothing observes, on every instance, for the lifetime of each one. It reads as a flag the code branches on, and nothing branches on it. Delete the field and its assignments — or, if the value was MEANT to be consulted, the missing read is the defect this row is pointing at, and the branch that should have depended on it is not there.
WriteOnlyPrivateField baml_language/sdks/csharp/bridge_csharp/tools/Baml.Union.LayoutProbe/Program.cs:328— private T6? _value6 — assigned 1 time(s), read never — this field is written and never read anywhere its type can be reached from, so the state it keeps answers no question: every assignment to it computes a value that nothing observes, on every instance, for the lifetime of each one. It reads as a flag the code branches on, and nothing branches on it. Delete the field and its assignments — or, if the value was MEANT to be consulted, the missing read is the defect this row is pointing at, and the branch that should have depended on it is not there.
WriteOnlyPrivateField baml_language/sdks/csharp/bridge_csharp/tools/Baml.Union.LayoutProbe/Program.cs:361— private T6? _value6 — assigned 1 time(s), read never — this field is written and never read anywhere its type can be reached from, so the state it keeps answers no question: every assignment to it computes a value that nothing observes, on every instance, for the lifetime of each one. It reads as a flag the code branches on, and nothing branches on it. Delete the field and its assignments — or, if the value was MEANT to be consulted, the missing read is the defect this row is pointing at, and the branch that should have depended on it is not there.
WriteOnlyPrivateField baml_language/sdks/csharp/bridge_csharp/tools/Baml.Union.LayoutProbe/Program.cs:411— private T6? _value6 — assigned 1 time(s), read never — this field is written and never read anywhere its type can be reached from, so the state it keeps answers no question: every assignment to it computes a value that nothing observes, on every instance, for the lifetime of each one. It reads as a flag the code branches on, and nothing branches on it. Delete the field and its assignments — or, if the value was MEANT to be consulted, the missing read is the defect this row is pointing at, and the branch that should have depended on it is not there.
WriteOnlyPrivateField baml_language/sdks/csharp/bridge_csharp/tools/Baml.Union.LayoutProbe/Program.cs:329— private T7? _value7 — assigned 1 time(s), read never — this field is written and never read anywhere its type can be reached from, so the state it keeps answers no question: every assignment to it computes a value that nothing observes, on every instance, for the lifetime of each one. It reads as a flag the code branches on, and nothing branches on it. Delete the field and its assignments — or, if the value was MEANT to be consulted, the missing read is the defect this row is pointing at, and the branch that should have depended on it is not there.
WriteOnlyPrivateField baml_language/sdks/csharp/bridge_csharp/tools/Baml.Union.LayoutProbe/Program.cs:362— private T7? _value7 — assigned 1 time(s), read never — this field is written and never read anywhere its type can be reached from, so the state it keeps answers no question: every assignment to it computes a value that nothing observes, on every instance, for the lifetime of each one. It reads as a flag the code branches on, and nothing branches on it. Delete the field and its assignments — or, if the value was MEANT to be consulted, the missing read is the defect this row is pointing at, and the branch that should have depended on it is not there.
WriteOnlyPrivateField baml_language/sdks/csharp/bridge_csharp/tools/Baml.Union.LayoutProbe/Program.cs:412— private T7? _value7 — assigned 1 time(s), read never — this field is written and never read anywhere its type can be reached from, so the state it keeps answers no question: every assignment to it computes a value that nothing observes, on every instance, for the lifetime of each one. It reads as a flag the code branches on, and nothing branches on it. Delete the field and its assignments — or, if the value was MEANT to be consulted, the missing read is the defect this row is pointing at, and the branch that should have depended on it is not there.
WriteOnlyPrivateField baml_language/sdks/csharp/bridge_csharp/tools/Baml.Union.LayoutProbe/Program.cs:363— private T8? _value8 — assigned 1 time(s), read never — this field is written and never read anywhere its type can be reached from, so the state it keeps answers no question: every assignment to it computes a value that nothing observes, on every instance, for the lifetime of each one. It reads as a flag the code branches on, and nothing branches on it. Delete the field and its assignments — or, if the value was MEANT to be consulted, the missing read is the defect this row is pointing at, and the branch that should have depended on it is not there.
WriteOnlyPrivateField baml_language/sdks/csharp/bridge_csharp/tools/Baml.Union.LayoutProbe/Program.cs:413— private T8? _value8 — assigned 1 time(s), read never — this field is written and never read anywhere its type can be reached from, so the state it keeps answers no question: every assignment to it computes a value that nothing observes, on every instance, for the lifetime of each one. It reads as a flag the code branches on, and nothing branches on it. Delete the field and its assignments — or, if the value was MEANT to be consulted, the missing read is the defect this row is pointing at, and the branch that should have depended on it is not there.
WriteOnlyPrivateField baml_language/sdks/csharp/bridge_csharp/tools/Baml.Union.LayoutProbe/Program.cs:364— private T9? _value9 — assigned 1 time(s), read never — this field is written and never read anywhere its type can be reached from, so the state it keeps answers no question: every assignment to it computes a value that nothing observes, on every instance, for the lifetime of each one. It reads as a flag the code branches on, and nothing branches on it. Delete the field and its assignments — or, if the value was MEANT to be consulted, the missing read is the defect this row is pointing at, and the branch that should have depended on it is not there.
WriteOnlyPrivateField baml_language/sdks/csharp/bridge_csharp/tools/Baml.Union.LayoutProbe/Program.cs:414— private T9? _value9 — assigned 1 time(s), read never — this field is written and never read anywhere its type can be reached from, so the state it keeps answers no question: every assignment to it computes a value that nothing observes, on every instance, for the lifetime of each one. It reads as a flag the code branches on, and nothing branches on it. Delete the field and its assignments — or, if the value was MEANT to be consulted, the missing read is the defect this row is pointing at, and the branch that should have depended on it is not there.
Orphaned knowledge engine/baml-runtime/src/optimize/tui.rs:1— No living knowledge remains for this large file — its last meaningful change has decayed away, so if it breaks, no one currently understands it. It does carry its own tests, so the behaviour is pinned even though the understanding is gone: schedule a read-through, using those tests as the specification, before the next change lands here.
Orphaned knowledge engine/baml-lib/ast/src/ast/baml_vis/mermaid_debug.rs:1— No living knowledge remains for this large file — its last meaningful change has decayed away; if it breaks, no one currently understands it. Schedule a read-through / add characterisation tests before it bites.
Orphaned knowledge engine/baml-runtime/src/async_interpreter_runtime.rs:1— No living knowledge remains for this large file — its last meaningful change has decayed away; if it breaks, no one currently understands it. Schedule a read-through / add characterisation tests before it bites.
Orphaned knowledge engine/baml-compiler/src/watch.rs:1— No living knowledge remains for this large file — its last meaningful change has decayed away, so if it breaks, no one currently understands it. It does carry its own tests, so the behaviour is pinned even though the understanding is gone: schedule a read-through, using those tests as the specification, before the next change lands here.
Orphaned knowledge engine/baml-runtime/src/optimize/applier.rs:1— No living knowledge remains for this large file — its last meaningful change has decayed away, so if it breaks, no one currently understands it. It does carry its own tests, so the behaviour is pinned even though the understanding is gone: schedule a read-through, using those tests as the specification, before the next change lands here.
Orphaned knowledge engine/generators/languages/openapi/src/type.rs:1— No living knowledge remains for this large file — its last meaningful change has decayed away, so if it breaks, no one currently understands it. It does carry its own tests, so the behaviour is pinned even though the understanding is gone: schedule a read-through, using those tests as the specification, before the next change lands here.
Orphaned knowledge engine/baml-lib/ast/src/ast/baml_vis/graph.rs:1— No living knowledge remains for this large file — its last meaningful change has decayed away; if it breaks, no one currently understands it. Schedule a read-through / add characterisation tests before it bites.
Orphaned knowledge typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/prompt-preview/pdf-viewer.tsx:1— No living knowledge remains for this large file — its last meaningful change has decayed away; if it breaks, no one currently understands it. Schedule a read-through / add characterisation tests before it bites.
Orphaned knowledge engine/baml-lib/ast/src/ast/baml_vis/header_collector.rs:1— No living knowledge remains for this large file — its last meaningful change has decayed away; if it breaks, no one currently understands it. Schedule a read-through / add characterisation tests before it bites.
Orphaned knowledge engine/baml-runtime/src/optimize/pareto.rs:1— No living knowledge remains for this large file — its last meaningful change has decayed away, so if it breaks, no one currently understands it. It does carry its own tests, so the behaviour is pinned even though the understanding is gone: schedule a read-through, using those tests as the specification, before the next change lands here.
Orphaned knowledge engine/baml-runtime/src/optimize/evaluator.rs:1— No living knowledge remains for this large file — its last meaningful change has decayed away; if it breaks, no one currently understands it. Schedule a read-through / add characterisation tests before it bites.
Orphaned knowledge engine/baml-lib/jsonish/src/deserializer/semantic_streaming.rs:1— No living knowledge remains for this large file — its last meaningful change has decayed away, so if it breaks, no one currently understands it. It does carry its own tests, so the behaviour is pinned even though the understanding is gone: schedule a read-through, using those tests as the specification, before the next change lands here.
Orphaned knowledge engine/baml-lib/ast/src/parser/parse_field.rs:1— No living knowledge remains for this large file — its last meaningful change has decayed away, so if it breaks, no one currently understands it. It does carry its own tests, so the behaviour is pinned even though the understanding is gone: schedule a read-through, using those tests as the specification, before the next change lands here.
EmptyCatchBlock baml_language/sdk_tests/crates/csharp/dynamic_values/Program.cs:333— empty catch block — the error is discarded with nothing recorded, so a failure here leaves no trace anywhere. Record it through whatever this codebase already uses to report problems, or let it propagate. Where swallowing one specific failure really is correct — as it often is on a teardown/dispose path where throwing would mask the original failure — catch exactly that exception type and write down WHY in a comment on the catch. Both are needed: a comment on a catch-all still swallows every failure nobody anticipated, and a note that only restates the swallow ("ignored", "do nothing") is read as no explanation at all.
EmptyCatchBlock baml_language/sdks/csharp/bridge_csharp/src/Cffi/HostValueRegistry.cs:559— empty catch block — the error is discarded with nothing recorded, so a failure here leaves no trace anywhere. Record it through whatever this codebase already uses to report problems, or let it propagate. Where swallowing one specific failure really is correct — as it often is on a teardown/dispose path where throwing would mask the original failure — catch exactly that exception type and write down WHY in a comment on the catch. Both are needed: a comment on a catch-all still swallows every failure nobody anticipated, and a note that only restates the swallow ("ignored", "do nothing") is read as no explanation at all.
EmptyCatchBlock baml_language/sdks/csharp/bridge_csharp/src/Cffi/NativeCallbacks.cs:133— empty catch block — the error is discarded with nothing recorded, so a failure here leaves no trace anywhere. Record it through whatever this codebase already uses to report problems, or let it propagate. Where swallowing one specific failure really is correct — as it often is on a teardown/dispose path where throwing would mask the original failure — catch exactly that exception type and write down WHY in a comment on the catch. Both are needed: a comment on a catch-all still swallows every failure nobody anticipated, and a note that only restates the swallow ("ignored", "do nothing") is read as no explanation at all.
EmptyCatchBlock baml_language/sdks/csharp/bridge_csharp/src/Cffi/NativeCallbacks.cs:270— empty catch block — the error is discarded with nothing recorded, so a failure here leaves no trace anywhere. Record it through whatever this codebase already uses to report problems, or let it propagate. Where swallowing one specific failure really is correct — as it often is on a teardown/dispose path where throwing would mask the original failure — catch exactly that exception type and write down WHY in a comment on the catch. Both are needed: a comment on a catch-all still swallows every failure nobody anticipated, and a note that only restates the swallow ("ignored", "do nothing") is read as no explanation at all.
EmptyCatchBlock baml_language/sdks/csharp/bridge_csharp/src/Values/BamlStream.cs:327— empty catch block — the error is discarded with nothing recorded, so a failure here leaves no trace anywhere. Record it through whatever this codebase already uses to report problems, or let it propagate. Where swallowing one specific failure really is correct — as it often is on a teardown/dispose path where throwing would mask the original failure — catch exactly that exception type and write down WHY in a comment on the catch. Both are needed: a comment on a catch-all still swallows every failure nobody anticipated, and a note that only restates the swallow ("ignored", "do nothing") is read as no explanation at all.
EmptyCatchBlock baml_language/sdks/csharp/bridge_csharp/src/Values/BamlStream.cs:342— empty catch block — the error is discarded with nothing recorded, so a failure here leaves no trace anywhere. Record it through whatever this codebase already uses to report problems, or let it propagate. Where swallowing one specific failure really is correct — as it often is on a teardown/dispose path where throwing would mask the original failure — catch exactly that exception type and write down WHY in a comment on the catch. Both are needed: a comment on a catch-all still swallows every failure nobody anticipated, and a note that only restates the swallow ("ignored", "do nothing") is read as no explanation at all.
EmptyCatchBlock baml_language/sdks/csharp/bridge_csharp/src/Values/BamlStream.cs:545— empty catch block — the error is discarded with nothing recorded, so a failure here leaves no trace anywhere. Record it through whatever this codebase already uses to report problems, or let it propagate. Where swallowing one specific failure really is correct — as it often is on a teardown/dispose path where throwing would mask the original failure — catch exactly that exception type and write down WHY in a comment on the catch. Both are needed: a comment on a catch-all still swallows every failure nobody anticipated, and a note that only restates the swallow ("ignored", "do nothing") is read as no explanation at all.
EmptyCatchBlock baml_language/sdks/csharp/bridge_csharp/src/Values/BamlStream.cs:580— empty catch block — the error is discarded with nothing recorded, so a failure here leaves no trace anywhere. Record it through whatever this codebase already uses to report problems, or let it propagate. Where swallowing one specific failure really is correct — as it often is on a teardown/dispose path where throwing would mask the original failure — catch exactly that exception type and write down WHY in a comment on the catch. Both are needed: a comment on a catch-all still swallows every failure nobody anticipated, and a note that only restates the swallow ("ignored", "do nothing") is read as no explanation at all.
EmptyCatchBlock baml_language/sdks/csharp/bridge_csharp/tools/Baml.Union.LayoutProbe/Program.cs:116— empty catch block — the error is discarded with nothing recorded, so a failure here leaves no trace anywhere. Record it through whatever this codebase already uses to report problems, or let it propagate. Where swallowing one specific failure really is correct — as it often is on a teardown/dispose path where throwing would mask the original failure — catch exactly that exception type and write down WHY in a comment on the catch. Both are needed: a comment on a catch-all still swallows every failure nobody anticipated, and a note that only restates the swallow ("ignored", "do nothing") is read as no explanation at all.
AX8 · Test isolation· Production project references a test project · ×4
Production project references a test project: generators-go → type_test_spec — `generators-go` (production) references the test project `type_test_spec`. Production must never depend on test code — it pulls a unit-test framework and test fixtures into the shipped product and inverts the only correct direction (tests depend on production, never the reverse). Move any shared helper into a production support library, or invert the reference.
Production project references a test project: generators-python → type_test_spec — `generators-python` (production) references the test project `type_test_spec`. Production must never depend on test code — it pulls a unit-test framework and test fixtures into the shipped product and inverts the only correct direction (tests depend on production, never the reverse). Move any shared helper into a production support library, or invert the reference.
Production project references a test project: generators-rust → type_test_spec — `generators-rust` (production) references the test project `type_test_spec`. Production must never depend on test code — it pulls a unit-test framework and test fixtures into the shipped product and inverts the only correct direction (tests depend on production, never the reverse). Move any shared helper into a production support library, or invert the reference.
Production project references a test project: generators-typescript → type_test_spec — `generators-typescript` (production) references the test project `type_test_spec`. Production must never depend on test code — it pulls a unit-test framework and test fixtures into the shipped product and inverts the only correct direction (tests depend on production, never the reverse). Move any shared helper into a production support library, or invert the reference.
Namespace dependency cycle baml_language/sdks/csharp/bridge_csharp/src/Cffi/NativeApi.cs:5— The namespaces Baml ↔ Baml.Cffi ↔ Baml.Generated.V1 ↔ Baml.Proto ↔ Baml.Runtime depend on each other. The lightest dependency in the cycle is Baml.Cffi → Baml (Baml.Cffi.NativeApi → Baml.MediaPayload, 1 type pair(s)); cut that one first, e.g. by moving the shared type to a namespace both can use or inverting it behind an interface.
Assertions commented out: should handle multiple async calls with nested gathers integ-tests/typescript/tests/collector.test.ts:417— The test body contains commented-out assertion calls and no live one — it runs, verifies nothing, and still passes. Restore the assertions or delete the test; a green test that checks nothing is worse than an absent one.
Unlisted import 'jotai-devtools' typescript/apps/playground/src/stories/api-keys-dialog.stories.tsx:1— Imported but not declared in any reachable REDACTED — installs work only by hoisting accident.
FunctionTooLong: baml_compiler::thir::typecheck::typecheck_expression engine/baml-compiler/src/thir/typecheck.rs:1486— FunctionTooLong — baml_compiler::thir::typecheck::typecheck_expression runs 928 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 828 over it, 9.28× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: bep-route-shell.BepRouteShell typescript2/app-beps/src/components/bep/bep-route-shell.tsx:74— FunctionTooLong — BepRouteShell runs 833 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 733 over it, 8.33× 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: article.Article typescript2/app-website/app/baml-intro/_components/article.tsx:343— FunctionTooLong — Article runs 804 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 704 over it, 8.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: baml_compiler::thir::interpret::evaluate_block_with_control_flow engine/baml-compiler/src/thir/interpret.rs:504— FunctionTooLong — baml_compiler::thir::interpret::evaluate_block_with_control_flow runs 655 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 555 over it, 6.55× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: comment-sidebar.CommentSidebar typescript2/app-beps/src/components/comments/comment-sidebar.tsx:177— FunctionTooLong — CommentSidebar runs 639 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 539 over it, 6.39× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: baml-monarch.registerBaml typescript2/app-website/app/learn2/_lib/baml-monarch.ts:9— FunctionTooLong — registerBaml runs 597 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 497 over it, 5.97× 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: story.Story typescript2/app-website/app/learn4/_components/story.tsx:566— FunctionTooLong — Story runs 565 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 465 over it, 5.65× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: cargo_stow::generate_dependency_graph_svg baml_language/crates/tools_stow/src/main.rs:1626— FunctionTooLong — cargo_stow::generate_dependency_graph_svg runs 562 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 462 over it, 5.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.
FunctionTooLong: slides.getSlides typescript2/app-website/app/learn2/_deck/slides.tsx:367— FunctionTooLong — getSlides runs 515 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 415 over it, 5.15× 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: baml_compiler::thir::interpret::evaluate_expr_with_context engine/baml-compiler/src/thir/interpret.rs:1639— FunctionTooLong — baml_compiler::thir::interpret::evaluate_expr_with_context runs 509 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 409 over it, 5.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: baml_lsp_server::playground_server::handle_ws_in_message baml_language/crates/baml_lsp_server/src/playground_server.rs:1735— FunctionTooLong — baml_lsp_server::playground_server::handle_ws_in_message runs 452 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 352 over it, 4.52× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: bep-import-dialog.BepImportDialog typescript2/app-beps/src/components/bep/bep-import-dialog.tsx:59— FunctionTooLong — BepImportDialog runs 448 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 348 over it, 4.48× 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: slides.getSlides typescript2/app-website/app/learn3/_deck/slides.tsx:394— FunctionTooLong — getSlides runs 431 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 331 over it, 4.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.
FunctionTooLong: perspective-slider.PerspectiveSlider REDACTED:1307— FunctionTooLong — PerspectiveSlider runs 420 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 320 over it, 4.20× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: sdkgen_go::render_functions baml_language/sdks/go/sdkgen_go/src/lib.rs:1789— FunctionTooLong — sdkgen_go::render_functions runs 417 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 317 over it, 4.17× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: language-fanout.LanguageFanout typescript2/app-website/components/landing/language-fanout.tsx:45— FunctionTooLong — LanguageFanout runs 390 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 290 over it, 3.90× 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: App.App typescript2/app-speedtest/src/App.tsx:63— FunctionTooLong — App runs 388 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 288 over it, 3.88× 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: page.WhoAreWePage typescript2/app-website/app/who-are-we/page.tsx:100— FunctionTooLong — WhoAreWePage runs 382 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 282 over it, 3.82× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: baml_compiler2_hir_ty::interfaces::impl_rules::validate_impl_signatures baml_language/crates/baml_compiler2_hir_ty/src/interfaces/impl_rules.rs:1035— FunctionTooLong — baml_compiler2_hir_ty::interfaces::impl_rules::validate_impl_signatures runs 379 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 279 over it, 3.79× 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: baml_cffi_macros::export_baml_fn engine/baml_cffi_macros/src/lib.rs:6— FunctionTooLong — baml_cffi_macros::export_baml_fn runs 376 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 276 over it, 3.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: baml_compiler2_hir_ty::interfaces::impl_rules::impl_data baml_language/crates/baml_compiler2_hir_ty/src/interfaces/impl_rules.rs:208— FunctionTooLong — baml_compiler2_hir_ty::interfaces::impl_rules::impl_data runs 324 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 224 over it, 3.24× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: deployment-status.DeploymentStatus typescript2/app-website/components/magicui/deployment-status.tsx:30— FunctionTooLong — DeploymentStatus runs 324 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 224 over it, 3.24× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: vs-client.VsClient typescript2/app-website/components/landing/vs-client.tsx:1015— FunctionTooLong — VsClient runs 323 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 223 over it, 3.23× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: sdkgen_csharp::semantic::generate_program_inner baml_language/sdks/csharp/sdkgen_csharp/src/semantic.rs:379— FunctionTooLong — sdkgen_csharp::semantic::generate_program_inner 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.
FunctionTooLong: baml_compiler2_mir::optimize::verify_definite_assignment baml_language/crates/baml_compiler2_mir/src/optimize.rs:1934— FunctionTooLong — baml_compiler2_mir::optimize::verify_definite_assignment runs 313 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 213 over it, 3.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.
FileTooLong: src/infer.rs baml_language/crates/baml_compiler2_hir_ty/src/infer.rs— FileTooLong — 9682 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), about 84% of them inside a single declaration: InferenceContext (3 blocks, 2064-15780), declaring 46 free functions. The bar is 500 significant lines; this is 9182 over it, 19.36× 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/lower.rs baml_language/crates/baml_compiler2_mir/src/lower.rs— FileTooLong — 9001 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), about 88% of them inside a single declaration: LoweringContext (15 blocks, 1711-14960), declaring 52 free functions. The bar is 500 significant lines; this is 8501 over it, 18.00× 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/vm.rs baml_language/crates/bex_vm/src/vm.rs— FileTooLong — 6452 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: BexVm (4 blocks, 1779-12249). The bar is 500 significant lines; this is 5952 over it, 12.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/parser.rs baml_language/crates/baml_compiler_parser/src/parser.rs— FileTooLong — 4747 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 4247 over it, 9.49× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: src/lib.rs baml_language/crates/bex_engine/src/lib.rs— FileTooLong — 4529 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 4029 over it, 9.06× 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: src/lower_expr_body.rs baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs— FileTooLong — 3956 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), about 76% of them inside a single declaration: LoweringContext (2 blocks, 1526-6451). The bar is 500 significant lines; this is 3456 over it, 7.91× 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/lib.rs baml_language/sdks/go/sdkgen_go/src/lib.rs— FileTooLong — 3936 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), declaring 76 free functions. The bar is 500 significant lines; this is 3436 over it, 7.87× 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: ast/expressions.rs baml_language/crates/baml_fmt/src/ast/expressions.rs— FileTooLong — 3921 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 3421 over it, 7.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: src/semantic.rs baml_language/sdks/csharp/sdkgen_csharp/src/semantic.rs— FileTooLong — 3776 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), declaring 95 free functions. The bar is 500 significant lines; this is 3276 over it, 7.55× 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: src/conversion.rs baml_language/crates/bex_engine/src/conversion.rs— FileTooLong — 3151 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), declaring 69 free functions. The bar is 500 significant lines; this is 2651 over it, 6.30× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: src/io_impls.rs baml_language/crates/sys_native/src/io_impls.rs— FileTooLong — 2787 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), about 81% of them inside a single declaration: NativeSysOps (29 blocks, 37-3979), declaring 37 free functions. The bar is 500 significant lines; this is 2287 over it, 5.57× 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: runtime_wasm/mod.rs engine/baml-schema-wasm/src/runtime_wasm/mod.rs— FileTooLong — 2295 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 1795 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: ast/declarations.rs baml_language/crates/baml_fmt/src/ast/declarations.rs— FileTooLong — 2274 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 1774 over it, 4.55× 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: src/emit.rs baml_language/crates/baml_compiler2_emit/src/emit.rs— FileTooLong — 2251 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: StackifyCodegen (5 blocks, 213-3682). The bar is 500 significant lines; this is 1751 over it, 4.50× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
FileTooLong: ir/repr.rs engine/baml-lib/baml-core/src/ir/repr.rs— FileTooLong — 2138 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 1638 over it, 4.28× 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: thir/interpret.rs engine/baml-compiler/src/thir/interpret.rs— FileTooLong — 2136 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 1636 over it, 4.27× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: src/lower.rs baml_language/crates/baml_compiler2_hir_ty/src/lower.rs— FileTooLong — 2081 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), declaring 55 free functions. The bar is 500 significant lines; this is 1581 over it, 4.16× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: src/lib.rs baml_language/crates/sys_ops/src/lib.rs— FileTooLong — 2013 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 1513 over it, 4.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: thir/typecheck.rs engine/baml-compiler/src/thir/typecheck.rs— FileTooLong — 1973 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 1473 over it, 3.95× 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: src/diagnostics.rs baml_language/crates/baml_compiler2_hir_ty/src/diagnostics.rs— FileTooLong — 1921 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), about 80% of them inside a single declaration: TirTypeError (2 blocks, 244-2749). The bar is 500 significant lines; this is 1421 over it, 3.84× 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: package_baml/csv.rs baml_language/crates/bex_vm/src/package_baml/csv.rs— FileTooLong — 1883 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 1383 over it, 3.77× 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: src/playground_server.rs baml_language/crates/baml_lsp_server/src/playground_server.rs— FileTooLong — 1832 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), declaring 65 free functions. The bar is 500 significant lines; this is 1332 over it, 3.66× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: src/normalize.rs baml_language/crates/baml_type/src/normalize.rs— FileTooLong — 1786 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), about 76% of them inside a single declaration: NormalTy (10 blocks, 682-3225). The bar is 500 significant lines; this is 1286 over it, 3.57× 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/codegen_io.rs baml_language/crates/baml_builtins2_codegen/src/codegen_io.rs— FileTooLong — 1785 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), declaring 63 free functions. The bar is 500 significant lines; this is 1285 over it, 3.57× 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: src/interfaces.rs baml_language/crates/baml_compiler2_hir_ty/src/interfaces.rs— FileTooLong — 1784 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), declaring 64 free functions. The bar is 500 significant lines; this is 1284 over it, 3.57× 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.
Hotspot: baml_language/crates/bex_vm/src/vm.rs baml_language/crates/bex_vm/src/vm.rs:9465— baml_language/crates/bex_vm/src/vm.rs changed 88 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 331 in BexVm::run_compact at line 9465. 12 of those changes were fix/bug commits, and the other 76 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-29..2026-10-27, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-29 02:53:01 +00:00' --until='2026-10-27 02:53:01 +00:00' --full-history --no-merges -- baml_language/crates/bex_vm/src/vm.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: baml_language/crates/baml_compiler2_hir_ty/src/infer.rs baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:12601— baml_language/crates/baml_compiler2_hir_ty/src/infer.rs changed 78 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 201 in InferenceContext::finish at line 12601. 22 of those changes were fix/bug commits, and the other 56 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-29..2026-10-27, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-29 02:53:01 +00:00' --until='2026-10-27 02:53:01 +00:00' --full-history --no-merges -- baml_language/crates/baml_compiler2_hir_ty/src/infer.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: baml_language/crates/baml_compiler2_hir_ty/src/diagnostics.rs baml_language/crates/baml_compiler2_hir_ty/src/diagnostics.rs:1226— baml_language/crates/baml_compiler2_hir_ty/src/diagnostics.rs changed 45 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 201 in TirTypeError::render at line 1226. 11 of those changes were fix/bug commits, and the other 34 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-29..2026-10-27, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-29 02:53:01 +00:00' --until='2026-10-27 02:53:01 +00:00' --full-history --no-merges -- baml_language/crates/baml_compiler2_hir_ty/src/diagnostics.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: baml_language/crates/baml_db/src/check.rs baml_language/crates/baml_db/src/check.rs:2120— baml_language/crates/baml_db/src/check.rs changed 46 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 125 in baml_db::check::tir_type_error_to_diagnostic_id at line 2120. 7 of those changes were fix/bug commits, and the other 39 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-29..2026-10-27, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-29 02:53:01 +00:00' --until='2026-10-27 02:53:01 +00:00' --full-history --no-merges -- baml_language/crates/baml_db/src/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: baml_language/crates/bex_engine/src/lib.rs baml_language/crates/bex_engine/src/lib.rs:5882— baml_language/crates/bex_engine/src/lib.rs changed 71 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 79 in BexEngine::run_thread_event_loop_inner at line 5882. 9 of those changes were fix/bug commits, and the other 62 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-29..2026-10-27, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-29 02:53:01 +00:00' --until='2026-10-27 02:53:01 +00:00' --full-history --no-merges -- baml_language/crates/bex_engine/src/lib.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: baml_language/crates/baml_compiler2_mir/src/lower.rs baml_language/crates/baml_compiler2_mir/src/lower.rs:8243— baml_language/crates/baml_compiler2_mir/src/lower.rs changed 71 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 70 in LoweringContext::lower_call_with_callee at line 8243. 15 of those changes were fix/bug commits, and the other 56 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-29..2026-10-27, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-29 02:53:01 +00:00' --until='2026-10-27 02:53:01 +00:00' --full-history --no-merges -- baml_language/crates/baml_compiler2_mir/src/lower.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: baml_language/crates/baml_compiler_diagnostics/src/diagnostic.rs baml_language/crates/baml_compiler_diagnostics/src/diagnostic.rs:468— baml_language/crates/baml_compiler_diagnostics/src/diagnostic.rs changed 29 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 149 in DiagnosticId::code at line 468. 4 of those changes were fix/bug commits, and the other 25 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-29..2026-10-27, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-29 02:53:01 +00:00' --until='2026-10-27 02:53:01 +00:00' --full-history --no-merges -- baml_language/crates/baml_compiler_diagnostics/src/diagnostic.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: typescript2/pkg-playground/src/ExecutionPanel.tsx typescript2/pkg-playground/src/ExecutionPanel.tsx:494— typescript2/pkg-playground/src/ExecutionPanel.tsx changed 9 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 461 in ExecutionPanel.ExecutionPanel at line 494. 3 of those changes were fix/bug commits, and the other 6 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-29..2026-10-27, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-29 02:53:01 +00:00' --until='2026-10-27 02:53:01 +00:00' --full-history --no-merges -- typescript2/pkg-playground/src/ExecutionPanel.tsx`: 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: baml_language/crates/bex_vm_types/src/bytecode.rs baml_language/crates/bex_vm_types/src/bytecode.rs:1499— baml_language/crates/bex_vm_types/src/bytecode.rs changed 23 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 140 in OpCode::try_from at line 1499. 4 of those changes were fix/bug commits, and the other 19 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-29..2026-10-27, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-29 02:53:01 +00:00' --until='2026-10-27 02:53:01 +00:00' --full-history --no-merges -- baml_language/crates/bex_vm_types/src/bytecode.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: baml_language/crates/bex_vm/src/debug.rs baml_language/crates/bex_vm/src/debug.rs:756— baml_language/crates/bex_vm/src/debug.rs changed 19 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 109 in bex_vm::debug::display_instruction_textual at line 756. 4 of those changes were fix/bug commits, and the other 15 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-29..2026-10-27, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-29 02:53:01 +00:00' --until='2026-10-27 02:53:01 +00:00' --full-history --no-merges -- baml_language/crates/bex_vm/src/debug.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: baml_language/crates/bex_engine/src/conversion.rs baml_language/crates/bex_engine/src/conversion.rs:1413— baml_language/crates/bex_engine/src/conversion.rs changed 33 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 60 in BexEngine::materialize_external_node at line 1413. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-29..2026-10-27, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-29 02:53:01 +00:00' --until='2026-10-27 02:53:01 +00:00' --full-history --no-merges -- baml_language/crates/bex_engine/src/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: baml_language/crates/baml_compiler2_mir/src/optimize.rs baml_language/crates/baml_compiler2_mir/src/optimize.rs:1934— baml_language/crates/baml_compiler2_mir/src/optimize.rs changed 20 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 84 in baml_compiler2_mir::optimize::verify_definite_assignment at line 1934. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-29..2026-10-27, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-29 02:53:01 +00:00' --until='2026-10-27 02:53:01 +00:00' --full-history --no-merges -- baml_language/crates/baml_compiler2_mir/src/optimize.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: baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:1958— baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs changed 42 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 39 in LoweringContext::lower_expr_inner at line 1958. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-29..2026-10-27, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-29 02:53:01 +00:00' --until='2026-10-27 02:53:01 +00:00' --full-history --no-merges -- baml_language/crates/baml_compiler2_ast/src/lower_expr_body.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: baml_language/crates/baml_compiler2_ast/src/lower_cst.rs baml_language/crates/baml_compiler2_ast/src/lower_cst.rs:103— baml_language/crates/baml_compiler2_ast/src/lower_cst.rs changed 38 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 38 in baml_compiler2_ast::lower_cst::lower_file_with_path_and_test_owner_impl at line 103. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-29..2026-10-27, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-29 02:53:01 +00:00' --until='2026-10-27 02:53:01 +00:00' --full-history --no-merges -- baml_language/crates/baml_compiler2_ast/src/lower_cst.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: baml_language/crates/baml_compiler2_ast/src/ast.rs baml_language/crates/baml_compiler2_ast/src/ast.rs:265— baml_language/crates/baml_compiler2_ast/src/ast.rs changed 36 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 40 in TypeExprKind::fmt at line 265. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-29..2026-10-27, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-29 02:53:01 +00:00' --until='2026-10-27 02:53:01 +00:00' --full-history --no-merges -- baml_language/crates/baml_compiler2_ast/src/ast.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: baml_language/crates/baml_compiler_parser/src/parser.rs baml_language/crates/baml_compiler_parser/src/parser.rs:6603— baml_language/crates/baml_compiler_parser/src/parser.rs changed 35 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 40 in Parser::parse_expr_bp at line 6603. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-29..2026-10-27, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-29 02:53:01 +00:00' --until='2026-10-27 02:53:01 +00:00' --full-history --no-merges -- baml_language/crates/baml_compiler_parser/src/parser.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: baml_language/crates/baml_compiler2_emit/src/emit.rs baml_language/crates/baml_compiler2_emit/src/emit.rs:2306— baml_language/crates/baml_compiler2_emit/src/emit.rs changed 42 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 29 in StackifyCodegen::emit_terminator at line 2306. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-29..2026-10-27, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-29 02:53:01 +00:00' --until='2026-10-27 02:53:01 +00:00' --full-history --no-merges -- baml_language/crates/baml_compiler2_emit/src/emit.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: baml_language/crates/baml_compiler2_ast/src/lowering_diagnostic.rs baml_language/crates/baml_compiler2_ast/src/lowering_diagnostic.rs:325— baml_language/crates/baml_compiler2_ast/src/lowering_diagnostic.rs changed 21 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 57 in LoweringDiagnostic::to_diagnostic at line 325. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-29..2026-10-27, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-29 02:53:01 +00:00' --until='2026-10-27 02:53:01 +00:00' --full-history --no-merges -- baml_language/crates/baml_compiler2_ast/src/lowering_diagnostic.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: baml_language/crates/bex_project/src/runtime_compile.rs baml_language/crates/bex_project/src/runtime_compile.rs:1282— baml_language/crates/bex_project/src/runtime_compile.rs changed 29 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 40 in bex_project::runtime_compile::lower_session_submission at line 1282. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-29..2026-10-27, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-29 02:53:01 +00:00' --until='2026-10-27 02:53:01 +00:00' --full-history --no-merges -- baml_language/crates/bex_project/src/runtime_compile.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: baml_language/crates/baml_compiler2_hir_ty/src/lower.rs baml_language/crates/baml_compiler2_hir_ty/src/lower.rs:798— baml_language/crates/baml_compiler2_hir_ty/src/lower.rs changed 32 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 35 in LowerCtx::lower_path at line 798. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-29..2026-10-27, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-29 02:53:01 +00:00' --until='2026-10-27 02:53:01 +00:00' --full-history --no-merges -- baml_language/crates/baml_compiler2_hir_ty/src/lower.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: baml_language/crates/baml_compiler2_emit/src/stack_carry.rs baml_language/crates/baml_compiler2_emit/src/stack_carry.rs:575— baml_language/crates/baml_compiler2_emit/src/stack_carry.rs changed 24 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 46 in baml_compiler2_emit::stack_carry::simulate_terminator_stack at line 575. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-29..2026-10-27, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-29 02:53:01 +00:00' --until='2026-10-27 02:53:01 +00:00' --full-history --no-merges -- baml_language/crates/baml_compiler2_emit/src/stack_carry.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: baml_language/crates/baml_compiler2_hir_ty/src/interfaces/impl_rules.rs baml_language/crates/baml_compiler2_hir_ty/src/interfaces/impl_rules.rs:1035— baml_language/crates/baml_compiler2_hir_ty/src/interfaces/impl_rules.rs changed 19 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 57 in baml_compiler2_hir_ty::interfaces::impl_rules::validate_impl_signatures at line 1035. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-29..2026-10-27, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-29 02:53:01 +00:00' --until='2026-10-27 02:53:01 +00:00' --full-history --no-merges -- baml_language/crates/baml_compiler2_hir_ty/src/interfaces/impl_rules.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: baml_language/crates/baml_compiler2_hir_ty/src/package_interface.rs baml_language/crates/baml_compiler2_hir_ty/src/package_interface.rs:1021— baml_language/crates/baml_compiler2_hir_ty/src/package_interface.rs changed 22 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 49 in baml_compiler2_hir_ty::package_interface::validate_row_identities at line 1021. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-29..2026-10-27, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-29 02:53:01 +00:00' --until='2026-10-27 02:53:01 +00:00' --full-history --no-merges -- baml_language/crates/baml_compiler2_hir_ty/src/package_interface.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: baml_language/crates/bex_heap/src/gc.rs baml_language/crates/bex_heap/src/gc.rs:1007— baml_language/crates/bex_heap/src/gc.rs changed 18 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 55 in BexHeap::fixup_object_references at line 1007. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-29..2026-10-27, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-29 02:53:01 +00:00' --until='2026-10-27 02:53:01 +00:00' --full-history --no-merges -- baml_language/crates/bex_heap/src/gc.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: baml_language/crates/bex_vm_types/src/types.rs baml_language/crates/bex_vm_types/src/types.rs:204— baml_language/crates/bex_vm_types/src/types.rs changed 15 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 64 in Program::validate at line 204. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-29..2026-10-27, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-29 02:53:01 +00:00' --until='2026-10-27 02:53:01 +00:00' --full-history --no-merges -- baml_language/crates/bex_vm_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.
MethodTooLong: BexVm.run_compact baml_language/crates/bex_vm/src/vm.rs:9465— MethodTooLong — run_compact runs 1720 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 1620 over it, 17.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: TirTypeError.render baml_language/crates/baml_compiler2_hir_ty/src/diagnostics.rs:1226— MethodTooLong — render runs 1202 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 1102 over it, 12.02× 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: InferenceContext.finish baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:12601— MethodTooLong — finish runs 1061 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 961 over it, 10.61× 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: ConversionBuffer.span baml_language/crates/btel_recorder/src/lib.rs:211— MethodTooLong — span runs 780 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 680 over it, 7.80× 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: Vm.exec engine/baml-vm/src/vm.rs:623— MethodTooLong — exec runs 614 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 514 over it, 6.14× 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: Hir2Diagnostic.to_diagnostic baml_language/crates/baml_compiler2_hir/src/diagnostic.rs:304— MethodTooLong — to_diagnostic runs 595 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 495 over it, 5.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.
MethodTooLong: ReplArgs.run engine/baml-runtime/src/cli/repl.rs:848— MethodTooLong — run runs 555 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 455 over it, 5.55× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: SpanRecord.completion baml_language/crates/btel_records/src/lib.rs:817— MethodTooLong — completion runs 483 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 383 over it, 4.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: BexEngine.materialize_external_node baml_language/crates/bex_engine/src/conversion.rs:1413— MethodTooLong — materialize_external_node runs 467 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 367 over it, 4.67× 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: LoweringContext.lower_call_with_callee baml_language/crates/baml_compiler2_mir/src/lower.rs:8243— MethodTooLong — lower_call_with_callee runs 435 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 335 over it, 4.35× 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: BamlAsyncVmRuntime.call_function engine/baml-runtime/src/async_vm_runtime.rs:160— MethodTooLong — call_function runs 370 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 270 over it, 3.70× 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: InferenceContext.infer_expr baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:2857— MethodTooLong — infer_expr runs 356 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 256 over it, 3.56× 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: ArgCoercer.coerce_arg engine/baml-lib/baml-core/src/ir/ir_helpers/to_baml_arg.rs:135— MethodTooLong — coerce_arg runs 314 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 214 over it, 3.14× 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: Bytecode.lower baml_language/crates/bex_vm_types/src/bytecode.rs:2534— MethodTooLong — lower runs 313 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 213 over it, 3.13× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: OptimizeArgs.run engine/baml-runtime/src/cli/optimize.rs:167— MethodTooLong — run runs 308 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 208 over it, 3.08× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: GenerateArgs.run_generate baml_language/crates/baml_cli/src/generate.rs:297— MethodTooLong — run_generate runs 277 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 177 over it, 2.77× 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: TelemetryState.complete_invocation_at baml_language/crates/bex_vm/src/telemetry.rs:971— MethodTooLong — complete_invocation_at runs 274 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 174 over it, 2.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.
MethodTooLong: StackifyCodegen.emit_terminator baml_language/crates/baml_compiler2_emit/src/emit.rs:2306— MethodTooLong — emit_terminator runs 272 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 172 over it, 2.72× 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: LoweringContext.try_lower_as_switch baml_language/crates/baml_compiler2_mir/src/lower.rs:12653— MethodTooLong — try_lower_as_switch runs 262 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 162 over it, 2.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: BexVm.execute_call_from_locals_offset baml_language/crates/bex_vm/src/vm.rs:7515— MethodTooLong — execute_call_from_locals_offset runs 259 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 159 over it, 2.59× 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: LoweringContext.lower_stmt baml_language/crates/baml_compiler2_mir/src/lower.rs:11823— MethodTooLong — lower_stmt runs 258 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 158 over it, 2.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: Program.validate baml_language/crates/bex_vm_types/src/types.rs:204— MethodTooLong — validate runs 257 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 157 over it, 2.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: InferenceContext.resolve_value_path baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:7410— MethodTooLong — resolve_value_path runs 252 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 152 over it, 2.52× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: BamlAsyncInterpreterRuntime.call_function engine/baml-runtime/src/async_interpreter_runtime.rs:160— MethodTooLong — call_function runs 242 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 142 over it, 2.42× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: Class.coerce engine/baml-lib/jsonish/src/deserializer/coercer/ir_ref/coerce_class.rs:136— MethodTooLong — coerce runs 240 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 140 over it, 2.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.
Duplicated block (8 lines × 2) baml_language/crates/baml_builtins2_codegen/src/codegen_io.rs:2465— baml_language/crates/baml_builtins2_codegen/src/codegen_io.rs:2465-2472 | baml_language/crates/baml_builtins2_codegen/src/codegen_io.rs:2605-2612 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler2_ast/src/ast.rs:365— baml_language/crates/baml_compiler2_ast/src/ast.rs:365-372 | baml_language/crates/baml_compiler2_hir/src/type_ref.rs:272-279 — 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) baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:1297— baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:1297-1304 | baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:1404-1411 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler2_emit/src/emit.rs:922— baml_language/crates/baml_compiler2_emit/src/emit.rs:922-929 | baml_language/crates/baml_compiler2_emit/src/items.rs:1015-1022 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (8 lines × 2) baml_language/crates/baml_compiler2_emit/src/emit.rs:1348— baml_language/crates/baml_compiler2_emit/src/emit.rs:1348-1355 | baml_language/crates/baml_compiler2_emit/src/emit.rs:1868-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 (8 lines × 2) baml_language/crates/baml_compiler2_emit/src/emit.rs:1811— baml_language/crates/baml_compiler2_emit/src/emit.rs:1811-1818 | baml_language/crates/baml_compiler2_emit/src/emit.rs:1845-1852 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler2_emit/src/items.rs:297— baml_language/crates/baml_compiler2_emit/src/items.rs:297-304 | baml_language/crates/baml_compiler2_hir_ty/src/method_resolution.rs:1041-1048 — 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) baml_language/crates/baml_compiler2_hir/src/contributions.rs:99— baml_language/crates/baml_compiler2_hir/src/contributions.rs:99-106 | baml_language/crates/baml_ide/src/search.rs:487-494 — 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) baml_language/crates/baml_compiler2_hir/src/item_tree/builder.rs:59— baml_language/crates/baml_compiler2_hir/src/item_tree/builder.rs:59-66 | baml_language/crates/baml_compiler2_hir/src/item_tree/builder.rs:281-288 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (8 lines × 2) baml_language/crates/baml_compiler2_hir/src/signature.rs:175— baml_language/crates/baml_compiler2_hir/src/signature.rs:175-182 | baml_language/crates/baml_compiler2_hir/src/signature.rs:353-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.
Duplicated block (8 lines × 2) baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs:413— baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs:413-420 | baml_language/crates/baml_type/src/unify.rs:756-763 — before extracting anything, compare `baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs` and `baml_language/crates/baml_type/src/unify.rs` as WHOLE FILES: this scan already matched 21 separate duplicated blocks between them, totalling at least 418 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (8 lines × 2) baml_language/crates/baml_compiler2_hir_ty/src/infer/obligations.rs:786— baml_language/crates/baml_compiler2_hir_ty/src/infer/obligations.rs:786-793 | baml_language/crates/baml_compiler2_hir_ty/src/infer/obligations.rs:930-937 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (8 lines × 2) baml_language/crates/baml_compiler2_hir_ty/src/package_interface.rs:1594— baml_language/crates/baml_compiler2_hir_ty/src/package_interface.rs:1594-1601 | baml_language/crates/baml_ide/src/symbol_pool.rs:715-722 — 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) baml_language/crates/baml_compiler2_mir/src/lower.rs:2287— baml_language/crates/baml_compiler2_mir/src/lower.rs:2287-2294 | baml_language/crates/baml_compiler2_mir/src/lower.rs:12069-12079 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler2_mir/src/lower.rs:13344— baml_language/crates/baml_compiler2_mir/src/lower.rs:13344-13351 | baml_language/crates/baml_compiler2_mir/src/lower.rs:13405-13412 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler2_visualization/src/control_flow/mod.rs:445— baml_language/crates/baml_compiler2_visualization/src/control_flow/mod.rs:445-452 | engine/baml-runtime/src/control_flow/flatten/mod.rs:49-56 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (8 lines × 2) baml_language/crates/baml_compiler_parser/src/parser.rs:6436— baml_language/crates/baml_compiler_parser/src/parser.rs:6436-6444 | baml_language/crates/baml_compiler_parser/src/parser.rs:7008-7015 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_fmt/src/ast/declarations.rs:1386— baml_language/crates/baml_fmt/src/ast/declarations.rs:1386-1393 | baml_language/crates/baml_fmt/src/ast/declarations.rs:2670-2677 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (8 lines × 2) baml_language/crates/baml_fmt/src/ast/declarations.rs:1385— baml_language/crates/baml_fmt/src/ast/declarations.rs:1385-1392 | baml_language/crates/baml_fmt/src/ast/declarations.rs:1445-1452 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (8 lines × 2) baml_language/crates/baml_fmt/src/ast/expressions.rs:3000— baml_language/crates/baml_fmt/src/ast/expressions.rs:3000-3007 | baml_language/crates/baml_fmt/src/ast/expressions.rs:4477-4484 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_ide/src/completion/completions.rs:243— baml_language/crates/baml_ide/src/completion/completions.rs:243-250 | baml_language/crates/baml_ide/src/completion/completions.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) baml_language/crates/baml_ide/src/describe.rs:1108— baml_language/crates/baml_ide/src/describe.rs:1108-1115 | baml_language/crates/baml_ide/src/describe.rs:1129-1137 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_lsp_server/src/playground_server.rs:244— baml_language/crates/baml_lsp_server/src/playground_server.rs:244-251 | baml_language/crates/baml_lsp_server/src/playground_server.rs:254-261 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (8 lines × 2) baml_language/crates/baml_query_btel/src/ingest/profile.rs:406— baml_language/crates/baml_query_btel/src/ingest/profile.rs:406-413 | baml_language/crates/baml_query_btel/src/ingest/profile.rs:459-466 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_type/src/normalize.rs:1507— baml_language/crates/baml_type/src/normalize.rs:1507-1514 | baml_language/crates/baml_type/src/normalize.rs:2192-2199 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_builtins2_codegen/src/codegen_io.rs:1585— baml_language/crates/baml_builtins2_codegen/src/codegen_io.rs:1585-1590 | baml_language/crates/baml_builtins2_codegen/src/codegen_io.rs:1939-1944 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_builtins2_codegen/src/codegen_io.rs:1940— baml_language/crates/baml_builtins2_codegen/src/codegen_io.rs:1940-1945 | baml_language/crates/baml_builtins2_codegen/src/codegen_io.rs:1993-1999 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_cli/src/describe_command.rs:136— baml_language/crates/baml_cli/src/describe_command.rs:136-141 | baml_language/crates/baml_cli/src/describe_command.rs:158-163 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:2892— baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:2892-2897 | baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:2970-2975 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler2_hir/src/builder.rs:1171— baml_language/crates/baml_compiler2_hir/src/builder.rs:1171-1176 | baml_language/crates/baml_compiler2_hir/src/builder.rs:1348-1353 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler2_hir/src/builder.rs:1386— baml_language/crates/baml_compiler2_hir/src/builder.rs:1386-1391 | baml_language/crates/baml_compiler2_hir/src/builder.rs:1619-1624 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler2_hir/src/contributions.rs:89— baml_language/crates/baml_compiler2_hir/src/contributions.rs:89-94 | baml_language/crates/baml_ide/src/export.rs:762-767 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (6 lines × 2) baml_language/crates/baml_compiler2_hir_ty/src/impls.rs:2183— baml_language/crates/baml_compiler2_hir_ty/src/impls.rs:2183-2188 | baml_language/crates/baml_compiler2_hir_ty/src/impls.rs:2191-2196 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler2_hir_ty/src/lower.rs:3199— baml_language/crates/baml_compiler2_hir_ty/src/lower.rs:3199-3204 | baml_language/crates/baml_compiler2_hir_ty/src/lower.rs:3220-3229 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler2_mir/src/lower.rs:3846— baml_language/crates/baml_compiler2_mir/src/lower.rs:3846-3851 | baml_language/crates/baml_compiler2_mir/src/lower.rs:9530-9536 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler2_mir/src/lower.rs:11907— baml_language/crates/baml_compiler2_mir/src/lower.rs:11907-11915 | baml_language/crates/baml_compiler2_mir/src/lower.rs:12035-12040 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler2_visualization/src/control_flow/flatten.rs:480— baml_language/crates/baml_compiler2_visualization/src/control_flow/flatten.rs:480-485 | engine/baml-runtime/src/control_flow/flatten/step2_hoist_branch_arms.rs:68-73 — before extracting anything, compare `baml_language/crates/baml_compiler2_visualization/src/control_flow/flatten.rs` and `engine/baml-runtime/src/control_flow/flatten/step2_hoist_branch_arms.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 56 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (6 lines × 2) baml_language/crates/baml_fmt/src/ast/declarations.rs:488— baml_language/crates/baml_fmt/src/ast/declarations.rs:488-493 | baml_language/crates/baml_fmt/src/ast/types.rs:1186-1191 — before extracting anything, compare `baml_language/crates/baml_fmt/src/ast/declarations.rs` and `baml_language/crates/baml_fmt/src/ast/types.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 53 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the 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) baml_language/crates/baml_fmt/src/ast/declarations.rs:898— baml_language/crates/baml_fmt/src/ast/declarations.rs:898-903 | baml_language/crates/baml_fmt/src/ast/pattern.rs:370-375 — 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) baml_language/crates/baml_fmt/src/ast/expressions.rs:841— baml_language/crates/baml_fmt/src/ast/expressions.rs:841-846 | baml_language/crates/baml_fmt/src/ast/statements.rs:840-846 — before extracting anything, compare `baml_language/crates/baml_fmt/src/ast/expressions.rs` and `baml_language/crates/baml_fmt/src/ast/statements.rs` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 65 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the 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) baml_language/crates/baml_fmt/src/ast/expressions.rs:1815— baml_language/crates/baml_fmt/src/ast/expressions.rs:1815-1820 | baml_language/crates/baml_fmt/src/ast/statements.rs:607-612 — before extracting anything, compare `baml_language/crates/baml_fmt/src/ast/expressions.rs` and `baml_language/crates/baml_fmt/src/ast/statements.rs` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 65 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the 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) baml_language/crates/baml_ide/src/annotations.rs:300— baml_language/crates/baml_ide/src/annotations.rs:300-305 | baml_language/crates/baml_ide/src/annotations.rs:363-368 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_ide/src/describe.rs:461— baml_language/crates/baml_ide/src/describe.rs:461-466 | baml_language/crates/baml_ide/src/describe.rs:517-522 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_ide/src/describe.rs:1588— baml_language/crates/baml_ide/src/describe.rs:1588-1593 | baml_language/crates/baml_ide/src/info.rs:1915-1920 — 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) baml_language/crates/baml_ide/src/listing.rs:110— baml_language/crates/baml_ide/src/listing.rs:110-119 | baml_language/crates/baml_ide/src/listing.rs:129-134 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_sdkgen_types/src/output_writer.rs:674— baml_language/crates/baml_sdkgen_types/src/output_writer.rs:674-679 | baml_language/crates/baml_sdkgen_types/src/output_writer.rs:902-907 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_type/src/normalize/mu.rs:677— baml_language/crates/baml_type/src/normalize/mu.rs:677-682 | baml_language/crates/baml_type/src/normalize/mu.rs:1407-1412 — both copies are in the same file, so extract the block into 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) baml_language/crates/bex_events/src/history/mod.rs:245— baml_language/crates/bex_events/src/history/mod.rs:245-250 | baml_language/crates/bridge_wasm/src/runs.rs:184-189 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (6 lines × 2) baml_language/crates/bex_heap/src/gc.rs:1269— baml_language/crates/bex_heap/src/gc.rs:1269-1274 | baml_language/crates/bex_heap/src/gc.rs:1305-1311 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (6 lines × 2) baml_language/crates/bex_sap/src/deserializer/coercer/array_helper.rs:71— baml_language/crates/bex_sap/src/deserializer/coercer/array_helper.rs:71-76 | engine/baml-lib/jsonish/src/deserializer/coercer/array_helper.rs:41-46 — 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) baml_language/crates/baml_builtins2_codegen/src/codegen_io.rs:249— baml_language/crates/baml_builtins2_codegen/src/codegen_io.rs:249-257 | baml_language/crates/baml_builtins2_codegen/src/codegen_io.rs:637-645 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_cli/src/commands.rs:284— baml_language/crates/baml_cli/src/commands.rs:284-292 | engine/cli/src/commands.rs:100-108 — 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) baml_language/crates/baml_cli/src/paint.rs:278— baml_language/crates/baml_cli/src/paint.rs:278-286 | baml_language/crates/baml_compiler_diagnostics/src/render.rs:1027-1035 — 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) baml_language/crates/baml_compiler2_emit/src/lib.rs:1176— baml_language/crates/baml_compiler2_emit/src/lib.rs:1176-1186 | baml_language/crates/baml_compiler2_emit/src/package/bodies.rs:88-96 — 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) baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs:436— baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs:436-444 | baml_language/crates/baml_type/src/unify.rs:780-788 — before extracting anything, compare `baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs` and `baml_language/crates/baml_type/src/unify.rs` as WHOLE FILES: this scan already matched 21 separate duplicated blocks between them, totalling at least 418 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (9 lines × 2) baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs:604— baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs:604-612 | baml_language/crates/baml_type/src/unify.rs:1123-1131 — before extracting anything, compare `baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs` and `baml_language/crates/baml_type/src/unify.rs` as WHOLE FILES: this scan already matched 21 separate duplicated blocks between them, totalling at least 418 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (9 lines × 2) baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:5378— baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:5378-5386 | baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:5397-5405 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:6970— baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:6970-6978 | baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:10109-10117 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:7027— baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:7027-7036 | baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:10090-10098 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler2_hir_ty/src/interfaces/impl_rules.rs:2019— baml_language/crates/baml_compiler2_hir_ty/src/interfaces/impl_rules.rs:2019-2027 | baml_language/crates/baml_compiler2_hir_ty/src/interfaces/impl_rules.rs:2105-2113 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler2_hir_ty/src/lower.rs:1264— baml_language/crates/baml_compiler2_hir_ty/src/lower.rs:1264-1273 | baml_language/crates/baml_compiler2_hir_ty/src/lower.rs:1404-1412 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler2_mir/src/lower.rs:12420— baml_language/crates/baml_compiler2_mir/src/lower.rs:12420-12428 | baml_language/crates/baml_compiler2_mir/src/lower.rs:12537-12545 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler2_mir/src/lower.rs:14364— baml_language/crates/baml_compiler2_mir/src/lower.rs:14364-14372 | baml_language/crates/baml_compiler2_mir/src/lower.rs:14538-14546 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler_parser/src/parser.rs:1176— baml_language/crates/baml_compiler_parser/src/parser.rs:1176-1184 | baml_language/crates/baml_compiler_parser/src/parser.rs:1241-1249 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (9 lines × 2) baml_language/crates/baml_fmt/src/ast/pattern.rs:447— baml_language/crates/baml_fmt/src/ast/pattern.rs:447-455 | baml_language/crates/baml_fmt/src/ast/pattern.rs:650-658 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_query_btel/src/ingest.rs:1132— baml_language/crates/baml_query_btel/src/ingest.rs:1132-1140 | baml_language/crates/baml_query_btel/src/ingest/bulk.rs:627-635 — 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) baml_language/crates/baml_sdkgen_types/src/output_writer.rs:591— baml_language/crates/baml_sdkgen_types/src/output_writer.rs:591-599 | baml_language/crates/baml_sdkgen_types/src/output_writer.rs:1515-1523 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_type_macros/src/convert.rs:215— baml_language/crates/baml_type_macros/src/convert.rs:215-227 | baml_language/crates/baml_type_macros/src/convert.rs:1002-1010 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_type_macros/src/convert.rs:412— baml_language/crates/baml_type_macros/src/convert.rs:412-420 | baml_language/crates/baml_type_macros/src/convert.rs:769-777 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_type_macros/src/convert.rs:718— baml_language/crates/baml_type_macros/src/convert.rs:718-726 | baml_language/crates/baml_type_macros/src/convert.rs:1023-1031 — both copies are in the same file, so extract the block into 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) baml_language/crates/bex_sap/src/deserializer/coercer/coerce_class.rs:237— baml_language/crates/bex_sap/src/deserializer/coercer/coerce_class.rs:237-245 | baml_language/crates/bex_sap/src/deserializer/coercer/coerce_class.rs:305-313 — both copies are in the same file, so extract the block into 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) baml_language/crates/bex_sap/src/deserializer/coercer/coerce_primitive.rs:158— baml_language/crates/bex_sap/src/deserializer/coercer/coerce_primitive.rs:158-166 | baml_language/crates/bex_sap/src/deserializer/coercer/coerce_primitive.rs:348-356 — both copies are in the same file, so extract the block into 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) baml_language/crates/bex_sap/src/deserializer/coercer/mod.rs:85— baml_language/crates/bex_sap/src/deserializer/coercer/mod.rs:85-93 | baml_language/crates/bex_sap/src/deserializer/coercer/mod.rs:96-104 — both copies are in the same file, so extract the block into 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) baml_language/crates/bex_sap/src/deserializer/score.rs:24— baml_language/crates/bex_sap/src/deserializer/score.rs:24-32 | engine/baml-lib/jsonish/src/deserializer/score.rs:44-52 — 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) baml_language/crates/bex_sap/src/jsonish/parser/entry.rs:136— baml_language/crates/bex_sap/src/jsonish/parser/entry.rs:136-144 | engine/baml-lib/jsonish/src/jsonish/parser/entry.rs:145-153 — before extracting anything, compare `baml_language/crates/bex_sap/src/jsonish/parser/entry.rs` and `engine/baml-lib/jsonish/src/jsonish/parser/entry.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 55 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (7 lines × 2) baml_language/crates/baml_builtins2_codegen/src/codegen_io.rs:1572— baml_language/crates/baml_builtins2_codegen/src/codegen_io.rs:1572-1578 | baml_language/crates/baml_builtins2_codegen/src/codegen_io.rs:1991-1997 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_cli/src/diagnostics_cache.rs:124— baml_language/crates/baml_cli/src/diagnostics_cache.rs:124-130 | baml_language/crates/baml_cli/src/diagnostics_cache.rs:160-166 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler2_hir/src/item_data/classes.rs:91— baml_language/crates/baml_compiler2_hir/src/item_data/classes.rs:91-97 | baml_language/crates/baml_compiler2_hir/src/item_data/functions.rs:404-410 — 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) baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs:1033— baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs:1033-1039 | baml_language/crates/baml_compiler2_hir_ty/src/interfaces/coherence.rs:249-255 — before extracting anything, compare `baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs` and `baml_language/crates/baml_compiler2_hir_ty/src/interfaces/coherence.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 61 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (7 lines × 2) baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs:1050— baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs:1050-1056 | baml_language/crates/baml_compiler2_hir_ty/src/interfaces/coherence.rs:273-281 — before extracting anything, compare `baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs` and `baml_language/crates/baml_compiler2_hir_ty/src/interfaces/coherence.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 61 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (7 lines × 2) baml_language/crates/baml_compiler2_hir_ty/src/impls.rs:2126— baml_language/crates/baml_compiler2_hir_ty/src/impls.rs:2126-2132 | baml_language/crates/baml_type/src/normalize.rs:3162-3168 — 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) baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:6827— baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:6827-6833 | baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:6841-6847 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:14460— baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:14460-14466 | baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:14468-14474 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler2_mir/src/lower.rs:2650— baml_language/crates/baml_compiler2_mir/src/lower.rs:2650-2656 | baml_language/crates/baml_compiler2_mir/src/lower.rs:2666-2672 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler2_mir/src/lower.rs:7075— baml_language/crates/baml_compiler2_mir/src/lower.rs:7075-7081 | baml_language/crates/baml_compiler2_mir/src/lower.rs:7976-7982 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler2_mir/src/lower.rs:9237— baml_language/crates/baml_compiler2_mir/src/lower.rs:9237-9243 | baml_language/crates/baml_compiler2_mir/src/lower.rs:9289-9295 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler2_mir/src/lower.rs:14388— baml_language/crates/baml_compiler2_mir/src/lower.rs:14388-14394 | baml_language/crates/baml_compiler2_mir/src/lower.rs:14560-14566 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler_parser/src/parser.rs:1515— baml_language/crates/baml_compiler_parser/src/parser.rs:1515-1521 | baml_language/crates/baml_compiler_parser/src/parser.rs:1710-1716 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_fmt/src/ast/attributes.rs:294— baml_language/crates/baml_fmt/src/ast/attributes.rs:294-300 | baml_language/crates/baml_fmt/src/ast/declarations.rs:2855-2861 — before extracting anything, compare `baml_language/crates/baml_fmt/src/ast/attributes.rs` and `baml_language/crates/baml_fmt/src/ast/declarations.rs` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 70 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (7 lines × 2) baml_language/crates/baml_fmt/src/ast/expressions.rs:3880— baml_language/crates/baml_fmt/src/ast/expressions.rs:3880-3887 | baml_language/crates/baml_fmt/src/ast/pattern.rs:614-620 — before extracting anything, compare `baml_language/crates/baml_fmt/src/ast/expressions.rs` and `baml_language/crates/baml_fmt/src/ast/pattern.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 39 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (7 lines × 2) baml_language/crates/baml_fmt/src/ast/pattern.rs:489— baml_language/crates/baml_fmt/src/ast/pattern.rs:489-495 | baml_language/crates/baml_fmt/src/ast/pattern.rs:711-717 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_ide/src/cursor_context.rs:301— baml_language/crates/baml_ide/src/cursor_context.rs:301-307 | baml_language/crates/baml_ide/src/cursor_context.rs:423-429 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (7 lines × 2) baml_language/crates/baml_ide/src/resolve.rs:579— baml_language/crates/baml_ide/src/resolve.rs:579-585 | baml_language/crates/baml_ide/src/resolve.rs:623-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 (7 lines × 2) baml_language/crates/baml_lsp_server/src/playground_seam.rs:1060— baml_language/crates/baml_lsp_server/src/playground_seam.rs:1060-1066 | baml_language/crates/bridge_wasm/src/playground.rs:560-566 — 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) baml_language/crates/baml_query/src/value/lowering.rs:665— baml_language/crates/baml_query/src/value/lowering.rs:665-671 | baml_language/crates/baml_query/src/value/lowering.rs:707-713 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (7 lines × 2) baml_language/crates/baml_type/src/normalize.rs:1516— baml_language/crates/baml_type/src/normalize.rs:1516-1522 | baml_language/crates/baml_type/src/normalize.rs:2201-2207 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_type/src/normalize/mu.rs:667— baml_language/crates/baml_type/src/normalize/mu.rs:667-673 | baml_language/crates/baml_type/src/normalize/mu.rs:1397-1403 — both copies are in the same file, so extract the block into 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) baml_language/crates/bex_engine/src/conversion.rs:698— baml_language/crates/bex_engine/src/conversion.rs:698-704 | baml_language/crates/bex_engine/src/conversion.rs:722-728 — both copies are in the same file, so extract the block into 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) baml_language/crates/bex_engine/src/lib.rs:4982— baml_language/crates/bex_engine/src/lib.rs:4982-4989 | baml_language/crates/bex_engine/src/lib.rs:5010-5016 — both copies are in the same file, so extract the block into 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) baml_language/crates/bex_heap/src/heap.rs:1126— baml_language/crates/bex_heap/src/heap.rs:1126-1132 | baml_language/crates/bex_heap/src/heap.rs:1387-1393 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_base/src/qualified_name.rs:225— baml_language/crates/baml_base/src/qualified_name.rs:225-229 | baml_language/crates/baml_base/src/qualified_name.rs:231-235 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs:67— baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs:67-71 | baml_language/crates/baml_type/src/unify.rs:160-164 — before extracting anything, compare `baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs` and `baml_language/crates/baml_type/src/unify.rs` as WHOLE FILES: this scan already matched 21 separate duplicated blocks between them, totalling at least 418 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (5 lines × 2) baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs:596— baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs:596-600 | baml_language/crates/baml_type/src/unify.rs:1111-1115 — before extracting anything, compare `baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs` and `baml_language/crates/baml_type/src/unify.rs` as WHOLE FILES: this scan already matched 21 separate duplicated blocks between them, totalling at least 418 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (5 lines × 2) baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs:731— baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs:731-735 | baml_language/crates/baml_type/src/unify.rs:1260-1264 — before extracting anything, compare `baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs` and `baml_language/crates/baml_type/src/unify.rs` as WHOLE FILES: this scan already matched 21 separate duplicated blocks between them, totalling at least 418 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (5 lines × 2) baml_language/crates/baml_compiler2_hir_ty/src/interfaces.rs:1006— baml_language/crates/baml_compiler2_hir_ty/src/interfaces.rs:1006-1010 | baml_language/crates/baml_compiler2_hir_ty/src/interfaces.rs:1014-1018 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler2_hir_ty/src/lower.rs:2704— baml_language/crates/baml_compiler2_hir_ty/src/lower.rs:2704-2708 | baml_language/crates/baml_compiler2_hir_ty/src/lower.rs:2716-2720 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler2_hir_ty/src/lower.rs:3192— baml_language/crates/baml_compiler2_hir_ty/src/lower.rs:3192-3196 | baml_language/crates/baml_compiler2_hir_ty/src/lower.rs:3213-3217 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler2_mir/src/lower.rs:8549— baml_language/crates/baml_compiler2_mir/src/lower.rs:8549-8553 | baml_language/crates/baml_compiler2_mir/src/lower.rs:8572-8576 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler2_mir/src/optimize/values.rs:252— baml_language/crates/baml_compiler2_mir/src/optimize/values.rs:252-256 | baml_language/crates/baml_compiler2_mir/src/optimize/values.rs:299-303 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_fmt/src/ast/declarations.rs:895— baml_language/crates/baml_fmt/src/ast/declarations.rs:895-900 | baml_language/crates/baml_fmt/src/ast/types.rs:544-548 — before extracting anything, compare `baml_language/crates/baml_fmt/src/ast/declarations.rs` and `baml_language/crates/baml_fmt/src/ast/types.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 53 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the 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) baml_language/crates/baml_fmt/src/ast/declarations.rs:1425— baml_language/crates/baml_fmt/src/ast/declarations.rs:1425-1429 | baml_language/crates/baml_fmt/src/ast/declarations.rs:2250-2254 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_fmt/src/ast/pattern.rs:209— baml_language/crates/baml_fmt/src/ast/pattern.rs:209-213 | baml_language/crates/baml_fmt/src/ast/pattern.rs:364-368 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_fmt/src/ast/pattern.rs:922— baml_language/crates/baml_fmt/src/ast/pattern.rs:922-926 | baml_language/crates/baml_fmt/src/ast/pattern.rs:1064-1068 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (5 lines × 2) baml_language/crates/baml_fmt/src/ast/pattern.rs:1011— baml_language/crates/baml_fmt/src/ast/pattern.rs:1011-1015 | baml_language/crates/baml_fmt/src/ast/types.rs:335-339 — before extracting anything, compare `baml_language/crates/baml_fmt/src/ast/pattern.rs` and `baml_language/crates/baml_fmt/src/ast/types.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 55 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the 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) baml_language/crates/baml_lsp/src/dispatch/requests.rs:368— baml_language/crates/baml_lsp/src/dispatch/requests.rs:368-372 | baml_language/crates/baml_lsp/src/dispatch/requests.rs:856-860 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_query_btel/src/sql.rs:762— baml_language/crates/baml_query_btel/src/sql.rs:762-766 | baml_language/crates/baml_query_btel/src/sql.rs:783-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.
Duplicated block (5 lines × 2) baml_language/crates/baml_type_macros/src/emit.rs:158— baml_language/crates/baml_type_macros/src/emit.rs:158-162 | baml_language/crates/baml_type_macros/src/emit.rs:198-202 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_type_macros/src/emit.rs:321— baml_language/crates/baml_type_macros/src/emit.rs:321-325 | baml_language/crates/baml_type_macros/src/emit.rs:588-592 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (5 lines × 2) baml_language/crates/bex_engine/src/lib.rs:3867— baml_language/crates/bex_engine/src/lib.rs:3867-3871 | baml_language/crates/bex_engine/src/lib.rs:5725-5729 — both copies are in the same file, so extract the block into 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) baml_language/crates/bex_sap/src/deserializer/coercer/coerce_primitive.rs:146— baml_language/crates/bex_sap/src/deserializer/coercer/coerce_primitive.rs:146-150 | baml_language/crates/bex_sap/src/deserializer/coercer/coerce_primitive.rs:463-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 (5 lines × 2) baml_language/crates/bex_sap/src/jsonish/value.rs:47— baml_language/crates/bex_sap/src/jsonish/value.rs:47-51 | engine/baml-lib/jsonish/src/jsonish/value.rs:39-43 — before extracting anything, compare `baml_language/crates/bex_sap/src/jsonish/value.rs` and `engine/baml-lib/jsonish/src/jsonish/value.rs` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 160 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (5 lines × 2) baml_language/crates/bex_vm/src/package_baml/json/encode.rs:364— baml_language/crates/bex_vm/src/package_baml/json/encode.rs:364-368 | baml_language/crates/bex_vm/src/package_baml/root.rs:304-308 — 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 (5 lines × 2) baml_language/crates/bex_vm/src/vm.rs:11271— baml_language/crates/bex_vm/src/vm.rs:11271-11278 | baml_language/crates/bex_vm/src/vm.rs:11307-11311 — both copies are in the same file, so extract the block into 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) baml_language/crates/bex_vm_types/src/bytecode.rs:1957— baml_language/crates/bex_vm_types/src/bytecode.rs:1957-1961 | engine/baml-vm/src/bytecode.rs:343-347 — 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 (5 lines × 2) baml_language/crates/bex_vm_types/src/bytecode.rs:2769— baml_language/crates/bex_vm_types/src/bytecode.rs:2769-2775 | baml_language/crates/bex_vm_types/src/bytecode.rs:2787-2791 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_cli/src/describe_command.rs:857— baml_language/crates/baml_cli/src/describe_command.rs:857-868 | baml_language/crates/baml_cli/src/describe_command.rs:883-894 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler2_hir/src/item_tree/builder.rs:68— baml_language/crates/baml_compiler2_hir/src/item_tree/builder.rs:68-79 | baml_language/crates/baml_compiler2_hir/src/item_tree/builder.rs:290-301 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs:689— baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs:689-700 | baml_language/crates/baml_type/src/unify.rs:1217-1228 — before extracting anything, compare `baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs` and `baml_language/crates/baml_type/src/unify.rs` as WHOLE FILES: this scan already matched 21 separate duplicated blocks between them, totalling at least 418 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (12 lines × 2) baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:6957— baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:6957-6968 | baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:7035-7046 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:7062— baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:7062-7073 | baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:10120-10131 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:7078— baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:7078-7089 | baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:10136-10147 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler2_mir/src/lower.rs:13155— baml_language/crates/baml_compiler2_mir/src/lower.rs:13155-13166 | baml_language/crates/baml_compiler2_mir/src/lower.rs:14474-14485 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler2_visualization/src/control_flow/flatten.rs:673— baml_language/crates/baml_compiler2_visualization/src/control_flow/flatten.rs:673-684 | engine/baml-runtime/src/control_flow/flatten/step3_inline_implicit_nodes.rs:142-153 — before extracting anything, compare `baml_language/crates/baml_compiler2_visualization/src/control_flow/flatten.rs` and `engine/baml-runtime/src/control_flow/flatten/step3_inline_implicit_nodes.rs` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 132 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (12 lines × 2) baml_language/crates/baml_compiler2_visualization/src/control_flow/from_ast.rs:528— baml_language/crates/baml_compiler2_visualization/src/control_flow/from_ast.rs:528-539 | engine/baml-runtime/src/control_flow.rs:718-729 — before extracting anything, compare `baml_language/crates/baml_compiler2_visualization/src/control_flow/from_ast.rs` and `engine/baml-runtime/src/control_flow.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 69 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (12 lines × 2) baml_language/crates/baml_compiler_parser/src/parser.rs:5235— baml_language/crates/baml_compiler_parser/src/parser.rs:5235-5248 | baml_language/crates/baml_compiler_parser/src/parser.rs:5293-5304 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_fmt/src/ast/declarations.rs:2980— baml_language/crates/baml_fmt/src/ast/declarations.rs:2980-2991 | baml_language/crates/baml_fmt/src/ast/expressions.rs:4038-4049 — before extracting anything, compare `baml_language/crates/baml_fmt/src/ast/declarations.rs` and `baml_language/crates/baml_fmt/src/ast/expressions.rs` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 124 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (12 lines × 2) baml_language/crates/baml_fmt/src/ast/declarations.rs:3076— baml_language/crates/baml_fmt/src/ast/declarations.rs:3076-3087 | baml_language/crates/baml_fmt/src/ast/declarations.rs:3156-3167 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (12 lines × 2) baml_language/crates/baml_fmt/src/ast/expressions.rs:1663— baml_language/crates/baml_fmt/src/ast/expressions.rs:1663-1674 | baml_language/crates/baml_fmt/src/ast/expressions.rs:1820-1831 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_ide/src/info.rs:598— baml_language/crates/baml_ide/src/info.rs:598-609 | baml_language/crates/baml_ide/src/info.rs:639-650 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_ide/src/resolve.rs:977— baml_language/crates/baml_ide/src/resolve.rs:977-988 | baml_language/crates/baml_ide/src/resolve.rs:1077-1088 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_query_btel/src/ingest.rs:587— baml_language/crates/baml_query_btel/src/ingest.rs:587-598 | baml_language/crates/baml_query_btel/src/ingest.rs:828-839 — both copies are in the same file, so extract the block into 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) baml_language/crates/bex_engine/src/conversion.rs:2252— baml_language/crates/bex_engine/src/conversion.rs:2252-2263 | baml_language/crates/bex_engine/src/conversion.rs:2292-2303 — both copies are in the same file, so extract the block into 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) baml_language/crates/bex_sap/src/deserializer/coercer/coerce_enum.rs:77— baml_language/crates/bex_sap/src/deserializer/coercer/coerce_enum.rs:77-88 | baml_language/crates/bex_sap/src/deserializer/coercer/coerce_enum.rs:168-179 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (12 lines × 2) baml_language/crates/bex_sap/src/deserializer/coercer/coerce_primitive.rs:828— baml_language/crates/bex_sap/src/deserializer/coercer/coerce_primitive.rs:828-839 | engine/baml-lib/jsonish/src/deserializer/coercer/coerce_primitive.rs:250-261 — 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 (12 lines × 2) baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs:815— baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs:815-826 | engine/baml-lib/jsonish/src/jsonish/parser/fixing_parser/json_parse_state.rs:860-871 — before extracting anything, compare `baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs` and `engine/baml-lib/jsonish/src/jsonish/parser/fixing_parser/json_parse_state.rs` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 575 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (12 lines × 2) baml_language/crates/bex_sap/src/sap_model/from_literal.rs:383— baml_language/crates/bex_sap/src/sap_model/from_literal.rs:383-394 | baml_language/crates/bex_sap/src/sap_model/from_literal.rs:422-433 — both copies are in the same file, so extract the block into 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) baml_language/crates/bex_vm/src/package_baml/array.rs:962— baml_language/crates/bex_vm/src/package_baml/array.rs:962-973 | baml_language/crates/bex_vm/src/package_baml/array.rs:1209-1220 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (12 lines × 2) baml_language/crates/bex_vm/src/package_reflect/reflect.rs:1560— baml_language/crates/bex_vm/src/package_reflect/reflect.rs:1560-1571 | baml_language/crates/bex_vm/src/package_reflect/reflect.rs:1899-1910 — both copies are in the same file, so extract the block into 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) baml_language/crates/bex_vm/src/vm.rs:7578— baml_language/crates/bex_vm/src/vm.rs:7578-7589 | baml_language/crates/bex_vm/src/vm.rs:7594-7605 — both copies are in the same file, so extract the block into 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) baml_language/crates/bex_vm/src/vm.rs:9790— baml_language/crates/bex_vm/src/vm.rs:9790-9801 | baml_language/crates/bex_vm/src/vm.rs:9824-9835 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_builtins2_codegen/src/codegen_io.rs:268— baml_language/crates/baml_builtins2_codegen/src/codegen_io.rs:268-277 | baml_language/crates/baml_builtins2_codegen/src/codegen_io.rs:656-665 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs:520— baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs:520-529 | baml_language/crates/baml_type/src/unify.rs:1023-1032 — before extracting anything, compare `baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs` and `baml_language/crates/baml_type/src/unify.rs` as WHOLE FILES: this scan already matched 21 separate duplicated blocks between them, totalling at least 418 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (10 lines × 2) baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:6969— baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:6969-6978 | baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:10216-10225 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler2_mir/src/lower.rs:12386— baml_language/crates/baml_compiler2_mir/src/lower.rs:12386-12395 | baml_language/crates/baml_compiler2_mir/src/lower.rs:12473-12482 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler_parser/src/parser.rs:5047— baml_language/crates/baml_compiler_parser/src/parser.rs:5047-5058 | baml_language/crates/baml_compiler_parser/src/parser.rs:6549-6558 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler_parser/src/parser.rs:8096— baml_language/crates/baml_compiler_parser/src/parser.rs:8096-8105 | baml_language/crates/baml_compiler_parser/src/parser.rs:8124-8134 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_db/src/check.rs:92— baml_language/crates/baml_db/src/check.rs:92-101 | baml_language/crates/baml_db/src/check.rs:286-301 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_linker/src/resolve.rs:30— baml_language/crates/baml_linker/src/resolve.rs:30-39 | baml_language/crates/baml_linker/src/resolve.rs:83-92 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_lsp_server/src/playground_env.rs:117— baml_language/crates/baml_lsp_server/src/playground_env.rs:117-126 | baml_language/crates/baml_lsp_server/src/playground_io.rs:96-105 — 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 (10 lines × 2) baml_language/crates/baml_lsp_server/src/playground_env.rs:159— baml_language/crates/baml_lsp_server/src/playground_env.rs:159-168 | baml_language/crates/baml_lsp_server/src/playground_io.rs:159-168 — 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 (10 lines × 2) baml_language/crates/baml_lsp_server/src/playground_server.rs:1780— baml_language/crates/baml_lsp_server/src/playground_server.rs:1780-1792 | baml_language/crates/baml_lsp_server/src/playground_server.rs:2006-2015 — both copies are in the same file, so extract the block into 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) baml_language/crates/bex_chunkedringbuffer/src/lib.rs:487— baml_language/crates/bex_chunkedringbuffer/src/lib.rs:487-496 | baml_language/crates/bex_chunkedringbuffer/src/lib.rs:533-542 — both copies are in the same file, so extract the block into 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) baml_language/crates/bex_engine/src/conversion.rs:3744— baml_language/crates/bex_engine/src/conversion.rs:3744-3753 | baml_language/crates/bex_engine/src/conversion.rs:4380-4389 — both copies are in the same file, so extract the block into 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) baml_language/crates/bex_engine/src/trace_value_encode.rs:469— baml_language/crates/bex_engine/src/trace_value_encode.rs:469-478 | baml_language/crates/bridge_ctypes/src/value_encode.rs:284-293 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (10 lines × 2) baml_language/crates/bex_heap/src/gc.rs:323— baml_language/crates/bex_heap/src/gc.rs:323-332 | baml_language/crates/bex_heap/src/gc.rs:464-473 — both copies are in the same file, so extract the block into 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) baml_language/crates/bex_sap/src/deserializer/coercer/coerce_class.rs:375— baml_language/crates/bex_sap/src/deserializer/coercer/coerce_class.rs:375-384 | baml_language/crates/bex_sap/src/deserializer/coercer/coerce_class.rs:390-399 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (10 lines × 2) baml_language/crates/bex_sap/src/deserializer/coercer/coerce_enum.rs:103— baml_language/crates/bex_sap/src/deserializer/coercer/coerce_enum.rs:103-112 | baml_language/crates/bex_sap/src/deserializer/coercer/coerce_enum.rs:192-201 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (10 lines × 2) baml_language/crates/bex_sap/src/deserializer/deserialize_flags.rs:143— baml_language/crates/bex_sap/src/deserializer/deserialize_flags.rs:143-152 | engine/baml-lib/jsonish/src/deserializer/deserialize_flags.rs:158-167 — before extracting anything, compare `baml_language/crates/bex_sap/src/deserializer/deserialize_flags.rs` and `engine/baml-lib/jsonish/src/deserializer/deserialize_flags.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 127 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (10 lines × 2) baml_language/crates/bex_vm/src/package_baml/array.rs:969— baml_language/crates/bex_vm/src/package_baml/array.rs:969-978 | baml_language/crates/bex_vm/src/package_baml/array.rs:997-1006 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (10 lines × 2) baml_language/crates/bex_vm/src/package_baml/root.rs:706— baml_language/crates/bex_vm/src/package_baml/root.rs:706-715 | baml_language/crates/bex_vm/src/package_baml/root.rs:738-747 — both copies are in the same file, so extract the block into 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) baml_language/crates/bex_vm/src/package_baml/time.rs:298— baml_language/crates/bex_vm/src/package_baml/time.rs:298-307 | baml_language/crates/bex_vm/src/package_baml/time.rs:522-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 (10 lines × 2) baml_language/crates/bex_vm/src/package_reflect/type_class.rs:1260— baml_language/crates/bex_vm/src/package_reflect/type_class.rs:1260-1269 | baml_language/crates/bex_vm/src/package_reflect/type_class.rs:1298-1307 — both copies are in the same file, so extract the block into 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) baml_language/crates/bex_vm/src/vm.rs:11005— baml_language/crates/bex_vm/src/vm.rs:11005-11014 | baml_language/crates/bex_vm/src/vm.rs:11020-11029 — both copies are in the same file, so extract the block into 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) baml_language/crates/bex_vm/src/vm.rs:11668— baml_language/crates/bex_vm/src/vm.rs:11668-11677 | baml_language/crates/bex_vm/src/vm.rs:11686-11695 — both copies are in the same file, so extract the block into 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) baml_language/crates/tools_size_gate/src/compare.rs:131— baml_language/crates/tools_size_gate/src/compare.rs:131-140 | baml_language/crates/tools_size_gate/src/output.rs:393-402 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (11 lines × 2) baml_language/crates/baml_builtins2_codegen/src/codegen_io.rs:1603— baml_language/crates/baml_builtins2_codegen/src/codegen_io.rs:1603-1613 | baml_language/crates/baml_builtins2_codegen/src/codegen_io.rs:1999-2009 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_builtins2_codegen/src/codegen_io.rs:1801— baml_language/crates/baml_builtins2_codegen/src/codegen_io.rs:1801-1811 | baml_language/crates/baml_builtins2_codegen/src/codegen_io.rs:1846-1856 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_cli/src/describe_command.rs:421— baml_language/crates/baml_cli/src/describe_command.rs:421-431 | baml_language/crates/baml_cli/src/describe_command.rs:465-475 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (11 lines × 2) baml_language/crates/baml_compiler2_ast/src/ast.rs:544— baml_language/crates/baml_compiler2_ast/src/ast.rs:544-554 | baml_language/crates/baml_compiler2_ast/src/ast.rs:562-572 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (11 lines × 2) baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:5929— baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:5929-5939 | baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:6362-6372 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler2_mir/src/lower.rs:13172— baml_language/crates/baml_compiler2_mir/src/lower.rs:13172-13182 | baml_language/crates/baml_compiler2_mir/src/lower.rs:13203-13213 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler2_mir/src/lower.rs:13767— baml_language/crates/baml_compiler2_mir/src/lower.rs:13767-13777 | baml_language/crates/baml_compiler2_mir/src/lower.rs:13813-13823 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler2_visualization/src/control_flow/flatten.rs:430— baml_language/crates/baml_compiler2_visualization/src/control_flow/flatten.rs:430-440 | engine/baml-runtime/src/control_flow/flatten/step2_hoist_branch_arms.rs:20-30 — before extracting anything, compare `baml_language/crates/baml_compiler2_visualization/src/control_flow/flatten.rs` and `engine/baml-runtime/src/control_flow/flatten/step2_hoist_branch_arms.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 56 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (11 lines × 2) baml_language/crates/baml_compiler2_visualization/src/control_flow/flatten.rs:523— baml_language/crates/baml_compiler2_visualization/src/control_flow/flatten.rs:523-533 | engine/baml-runtime/src/control_flow/flatten/step3_inline_implicit_nodes.rs:14-24 — before extracting anything, compare `baml_language/crates/baml_compiler2_visualization/src/control_flow/flatten.rs` and `engine/baml-runtime/src/control_flow/flatten/step3_inline_implicit_nodes.rs` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 132 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (11 lines × 2) baml_language/crates/baml_compiler2_visualization/src/control_flow/flatten.rs:610— baml_language/crates/baml_compiler2_visualization/src/control_flow/flatten.rs:610-620 | engine/baml-runtime/src/control_flow/flatten/step3_inline_implicit_nodes.rs:98-108 — before extracting anything, compare `baml_language/crates/baml_compiler2_visualization/src/control_flow/flatten.rs` and `engine/baml-runtime/src/control_flow/flatten/step3_inline_implicit_nodes.rs` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 132 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (11 lines × 2) baml_language/crates/baml_compiler2_visualization/src/control_flow/from_ast.rs:1154— baml_language/crates/baml_compiler2_visualization/src/control_flow/from_ast.rs:1154-1164 | baml_language/crates/baml_compiler2_visualization/src/control_flow/from_ast.rs:1168-1178 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (11 lines × 2) baml_language/crates/baml_compiler_syntax/src/ast.rs:1224— baml_language/crates/baml_compiler_syntax/src/ast.rs:1224-1238 | baml_language/crates/baml_compiler_syntax/src/ast.rs:1262-1272 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_fmt/src/ast/declarations.rs:191— baml_language/crates/baml_fmt/src/ast/declarations.rs:191-201 | baml_language/crates/baml_fmt/src/ast/declarations.rs:1181-1191 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_fmt/src/ast/statements.rs:967— baml_language/crates/baml_fmt/src/ast/statements.rs:967-977 | baml_language/crates/baml_fmt/src/ast/statements.rs:1021-1031 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_ide/src/describe.rs:2043— baml_language/crates/baml_ide/src/describe.rs:2043-2053 | baml_language/crates/baml_ide/src/describe.rs:2105-2115 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_ide/src/usages.rs:131— baml_language/crates/baml_ide/src/usages.rs:131-141 | baml_language/crates/baml_ide/src/usages.rs:374-384 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (11 lines × 2) baml_language/crates/baml_query_btel/src/ingest.rs:717— baml_language/crates/baml_query_btel/src/ingest.rs:717-727 | baml_language/crates/baml_query_btel/src/ingest.rs:932-942 — both copies are in the same file, so extract the block into 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) baml_language/crates/bex_heap/src/gc.rs:366— baml_language/crates/bex_heap/src/gc.rs:366-376 | baml_language/crates/bex_heap/src/gc.rs:502-512 — both copies are in the same file, so extract the block into 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) baml_language/crates/bex_heap/src/gc.rs:477— baml_language/crates/bex_heap/src/gc.rs:477-487 | baml_language/crates/bex_heap/src/gc.rs:522-532 — both copies are in the same file, so extract the block into 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) baml_language/crates/bex_sap/src/deserializer/coercer/mod.rs:283— baml_language/crates/bex_sap/src/deserializer/coercer/mod.rs:283-293 | engine/baml-lib/jsonish/src/deserializer/coercer/mod.rs:97-107 — 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 (11 lines × 2) baml_language/crates/bex_sap/src/deserializer/coercer/mod.rs:459— baml_language/crates/bex_sap/src/deserializer/coercer/mod.rs:459-469 | engine/baml-lib/jsonish/src/deserializer/coercer/mod.rs:211-221 — 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 (11 lines × 2) baml_language/crates/bex_sap/src/deserializer/deserialize_flags.rs:128— baml_language/crates/bex_sap/src/deserializer/deserialize_flags.rs:128-138 | engine/baml-lib/jsonish/src/deserializer/deserialize_flags.rs:143-153 — before extracting anything, compare `baml_language/crates/bex_sap/src/deserializer/deserialize_flags.rs` and `engine/baml-lib/jsonish/src/deserializer/deserialize_flags.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 127 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (11 lines × 2) baml_language/crates/bex_sap/src/jsonish/parser/entry.rs:147— baml_language/crates/bex_sap/src/jsonish/parser/entry.rs:147-157 | engine/baml-lib/jsonish/src/jsonish/parser/entry.rs:156-166 — before extracting anything, compare `baml_language/crates/bex_sap/src/jsonish/parser/entry.rs` and `engine/baml-lib/jsonish/src/jsonish/parser/entry.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 55 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (11 lines × 2) baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser.rs:84— baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser.rs:84-94 | engine/baml-lib/jsonish/src/jsonish/parser/fixing_parser.rs:81-91 — 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 (11 lines × 2) baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs:137— baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs:137-147 | engine/baml-lib/jsonish/src/jsonish/parser/fixing_parser/json_parse_state.rs:142-152 — before extracting anything, compare `baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs` and `engine/baml-lib/jsonish/src/jsonish/parser/fixing_parser/json_parse_state.rs` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 575 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
ClassTooLong: InferenceContext baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:2064— ClassTooLong — 8129 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 308 methods, 3 blocks, lines 2064-15780. The bar is 400 significant lines; this is 7729 over it, 20.32× 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: LoweringContext baml_language/crates/baml_compiler2_mir/src/lower.rs:1711— ClassTooLong — 7928 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 302 methods, 15 blocks, lines 1711-14960. The bar is 400 significant lines; this is 7528 over it, 19.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: BexVm baml_language/crates/bex_vm/src/vm.rs:1779— ClassTooLong — 5899 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 416 methods, 4 blocks, lines 1779-12249. The bar is 400 significant lines; this is 5499 over it, 14.75× 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: LoweringContext baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:1526— ClassTooLong — 2991 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 116 methods, 2 blocks, lines 1526-6451. The bar is 400 significant lines; this is 2591 over it, 7.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: StackifyCodegen baml_language/crates/baml_compiler2_emit/src/emit.rs:213— ClassTooLong — 2111 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 78 methods, 5 blocks, lines 213-3682. The bar is 400 significant lines; this is 1711 over it, 5.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: TirTypeError baml_language/crates/baml_compiler2_hir_ty/src/diagnostics.rs:244— ClassTooLong — 1541 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, 2 blocks, lines 244-2749. The bar is 400 significant lines; this is 1141 over it, 3.85× 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: NormalTy baml_language/crates/baml_type/src/normalize.rs:1165— ClassTooLong — 1357 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 41 methods, 10 blocks, lines 682-3225. The bar is 400 significant lines; this is 957 over it, 3.39× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: SemanticIndexBuilder baml_language/crates/baml_compiler2_hir/src/builder.rs:62— ClassTooLong — 1292 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 50 methods, 2 blocks, lines 62-2097. The bar is 400 significant lines; this is 892 over it, 3.23× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: BamlRuntime engine/baml-runtime/src/lib.rs:422— ClassTooLong — 1282 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 39 methods, 8 blocks, lines 422-2235. The bar is 400 significant lines; this is 882 over it, 3.21× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: TelemetryState baml_language/crates/bex_vm/src/telemetry.rs:188— ClassTooLong — 979 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 64 methods. The bar is 400 significant lines; this is 579 over it, 2.45× 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: RunArgs baml_language/crates/baml_cli/src/run_command.rs:170— ClassTooLong — 969 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 35 methods, 3 blocks, lines 170-1742. The bar is 400 significant lines; this is 569 over it, 2.42× 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: DefaultIoOps baml_language/crates/sys_ops/src/lib.rs:1469— ClassTooLong — 959 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 0 methods, 27 blocks, lines 1471-2694. The bar is 400 significant lines; this is 559 over it, 2.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.
ClassTooLong: Bulk baml_language/crates/baml_query_btel/src/ingest/bulk.rs:391— ClassTooLong — 953 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 32 methods, 2 blocks, lines 391-1717. The bar is 400 significant lines; this is 553 over it, 2.38× 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: ConversionBuffer baml_language/crates/btel_recorder/src/lib.rs:58— ClassTooLong — 885 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, 3 blocks, lines 58-1132. The bar is 400 significant lines; this is 485 over it, 2.21× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: LowerCtx baml_language/crates/baml_compiler2_hir_ty/src/lower.rs:144— ClassTooLong — 883 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 46 methods, 2 blocks, lines 144-1643. The bar is 400 significant lines; this is 483 over it, 2.21× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: Applier baml_language/crates/baml_query_btel/src/ingest.rs:1019— ClassTooLong — 882 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 11 methods, 2 blocks, lines 1019-2044. The bar is 400 significant lines; this is 482 over it, 2.21× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: Translator baml_language/crates/baml_query_btel/src/sql.rs:126— ClassTooLong — 839 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 23 methods, 2 blocks, lines 126-1547. The bar is 400 significant lines; this is 439 over it, 2.10× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: BamlAsyncVmRuntime engine/baml-runtime/src/async_vm_runtime.rs:49— ClassTooLong — 808 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 20 methods, 5 blocks, lines 49-1471. The bar is 400 significant lines; this is 408 over it, 2.02× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: SpanRecord baml_language/crates/btel_records/src/lib.rs:107— ClassTooLong — 800 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 5 methods, 5 blocks, lines 45-1478. The bar is 400 significant lines; this is 400 over it, 2.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: Vm engine/baml-vm/src/vm.rs:186— ClassTooLong — 798 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 186-1842. The bar is 400 significant lines; this is 398 over it, 2.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: AwsClient engine/baml-runtime/src/internal/llm_client/primitive/aws/aws_client.rs:158— ClassTooLong — 789 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 15 methods, 9 blocks, lines 158-1500. The bar is 400 significant lines; this is 389 over it, 1.97× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: MonacoEditor typescript2/pkg-editor/src/MonacoEditor.tsx:1— ClassTooLong — 729 significant lines (blank, comment-only and punctuation-only lines excluded), 5 methods. The bar is 400 significant lines; this is 329 over it, 1.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: Hir2Diagnostic baml_language/crates/baml_compiler2_hir/src/diagnostic.rs:26— ClassTooLong — 724 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 1 methods, 2 blocks, lines 26-1069. The bar is 400 significant lines; this is 324 over it, 1.81× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: ImplResolver baml_language/crates/bex_vm/src/package_baml/resolve.rs:102— ClassTooLong — 701 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 35 methods, 4 blocks, lines 102-1330. The bar is 400 significant lines; this is 301 over it, 1.75× 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: BamlAsyncInterpreterRuntime engine/baml-runtime/src/async_interpreter_runtime.rs:51— ClassTooLong — 672 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 20 methods, 5 blocks, lines 51-1029. The bar is 400 significant lines; this is 272 over it, 1.68× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
+ 37 more in this group — see findings.md.
D30 · Dependency Vulnerabilities· Medium CVE · ×56
Duplicated block (13 lines × 2) baml_language/crates/baml_builtins2_codegen/src/extract.rs:141— baml_language/crates/baml_builtins2_codegen/src/extract.rs:141-153 | baml_language/crates/baml_builtins2_codegen/src/extract.rs:160-172 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:2290— baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:2290-2302 | baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:2553-2565 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:3915— baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:3915-3927 | baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:4145-4157 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:6278— baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:6278-6290 | baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:6362-6374 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:6982— baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:6982-6994 | baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:7079-7091 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler2_hir_ty/src/interfaces/impl_rules.rs:249— baml_language/crates/baml_compiler2_hir_ty/src/interfaces/impl_rules.rs:249-261 | baml_language/crates/baml_compiler2_hir_ty/src/interfaces/impl_rules.rs:293-305 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler2_hir_ty/src/lower.rs:1151— baml_language/crates/baml_compiler2_hir_ty/src/lower.rs:1151-1163 | baml_language/crates/baml_compiler2_hir_ty/src/lower.rs:1307-1319 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler2_visualization/src/control_flow/from_ast.rs:710— baml_language/crates/baml_compiler2_visualization/src/control_flow/from_ast.rs:710-722 | engine/baml-runtime/src/control_flow.rs:467-479 — before extracting anything, compare `baml_language/crates/baml_compiler2_visualization/src/control_flow/from_ast.rs` and `engine/baml-runtime/src/control_flow.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 69 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (13 lines × 2) baml_language/crates/baml_compiler_parser/src/parser.rs:366— baml_language/crates/baml_compiler_parser/src/parser.rs:366-378 | baml_language/crates/baml_compiler_parser/src/parser.rs:389-401 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler_parser/src/parser.rs:1523— baml_language/crates/baml_compiler_parser/src/parser.rs:1523-1535 | baml_language/crates/baml_compiler_parser/src/parser.rs:1718-1730 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (13 lines × 2) baml_language/crates/baml_fmt/src/ast/declarations.rs:238— baml_language/crates/baml_fmt/src/ast/declarations.rs:238-250 | baml_language/crates/baml_fmt/src/ast/interfaces.rs:98-110 — before extracting anything, compare `baml_language/crates/baml_fmt/src/ast/declarations.rs` and `baml_language/crates/baml_fmt/src/ast/interfaces.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 32 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (13 lines × 2) baml_language/crates/baml_fmt/src/ast/expressions.rs:4945— baml_language/crates/baml_fmt/src/ast/expressions.rs:4945-4957 | baml_language/crates/baml_fmt/src/ast/expressions.rs:5098-5110 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_lsp_server/src/lsp_ingress.rs:1505— baml_language/crates/baml_lsp_server/src/lsp_ingress.rs:1505-1517 | baml_language/crates/baml_lsp_server/src/lsp_ingress.rs:1519-1531 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_type/src/lib.rs:275— baml_language/crates/baml_type/src/lib.rs:275-287 | baml_language/crates/baml_type/src/lib.rs:337-349 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (13 lines × 2) baml_language/crates/baml_type/src/normalize.rs:2883— baml_language/crates/baml_type/src/normalize.rs:2883-2895 | baml_language/crates/baml_type/src/normalize.rs:3235-3247 — both copies are in the same file, so extract the block into 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) baml_language/crates/bex_events/src/history/mod.rs:175— baml_language/crates/bex_events/src/history/mod.rs:175-187 | baml_language/crates/bex_events/src/history/mod.rs:196-208 — both copies are in the same file, so extract the block into 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) baml_language/crates/bex_events/src/history/mod.rs:253— baml_language/crates/bex_events/src/history/mod.rs:253-265 | baml_language/crates/bex_events/src/history/mod.rs:294-306 — both copies are in the same file, so extract the block into 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) baml_language/crates/bex_sap/src/deserializer/coercer/array_helper.rs:361— baml_language/crates/bex_sap/src/deserializer/coercer/array_helper.rs:361-373 | engine/baml-lib/jsonish/src/deserializer/coercer/array_helper.rs:302-314 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (13 lines × 2) baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_collection.rs:38— baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_collection.rs:38-50 | engine/baml-lib/jsonish/src/jsonish/parser/fixing_parser/json_collection.rs:38-50 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (13 lines × 2) baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs:223— baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs:223-235 | engine/baml-lib/jsonish/src/jsonish/parser/fixing_parser/json_parse_state.rs:252-264 — before extracting anything, compare `baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs` and `engine/baml-lib/jsonish/src/jsonish/parser/fixing_parser/json_parse_state.rs` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 575 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (13 lines × 2) baml_language/crates/bex_vm/src/package_baml/array.rs:557— baml_language/crates/bex_vm/src/package_baml/array.rs:557-569 | baml_language/crates/bex_vm/src/package_baml/array.rs:599-611 — both copies are in the same file, so extract the block into 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) baml_language/crates/bex_vm/src/package_reflect/type_class.rs:1283— baml_language/crates/bex_vm/src/package_reflect/type_class.rs:1283-1295 | baml_language/crates/bex_vm/src/package_reflect/type_class.rs:1330-1342 — both copies are in the same file, so extract the block into 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) baml_language/crates/bex_vm_types/src/bytecode.rs:1870— baml_language/crates/bex_vm_types/src/bytecode.rs:1870-1882 | engine/baml-vm/src/bytecode.rs:287-299 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (13 lines × 2) baml_language/crates/bridge_wasm/src/wasm_io_fs.rs:415— baml_language/crates/bridge_wasm/src/wasm_io_fs.rs:415-427 | baml_language/crates/bridge_wasm/src/wasm_io_fs.rs:437-449 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (13 lines × 2) baml_language/sdks/cpp/sdkgen_cpp/src/lib.rs:1561— baml_language/sdks/cpp/sdkgen_cpp/src/lib.rs:1561-1573 | baml_language/sdks/cpp/sdkgen_cpp/src/lib.rs:1647-1659 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
baml_compiler2_hir_ty::interfaces::impl_rules::validate_impl_signatures (cognitive 112) baml_language/crates/baml_compiler2_hir_ty/src/interfaces/impl_rules.rs:1035— baml_compiler2_hir_ty::interfaces::impl_rules::validate_impl_signatures has cognitive complexity 112 (threshold 15). Drivers by points: if/else 30 (71 pts), loops 12 (27 pts), match/switch 5 (10 pts), boolean chains 4 (nesting depth added 61). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
baml_compiler2_hir_ty::interfaces::impl_rules::impl_data (cognitive 88) baml_language/crates/baml_compiler2_hir_ty/src/interfaces/impl_rules.rs:208— baml_compiler2_hir_ty::interfaces::impl_rules::impl_data has cognitive complexity 88 (threshold 15). Drivers by points: if/else 25 (57 pts), loops 8 (19 pts), boolean chains 9, match/switch 2 (3 pts) (nesting depth added 44). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
baml_compiler2_hir_ty::package_interface::validate_row_identities (cognitive 81) baml_language/crates/baml_compiler2_hir_ty/src/package_interface.rs:1021— baml_compiler2_hir_ty::package_interface::validate_row_identities has cognitive complexity 81 (threshold 15). Drivers by points: if/else 22 (48 pts), match/switch 7 (18 pts), loops 9 (12 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.
baml_compiler2_hir_ty::method_resolution::lookup_impl_member (cognitive 51) baml_language/crates/baml_compiler2_hir_ty/src/method_resolution.rs:492— baml_compiler2_hir_ty::method_resolution::lookup_impl_member has cognitive complexity 51 (threshold 15). Drivers by points: match/switch 7 (26 pts), if/else 11 (18 pts), boolean chains 4, loops 2 (3 pts) (nesting depth added 27). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own 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.
baml_compiler2_hir_ty::infer::trace_hooks::checked_declaration (cognitive 47) baml_language/crates/baml_compiler2_hir_ty/src/infer/trace_hooks.rs:60— baml_compiler2_hir_ty::infer::trace_hooks::checked_declaration has cognitive complexity 47 (threshold 15). Drivers by points: if/else 21 (32 pts), match/switch 5 (9 pts), boolean chains 3, loops 2 (3 pts) (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
baml_compiler2_hir_ty::defaults::collect_default_expr_forward_references (cognitive 46) baml_language/crates/baml_compiler2_hir_ty/src/defaults.rs:77— baml_compiler2_hir_ty::defaults::collect_default_expr_forward_references has cognitive complexity 46 (threshold 15). Drivers by points: if/else 10 (22 pts), loops 11 (22 pts), boolean chains 1, match/switch 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.
baml_compiler2_hir_ty::lower::interface_lowering_diagnostics (cognitive 42) baml_language/crates/baml_compiler2_hir_ty/src/lower.rs:2909— baml_compiler2_hir_ty::lower::interface_lowering_diagnostics has cognitive complexity 42 (threshold 15). Drivers by points: loops 15 (20 pts), if/else 9 (18 pts), match/switch 1 (3 pts), boolean chains 1 (nesting depth added 16). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
baml_compiler2_hir_ty::interfaces::impl_rules::first_failing_impl_bound (cognitive 38) baml_language/crates/baml_compiler2_hir_ty/src/interfaces/impl_rules.rs:2138— baml_compiler2_hir_ty::interfaces::impl_rules::first_failing_impl_bound has cognitive complexity 38 (threshold 15). Drivers by points: if/else 8 (27 pts), loops 4 (10 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.
baml_compiler2_hir_ty::infer::reachability::add_diagnostics (cognitive 32) baml_language/crates/baml_compiler2_hir_ty/src/infer/reachability.rs:17— baml_compiler2_hir_ty::infer::reachability::add_diagnostics has cognitive complexity 32 (threshold 15). Drivers by points: if/else 9 (25 pts), loops 3, boolean chains 2, match/switch 1 (2 pts) (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
baml_compiler2_hir_ty::impls::hash_eligible_within_depth::visit (cognitive 31) baml_language/crates/baml_compiler2_hir_ty/src/impls.rs:1532— baml_compiler2_hir_ty::impls::hash_eligible_within_depth::visit has cognitive complexity 31 (threshold 15). Drivers by points: if/else 15 (22 pts), boolean chains 8, match/switch 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.
baml_compiler2_hir_ty::method_resolution::union_arm_interfaces (cognitive 30) baml_language/crates/baml_compiler2_hir_ty/src/method_resolution.rs:1806— baml_compiler2_hir_ty::method_resolution::union_arm_interfaces has cognitive complexity 30 (threshold 15). Drivers by points: if/else 7 (19 pts), loops 5 (10 pts), match/switch 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.
baml_compiler2_hir_ty::infer::const_fold_binary (cognitive 29) baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:131— baml_compiler2_hir_ty::infer::const_fold_binary has cognitive complexity 29 (threshold 15). Drivers by points: match/switch 8 (15 pts), if/else 5 (12 pts), boolean chains 2 (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.
baml_compiler2_hir_ty::infer::infer_body_impl (cognitive 29) baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:1724— baml_compiler2_hir_ty::infer::infer_body_impl has cognitive complexity 29 (threshold 15). Drivers by points: if/else 8 (13 pts), match/switch 8 (13 pts), loops 1 (3 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
baml_compiler2_hir_ty::globals::strongly_connected_components (cognitive 28) baml_language/crates/baml_compiler2_hir_ty/src/globals.rs:385— baml_compiler2_hir_ty::globals::strongly_connected_components has cognitive complexity 28 (threshold 15). Drivers by points: if/else 7 (21 pts), loops 3 (7 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.
baml_compiler2_hir_ty::exhaustiveness::write_ty_identity (cognitive 26) baml_language/crates/baml_compiler2_hir_ty/src/exhaustiveness.rs:312— baml_compiler2_hir_ty::exhaustiveness::write_ty_identity has cognitive complexity 26 (threshold 15). Drivers by points: if/else 5 (15 pts), loops 5 (10 pts), match/switch 1 (nesting depth added 15). 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.
baml_compiler2_hir_ty::init_io::evaluated_calls_impl (cognitive 26) baml_language/crates/baml_compiler2_hir_ty/src/init_io.rs:141— baml_compiler2_hir_ty::init_io::evaluated_calls_impl has cognitive complexity 26 (threshold 15). Drivers by points: if/else 5 (12 pts), match/switch 4 (8 pts), loops 3 (4 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.
baml_compiler2_hir_ty::interfaces::realize_qualifier_through_roots (cognitive 26) baml_language/crates/baml_compiler2_hir_ty/src/interfaces.rs:2173— baml_compiler2_hir_ty::interfaces::realize_qualifier_through_roots has cognitive complexity 26 (threshold 15). Drivers by points: if/else 6 (19 pts), loops 3 (6 pts), boolean chains 1 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
baml_compiler2_hir_ty::lower::function_generic_bounds (cognitive 26) baml_language/crates/baml_compiler2_hir_ty/src/lower.rs:2177— baml_compiler2_hir_ty::lower::function_generic_bounds has cognitive complexity 26 (threshold 15). Drivers by points: if/else 4 (12 pts), loops 5 (11 pts), match/switch 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.
baml_compiler2_hir_ty::exhaustiveness::compute_exhaustiveness (cognitive 25) baml_language/crates/baml_compiler2_hir_ty/src/exhaustiveness.rs:1277— baml_compiler2_hir_ty::exhaustiveness::compute_exhaustiveness has cognitive complexity 25 (threshold 15). Drivers by points: if/else 9 (18 pts), loops 3 (7 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
baml_compiler2_hir_ty::exhaustiveness::split_ctors (cognitive 24) baml_language/crates/baml_compiler2_hir_ty/src/exhaustiveness.rs:1388— baml_compiler2_hir_ty::exhaustiveness::split_ctors has cognitive complexity 24 (threshold 15). Drivers by points: if/else 15 (22 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.
baml_compiler2_hir_ty::interfaces::resolve_through_roots (cognitive 24) baml_language/crates/baml_compiler2_hir_ty/src/interfaces.rs:2369— baml_compiler2_hir_ty::interfaces::resolve_through_roots has cognitive complexity 24 (threshold 15). Drivers by points: if/else 7 (17 pts), loops 3 (6 pts), match/switch 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.
baml_compiler2_hir_ty::method_resolution::lookup_interface_member (cognitive 24) baml_language/crates/baml_compiler2_hir_ty/src/method_resolution.rs:350— baml_compiler2_hir_ty::method_resolution::lookup_interface_member has cognitive complexity 24 (threshold 15). Drivers by points: if/else 7 (16 pts), loops 3 (6 pts), boolean chains 1, match/switch 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.
baml_compiler2_hir_ty::method_resolution::member_candidates (cognitive 24) baml_language/crates/baml_compiler2_hir_ty/src/method_resolution.rs:1301— baml_compiler2_hir_ty::method_resolution::member_candidates has cognitive complexity 24 (threshold 15). Drivers by points: loops 8 (17 pts), if/else 3 (5 pts), boolean chains 1, match/switch 1 (nesting depth added 11). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
baml_compiler2_hir_ty::impls::impls_for_type_cached (cognitive 23) baml_language/crates/baml_compiler2_hir_ty/src/impls.rs:1231— baml_compiler2_hir_ty::impls::impls_for_type_cached has cognitive complexity 23 (threshold 15). Drivers by points: if/else 6 (16 pts), boolean chains 4, loops 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.
baml_compiler2_hir_ty::interfaces::match_ty_pattern_into (cognitive 23) baml_language/crates/baml_compiler2_hir_ty/src/interfaces.rs:972— baml_compiler2_hir_ty::interfaces::match_ty_pattern_into has cognitive complexity 23 (threshold 15). Drivers by points: if/else 5 (8 pts), loops 4 (8 pts), boolean chains 6, match/switch 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.
+ 19 more in this group — see findings.md.
R4 · Test Coverage· No test reaches this file · ×40
No test reaches this file typescript2/pkg-grammar/src/baml.ts:1— No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
No test reaches this file typescript2/app-website/components/icons.tsx:1— No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
No test reaches this file REDACTED:1— No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
No test reaches this file typescript2/app-website/components/landing/vs-client.tsx:1— No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
No test reaches this file typescript2/pkg-grammar-treesitter/grammar.js:1— No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
No test reaches this file typescript2/app-website/app/baml-intro/_components/article.tsx:1— No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
No test reaches this file typescript2/app-website/components/landing/incremental-adoption.tsx:1— No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
No test reaches this file typescript2/app-website/app/learn4/_components/story.tsx:1— No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
No test reaches this file typescript2/app-website/lib/mdx/bfcl/_components/TestResultsTable.tsx:1— No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
No test reaches this file typescript2/app-beps/src/components/bep/bep-route-shell.tsx:1— No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
No test reaches this file typescript2/app-promptfiddle/src/playground/baml-lsp-worker.ts:1— No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
No test reaches this file typescript/apps/vscode-ext/src/plugins/language-server-client/index.ts:1— No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
No test reaches this file typescript2/app-website/app/learn2/_deck/slides.tsx:1— No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
No test reaches this file typescript2/app-beps/src/lib/export-utils.ts:1— No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
No test reaches this file typescript2/app-beps/src/components/comments/comment-feed-view.tsx:1— No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
No test reaches this file typescript2/app-beps/src/components/comments/comment-sidebar.tsx:1— No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
No test reaches this file typescript2/app-website/components/landing/variant-home.tsx:1— No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
No test reaches this file typescript2/app-website/app/learn3/_deck/slides.tsx:1— No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
No test reaches this file typescript2/app-website/playground/baml-worker.ts:1— No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
No test reaches this file typescript2/app-beps/convex/beps.ts:1— No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
No test reaches this file typescript2/app-type-quiz/src/app.tsx:1— No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
No test reaches this file typescript2/app-website/app/what-is-baml/page.tsx:1— No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
No test reaches this file typescript2/app-beps/src/lib/export-all-utils.ts:1— No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
No test reaches this file typescript2/app-website/app/baml-intro/_components/TenetsAccordion.tsx:1— No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
No test reaches this file typescript2/app-beps/src/lib/static/bep-script.ts:1— No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
LoweringContext::lower_call_with_callee (cognitive 150) baml_language/crates/baml_compiler2_mir/src/lower.rs:8243— LoweringContext::lower_call_with_callee has cognitive complexity 150 (threshold 15). Drivers by points: if/else 60 (103 pts), match/switch 14 (36 pts), boolean chains 11 (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.
LoweringContext::try_lower_as_switch (cognitive 114) baml_language/crates/baml_compiler2_mir/src/lower.rs:12653— LoweringContext::try_lower_as_switch has cognitive complexity 114 (threshold 15). Drivers by points: if/else 32 (69 pts), match/switch 12 (28 pts), loops 5 (11 pts), boolean chains 6 (nesting depth added 59). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
LoweringContext::lower_pattern_test_with_catch_policy (cognitive 87) baml_language/crates/baml_compiler2_mir/src/lower.rs:13859— LoweringContext::lower_pattern_test_with_catch_policy has cognitive complexity 87 (threshold 15). Drivers by points: if/else 37 (74 pts), loops 4 (9 pts), match/switch 2 (3 pts), boolean chains 1 (nesting depth added 43). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
LoweringContext::lower_path_expr (cognitive 69) baml_language/crates/baml_compiler2_mir/src/lower.rs:6431— LoweringContext::lower_path_expr has cognitive complexity 69 (threshold 15). Drivers by points: if/else 25 (59 pts), match/switch 3 (6 pts), boolean chains 4 (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.
LoweringContext::lower_stmt (cognitive 61) baml_language/crates/baml_compiler2_mir/src/lower.rs:11823— LoweringContext::lower_stmt has cognitive complexity 61 (threshold 15). Drivers by points: if/else 29 (48 pts), match/switch 6 (11 pts), loops 1 (2 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.
LoweringContext::lower_object_literal (cognitive 59) baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:5376— LoweringContext::lower_object_literal has cognitive complexity 59 (threshold 15). Drivers by points: if/else 13 (33 pts), match/switch 5 (15 pts), loops 5 (7 pts), boolean chains 4 (nesting depth added 32). Of this number, 56 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.
LoweringContext::lower_match_arm (cognitive 52) baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:2870— LoweringContext::lower_match_arm has cognitive complexity 52 (threshold 15). Drivers by points: match/switch 6 (24 pts), if/else 4 (15 pts), boolean chains 7, loops 2 (6 pts) (nesting depth added 33). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own 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.
LoweringContext::lower_multi_segment_path_as_field_chain (cognitive 37) baml_language/crates/baml_compiler2_mir/src/lower.rs:6810— LoweringContext::lower_multi_segment_path_as_field_chain has cognitive complexity 37 (threshold 15). Drivers by points: if/else 15 (30 pts), match/switch 2 (4 pts), boolean chains 2, loops 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.
LoweringContext::lower_binary_expr (cognitive 34) baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:2210— LoweringContext::lower_binary_expr has cognitive complexity 34 (threshold 15). Drivers by points: if/else 10 (24 pts), match/switch 3 (9 pts), loops 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.
LoweringContext::lower_lvalue (cognitive 33) baml_language/crates/baml_compiler2_mir/src/lower.rs:12283— LoweringContext::lower_lvalue has cognitive complexity 33 (threshold 15). Drivers by points: if/else 13 (27 pts), match/switch 2 (4 pts), loops 1 (2 pts) (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.
LoweringContext::lower_block_expr (cognitive 32) baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:1826— LoweringContext::lower_block_expr has cognitive complexity 32 (threshold 15). Drivers by points: if/else 9 (21 pts), match/switch 3 (8 pts), boolean chains 2, loops 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.
LoweringContext::lower_spawn_expr (cognitive 29) baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:2041— LoweringContext::lower_spawn_expr has cognitive complexity 29 (threshold 15). Drivers by points: if/else 9 (18 pts), match/switch 3 (9 pts), loops 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.
LoweringContext::check_intrinsic (cognitive 29) baml_language/crates/baml_compiler2_mir/src/lower.rs:9226— LoweringContext::check_intrinsic has cognitive complexity 29 (threshold 15). Drivers by points: if/else 9 (18 pts), match/switch 3 (9 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.
LoweringContext::lower_match_chain (cognitive 29) baml_language/crates/baml_compiler2_mir/src/lower.rs:13086— LoweringContext::lower_match_chain has cognitive complexity 29 (threshold 15). Drivers by points: if/else 14 (25 pts), boolean chains 2, 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.
LoweringContext::lower_member_access (cognitive 28) baml_language/crates/baml_compiler2_mir/src/lower.rs:10383— LoweringContext::lower_member_access has cognitive complexity 28 (threshold 15). Drivers by points: if/else 14 (24 pts), match/switch 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.
LoweringContext::lower_let_parts (cognitive 27) baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:5764— LoweringContext::lower_let_parts has cognitive complexity 27 (threshold 15). Drivers by points: if/else 6 (17 pts), match/switch 2 (5 pts), boolean chains 4, 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.
LoweringContext::callee_builtin_kind (cognitive 27) baml_language/crates/baml_compiler2_mir/src/lower.rs:9076— LoweringContext::callee_builtin_kind has cognitive complexity 27 (threshold 15). Drivers by points: if/else 12 (24 pts), match/switch 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.
LoweringContext::lower_match_expr (cognitive 26) baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:2798— LoweringContext::lower_match_expr has cognitive complexity 26 (threshold 15). Drivers by points: match/switch 4 (14 pts), if/else 3 (11 pts), loops 1 (nesting depth added 18). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own 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.
LoweringContext::sys_op_callee (cognitive 26) baml_language/crates/baml_compiler2_mir/src/lower.rs:8994— LoweringContext::sys_op_callee has cognitive complexity 26 (threshold 15). Drivers by points: if/else 11 (23 pts), match/switch 1 (3 pts) (nesting depth added 14). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function. This shape REPEATS in the file: one other method here (LoweringContext::sys_op_synthetic_type_arg_count) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
LoweringContext::sys_op_synthetic_type_arg_count (cognitive 26) baml_language/crates/baml_compiler2_mir/src/lower.rs:9138— LoweringContext::sys_op_synthetic_type_arg_count has cognitive complexity 26 (threshold 15). Drivers by points: if/else 11 (23 pts), match/switch 1 (3 pts) (nesting depth added 14). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function. This shape REPEATS in the file: one other method here (LoweringContext::sys_op_callee) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
LoweringContext::lower_for_stmt (cognitive 24) baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:6067— LoweringContext::lower_for_stmt has cognitive complexity 24 (threshold 15). Drivers by points: if/else 6 (14 pts), match/switch 2 (5 pts), boolean chains 4, 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.
LoweringContext::lower_is_expr (cognitive 22) baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:2347— LoweringContext::lower_is_expr has cognitive complexity 22 (threshold 15). Drivers by points: match/switch 4 (14 pts), if/else 2 (7 pts), loops 1 (nesting depth added 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
LoweringContext::lower_catch_arm (cognitive 22) baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:3378— LoweringContext::lower_catch_arm has cognitive complexity 22 (threshold 15). Drivers by points: match/switch 6 (14 pts), boolean chains 7, 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.
LoweringContext::lower_function_body (cognitive 21) baml_language/crates/baml_compiler2_mir/src/lower.rs:4534— LoweringContext::lower_function_body has cognitive complexity 21 (threshold 15). Drivers by points: if/else 11 (16 pts), boolean chains 2, match/switch 2, loops 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
LoweringContext::lower_lambda (cognitive 20) baml_language/crates/baml_compiler2_mir/src/lower.rs:4965— LoweringContext::lower_lambda has cognitive complexity 20 (threshold 15). Drivers by points: if/else 12 (16 pts), loops 3, match/switch 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.
Duplicated block (14 lines × 2) baml_language/crates/baml_compiler2_ast/src/lower_cst.rs:2357— baml_language/crates/baml_compiler2_ast/src/lower_cst.rs:2357-2370 | baml_language/crates/baml_compiler2_ast/src/lower_cst.rs:2374-2387 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:4948— baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:4948-4961 | baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:4973-4986 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler2_emit/src/stack_carry.rs:1084— baml_language/crates/baml_compiler2_emit/src/stack_carry.rs:1084-1097 | baml_language/crates/baml_compiler2_emit/src/stack_carry.rs:1124-1137 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs:712— baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs:712-725 | baml_language/crates/baml_type/src/unify.rs:1240-1253 — before extracting anything, compare `baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs` and `baml_language/crates/baml_type/src/unify.rs` as WHOLE FILES: this scan already matched 21 separate duplicated blocks between them, totalling at least 418 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, 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 × 2) baml_language/crates/baml_compiler2_hir_ty/src/impls.rs:229— baml_language/crates/baml_compiler2_hir_ty/src/impls.rs:229-242 | baml_language/crates/baml_compiler2_hir_ty/src/impls.rs:267-280 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler2_hir_ty/src/impls.rs:885— baml_language/crates/baml_compiler2_hir_ty/src/impls.rs:885-898 | baml_language/crates/baml_compiler2_hir_ty/src/impls.rs:974-987 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:7485— baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:7485-7498 | baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:7584-7597 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler2_hir_ty/src/lower.rs:2259— baml_language/crates/baml_compiler2_hir_ty/src/lower.rs:2259-2272 | baml_language/crates/baml_compiler2_hir_ty/src/lower.rs:2323-2336 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler_parser/src/parser.rs:2074— baml_language/crates/baml_compiler_parser/src/parser.rs:2074-2087 | baml_language/crates/baml_compiler_parser/src/parser.rs:2148-2161 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (14 lines × 2) baml_language/crates/baml_compiler_parser/src/parser.rs:4113— baml_language/crates/baml_compiler_parser/src/parser.rs:4113-4126 | baml_language/crates/baml_compiler_parser/src/parser.rs:4215-4228 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (14 lines × 2) baml_language/crates/baml_lsp_server/src/playground_server.rs:1567— baml_language/crates/baml_lsp_server/src/playground_server.rs:1567-1580 | baml_language/crates/baml_lsp_server/src/playground_server.rs:1671-1684 — both copies are in the same file, so extract the block into 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) baml_language/crates/bex_engine/src/telemetry.rs:273— baml_language/crates/bex_engine/src/telemetry.rs:273-286 | baml_language/crates/bex_engine/src/telemetry.rs:362-375 — both copies are in the same file, so extract the block into 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) baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs:99— baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs:99-112 | engine/baml-lib/jsonish/src/jsonish/parser/fixing_parser/json_parse_state.rs:104-117 — before extracting anything, compare `baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs` and `engine/baml-lib/jsonish/src/jsonish/parser/fixing_parser/json_parse_state.rs` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 575 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, 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 × 2) baml_language/crates/bex_sap/src/jsonish/parser/multi_json_parser.rs:31— baml_language/crates/bex_sap/src/jsonish/parser/multi_json_parser.rs:31-44 | engine/baml-lib/jsonish/src/jsonish/parser/multi_json_parser.rs:30-43 — 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) baml_language/crates/bex_vm/src/vm.rs:5582— baml_language/crates/bex_vm/src/vm.rs:5582-5595 | baml_language/crates/bex_vm/src/vm.rs:5697-5710 — both copies are in the same file, so extract the block into 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) baml_language/crates/bex_vm/src/vm.rs:11793— baml_language/crates/bex_vm/src/vm.rs:11793-11806 | baml_language/crates/bex_vm/src/vm.rs:11814-11827 — both copies are in the same file, so extract the block into 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) baml_language/crates/bex_vm_types/src/indexable.rs:92— baml_language/crates/bex_vm_types/src/indexable.rs:92-105 | engine/baml-vm/src/indexable.rs:67-80 — 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) baml_language/crates/bridge_ctypes/src/value_encode.rs:110— baml_language/crates/bridge_ctypes/src/value_encode.rs:110-123 | baml_language/crates/bridge_ctypes/src/value_encode.rs:315-328 — both copies are in the same file, so extract the block into 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) baml_language/crates/bridge_wasm/src/wasm_random.rs:24— baml_language/crates/bridge_wasm/src/wasm_random.rs:24-37 | baml_language/crates/sys_native/src/io_impls.rs:223-236 — 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) baml_language/crates/sys_types/src/sse.rs:64— baml_language/crates/sys_types/src/sse.rs:64-77 | baml_language/crates/sys_types/src/sse.rs:130-143 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (14 lines × 2) baml_language/sdks/csharp/sdkgen_csharp/src/semantic.rs:3738— baml_language/sdks/csharp/sdkgen_csharp/src/semantic.rs:3738-3751 | baml_language/sdks/csharp/sdkgen_csharp/src/semantic.rs:3859-3872 — both copies are in the same file, so extract the block into 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) baml_language/sdks/python/rust/sdkgen_python_pydantic2/src/leaf.rs:1299— baml_language/sdks/python/rust/sdkgen_python_pydantic2/src/leaf.rs:1299-1312 | baml_language/sdks/python/rust/sdkgen_python_pydantic2/src/leaf.rs:2204-2217 — both copies are in the same file, so extract the block into 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) engine/baml-lib/jinja/src/evaluate_type/pretty_print.rs:78— engine/baml-lib/jinja/src/evaluate_type/pretty_print.rs:78-91 | engine/baml-lib/jinja/src/evaluate_type/pretty_print.rs:96-109 — both copies are in the same file, so extract the block into 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) engine/baml-lib/jsonish/src/deserializer/coercer/coerce_array.rs:50— engine/baml-lib/jsonish/src/deserializer/coercer/coerce_array.rs:50-66 | engine/baml-lib/jsonish/src/deserializer/coercer/coerce_map.rs:39-52 — 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 (14 lines × 2) engine/baml-lib/jsonish/src/deserializer/coercer/coerce_array.rs:83— engine/baml-lib/jsonish/src/deserializer/coercer/coerce_array.rs:83-96 | engine/baml-lib/jsonish/src/deserializer/coercer/coerce_map.rs:69-82 — 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.
TooManyMethods: BexVm baml_language/crates/bex_vm/src/vm.rs:1779— TooManyMethods — 416 methods, declared across 17 files: src/vm.rs (229), compiled_rt/record.rs (43), compiled_rt/call.rs (24), vm/error_evidence.rs (18), +13 more file(s). The bar is 30 methods; this is 386 over it, 13.87× 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: InferenceContext baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:2064— TooManyMethods — 308 methods, declared across 5 files: src/infer.rs (236), infer/pat.rs (29), infer/obligations.rs (22), infer/flow.rs (15), +1 more file(s). The bar is 30 methods; this is 278 over it, 10.27× 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: LoweringContext baml_language/crates/baml_compiler2_mir/src/lower.rs:1711— TooManyMethods — 302 methods. The bar is 30 methods; this is 272 over it, 10.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: Parser baml_language/crates/baml_compiler_parser/src/parser.rs:246— TooManyMethods — 270 methods. The bar is 30 methods; this is 240 over it, 9.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.
TooManyMethods: BexEngine baml_language/crates/bex_engine/src/lib.rs:1099— TooManyMethods — 158 methods, declared across 6 files: src/lib.rs (104), src/conversion.rs (29), src/telemetry.rs (14), src/host_instrumentation.rs (4), +2 more file(s). The bar is 30 methods; this is 128 over it, 5.27× 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: LoweringContext baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:1526— TooManyMethods — 116 methods. The bar is 30 methods; this is 86 over it, 3.87× 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: BexHeap baml_language/crates/bex_heap/src/heap.rs:158— TooManyMethods — 112 methods, declared across 5 files: src/heap.rs (61), src/gc.rs (24), heap_debugger/real.rs (18), src/functions.rs (7), +1 more file(s). 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: StackifyCodegen baml_language/crates/baml_compiler2_emit/src/emit.rs:213— TooManyMethods — 78 methods. The bar is 30 methods; this is 48 over it, 2.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: BamlFfi baml_language/sdks/java/baml_bridge/src/main/java/baml_bridge/BamlFfi.java:46— 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: TelemetryState baml_language/crates/bex_vm/src/telemetry.rs:188— TooManyMethods — 64 methods, declared across 2 files: src/telemetry.rs (57), telemetry/host.rs (7). The bar is 30 methods; this is 34 over it, 2.13× 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: ProtoReader baml_language/sdks/java/baml_bridge/src/main/java/baml_bridge/internal/ProtoReader.java:47— 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: GlobalState baml_language/crates/baml_lsp/src/state.rs:353— TooManyMethods — 60 methods, declared across 5 files: src/state.rs (49), dispatch/events.rs (5), dispatch/mod.rs (3), src/discovery.rs (2), +1 more file(s). The bar is 30 methods; this is 30 over it, 2.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: DatamodelError engine/baml-lib/diagnostics/src/error.rs:11— TooManyMethods — 59 methods. The bar is 30 methods; this is 29 over it, 1.97× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: PrimitiveProtocol baml_language/sdks/csharp/bridge_csharp/src/Proto/PrimitiveProtocol.cs— TooManyMethods — 926 significant lines (blank, comment-only and punctuation-only lines excluded), 51 methods. The bar is 30 methods; this is 21 over it, 1.70× the bar. The type holds no instance state, so there is no shared data to group its members by. To reduce it, split it by area instead: give each cohesive family of members its own smaller type, so no one type has to be read whole to change one of them.
TooManyMethods: BamlType baml_language/sdks/java/baml_bridge/src/main/java/baml_bridge/BamlType.java:74— TooManyMethods — 50 methods. The bar is 30 methods; this is 20 over it, 1.67× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: SemanticIndexBuilder baml_language/crates/baml_compiler2_hir/src/builder.rs:62— TooManyMethods — 50 methods. The bar is 30 methods; this is 20 over it, 1.67× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: MirBuilder baml_language/crates/baml_compiler2_mir/src/builder.rs:38— 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: TypeBuilder engine/baml-runtime/src/type_builder/mod.rs:491— TooManyMethods — 47 methods, declared across 4 files: type_builder/mod.rs (15), types/type_builder.rs (15), raw_objects/type_builder.rs (11), types/type_builder.rs (6). The bar is 30 methods; this is 17 over it, 1.57× 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: LowerCtx baml_language/crates/baml_compiler2_hir_ty/src/lower.rs:144— TooManyMethods — 46 methods. The bar is 30 methods; this is 16 over it, 1.53× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: CacheContext baml_language/crates/baml_cli/src/bytecode_cache.rs:74— TooManyMethods — 44 methods. The bar is 30 methods; this is 14 over it, 1.47× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: Ty baml_language/crates/baml_type/src/interned.rs:100— TooManyMethods — 44 methods, declared across 2 files: src/interned.rs (23), src/lib.rs (21). The bar is 30 methods; this is 14 over it, 1.47× 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: IntermediateRepr engine/baml-lib/baml-core/src/ir/repr.rs:40— 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: NormalTy baml_language/crates/baml_type/src/normalize.rs:1165— TooManyMethods — 41 methods. The bar is 30 methods; this is 11 over it, 1.37× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: TypeGeneric engine/baml-lib/baml-types/src/ir_type/mod.rs:26— TooManyMethods — 40 methods, declared across 4 files: ir_type/builder.rs (22), ir_type/mod.rs (14), ir_type/union_type.rs (3), simplify/ir.rs (1). The bar is 30 methods; this is 10 over it, 1.33× 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: ParserDatabase engine/baml-lib/parser-database/src/lib.rs:78— TooManyMethods — 40 methods, declared across 2 files: walkers/mod.rs (30), src/lib.rs (10). The bar is 30 methods; this is 10 over it, 1.33× 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.
bex_vm::package_baml::csv::scan_record (cognitive 100) baml_language/crates/bex_vm/src/package_baml/csv.rs:855— bex_vm::package_baml::csv::scan_record has cognitive complexity 100 (threshold 15). Drivers by points: if/else 31 (85 pts), boolean chains 11, match/switch 1 (3 pts), loops 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.
bex_vm::package_baml::root::render_to_sink (cognitive 76) baml_language/crates/bex_vm/src/package_baml/root.rs:523— bex_vm::package_baml::root::render_to_sink has cognitive complexity 76 (threshold 15). Drivers by points: if/else 27 (61 pts), loops 3 (7 pts), match/switch 5 (7 pts), boolean chains 1 (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.
bex_vm::package_baml::csv::poll_record (cognitive 57) baml_language/crates/bex_vm/src/package_baml/csv.rs:1211— bex_vm::package_baml::csv::poll_record has cognitive complexity 57 (threshold 15). Drivers by points: if/else 16 (41 pts), match/switch 3 (9 pts), loops 2 (7 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.
bex_vm::package_baml::json::copy_json (cognitive 50) baml_language/crates/bex_vm/src/package_baml/json/mod.rs:273— bex_vm::package_baml::json::copy_json has cognitive complexity 50 (threshold 15). Drivers by points: if/else 9 (27 pts), match/switch 6 (18 pts), loops 3 (5 pts) (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.
bex_vm::package_baml::json::path::select (cognitive 46) baml_language/crates/bex_vm/src/package_baml/json/path.rs:14— bex_vm::package_baml::json::path::select has cognitive complexity 46 (threshold 15). Drivers by points: if/else 12 (32 pts), loops 4 (9 pts), boolean chains 5 (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.
bex_vm::package_baml::sap::empty_value (cognitive 37) baml_language/crates/bex_vm/src/package_baml/sap.rs:1567— bex_vm::package_baml::sap::empty_value has cognitive complexity 37 (threshold 15). Drivers by points: if/else 12 (26 pts), match/switch 3 (6 pts), loops 2 (5 pts) (nesting depth added 20). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
bex_vm::package_reflect::graft::relocate (cognitive 37) baml_language/crates/bex_vm/src/package_reflect/graft.rs:1172— bex_vm::package_reflect::graft::relocate has cognitive complexity 37 (threshold 15). Drivers by points: if/else 8 (16 pts), match/switch 7 (13 pts), loops 4 (8 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.
bex_vm::package_reflect::type_class::expanded_type_value_nominals (cognitive 36) baml_language/crates/bex_vm/src/package_reflect/type_class.rs:1170— bex_vm::package_reflect::type_class::expanded_type_value_nominals has cognitive complexity 36 (threshold 15). Drivers by points: if/else 7 (21 pts), loops 7 (14 pts), match/switch 1 (nesting depth added 21). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
bex_vm::package_baml::csv::decode_record_to_instance (cognitive 34) baml_language/crates/bex_vm/src/package_baml/csv.rs:1560— bex_vm::package_baml::csv::decode_record_to_instance has cognitive complexity 34 (threshold 15). Drivers by points: if/else 9 (23 pts), match/switch 5 (10 pts), loops 1 (nesting depth added 19). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
bex_vm::package_reflect::type_class::render_type_value_source (cognitive 34) baml_language/crates/bex_vm/src/package_reflect/type_class.rs:1240— bex_vm::package_reflect::type_class::render_type_value_source has cognitive complexity 34 (threshold 15). Drivers by points: if/else 13 (24 pts), loops 5 (7 pts), match/switch 2 (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.
bex_vm::call_specialize::specialize_calls (cognitive 33) baml_language/crates/bex_vm/src/call_specialize.rs:7— bex_vm::call_specialize::specialize_calls has cognitive complexity 33 (threshold 15). Drivers by points: if/else 6 (21 pts), match/switch 3 (5 pts), loops 3 (4 pts), boolean chains 3 (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.
bex_vm::package_baml::csv::parse_reader_options (cognitive 33) baml_language/crates/bex_vm/src/package_baml/csv.rs:371— bex_vm::package_baml::csv::parse_reader_options has cognitive complexity 33 (threshold 15). Drivers by points: if/else 20 (23 pts), match/switch 5 (10 pts) (nesting depth added 8). 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.
bex_vm::package_reflect::runtime_class_builder::prepare_group (cognitive 33) baml_language/crates/bex_vm/src/package_reflect/runtime_class_builder.rs:636— bex_vm::package_reflect::runtime_class_builder::prepare_group has cognitive complexity 33 (threshold 15). Drivers by points: if/else 9 (19 pts), match/switch 3 (11 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.
bex_vm::debug::display_bytecode_textual (cognitive 32) baml_language/crates/bex_vm/src/debug.rs:669— bex_vm::debug::display_bytecode_textual has cognitive complexity 32 (threshold 15). Drivers by points: if/else 8 (24 pts), loops 3 (6 pts), match/switch 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.
bex_vm::package_reflect::type_kinds::validate_witness_states (cognitive 30) baml_language/crates/bex_vm/src/package_reflect/type_kinds.rs:223— bex_vm::package_reflect::type_kinds::validate_witness_states has cognitive complexity 30 (threshold 15). Drivers by points: if/else 6 (16 pts), loops 5 (7 pts), match/switch 3 (7 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.
bex_vm::debug::display_bytecode (cognitive 28) baml_language/crates/bex_vm/src/debug.rs:537— bex_vm::debug::display_bytecode has cognitive complexity 28 (threshold 15). Drivers by points: if/else 7 (14 pts), loops 5 (9 pts), match/switch 1 (4 pts), boolean chains 1 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
bex_vm::package_baml::csv::convert_cell (cognitive 28) baml_language/crates/bex_vm/src/package_baml/csv.rs:1426— bex_vm::package_baml::csv::convert_cell has cognitive complexity 28 (threshold 15). Drivers by points: match/switch 9 (17 pts), if/else 6 (10 pts), boolean chains 1 (nesting depth added 12). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own 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.
bex_vm::debug::display_instruction_textual (cognitive 24) baml_language/crates/bex_vm/src/debug.rs:756— bex_vm::debug::display_instruction_textual has cognitive complexity 24 (threshold 15). Drivers by points: if/else 9 (14 pts), match/switch 3 (7 pts), loops 1 (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.
bex_vm::package_reflect::runtime_class_builder::planned_pending_type (cognitive 23) baml_language/crates/bex_vm/src/package_reflect/runtime_class_builder.rs:810— bex_vm::package_reflect::runtime_class_builder::planned_pending_type has cognitive complexity 23 (threshold 15). Drivers by points: if/else 10 (18 pts), match/switch 2 (3 pts), boolean chains 2 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
bex_vm::package_reflect::runtime_class_builder::resolve_pending_if_ready (cognitive 23) baml_language/crates/bex_vm/src/package_reflect/runtime_class_builder.rs:1063— bex_vm::package_reflect::runtime_class_builder::resolve_pending_if_ready has cognitive complexity 23 (threshold 15). Drivers by points: if/else 7 (14 pts), match/switch 3 (6 pts), loops 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.
bex_vm::package_baml::csv::encode_cell_into (cognitive 21) baml_language/crates/bex_vm/src/package_baml/csv.rs:1786— bex_vm::package_baml::csv::encode_cell_into has cognitive complexity 21 (threshold 15). Drivers by points: if/else 6 (12 pts), loops 2 (4 pts), boolean chains 3, match/switch 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.
bex_vm::package_baml::csv::ensure_preamble (cognitive 20) baml_language/crates/bex_vm/src/package_baml/csv.rs:1090— bex_vm::package_baml::csv::ensure_preamble has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (16 pts), match/switch 1 (2 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.
bex_vm::package_reflect::type_class::first_open_interface (cognitive 20) baml_language/crates/bex_vm/src/package_reflect/type_class.rs:844— bex_vm::package_reflect::type_class::first_open_interface has cognitive complexity 20 (threshold 15). Drivers by points: if/else 6 (16 pts), loops 1 (2 pts), boolean chains 1, match/switch 1 (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.
bex_vm::package_load::fill_package_slots (cognitive 19) baml_language/crates/bex_vm/src/package_load.rs:460— bex_vm::package_load::fill_package_slots has cognitive complexity 19 (threshold 15). Drivers by points: loops 6 (11 pts), if/else 2 (5 pts), match/switch 1 (3 pts) (nesting depth added 10). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
bex_vm::package_reflect::runtime_class_builder::validate_pending::walk (cognitive 19) baml_language/crates/bex_vm/src/package_reflect/runtime_class_builder.rs:758— bex_vm::package_reflect::runtime_class_builder::validate_pending::walk has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (13 pts), boolean chains 3, loops 1 (2 pts), match/switch 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.
Parser::parse_expr_bp (cognitive 67) baml_language/crates/baml_compiler_parser/src/parser.rs:6603— Parser::parse_expr_bp has cognitive complexity 67 (threshold 15). Drivers by points: if/else 32 (54 pts), boolean chains 12, loops 1 (nesting depth added 22). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Parser::parse_object_literal_fields (cognitive 44) baml_language/crates/baml_compiler_parser/src/parser.rs:8074— Parser::parse_object_literal_fields has cognitive complexity 44 (threshold 15). Drivers by points: if/else 13 (39 pts), boolean chains 4, loops 1 (nesting depth added 26). 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.
Parser::parse_primary_expr (cognitive 41) baml_language/crates/baml_compiler_parser/src/parser.rs:7149— Parser::parse_primary_expr has cognitive complexity 41 (threshold 15). Drivers by points: if/else 29 (32 pts), boolean chains 9 (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.
Parser::parse_type_primary (cognitive 38) baml_language/crates/baml_compiler_parser/src/parser.rs:3182— Parser::parse_type_primary has cognitive complexity 38 (threshold 15). Drivers by points: if/else 22 (31 pts), boolean chains 5, loops 1 (2 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Parser::find_matching_generic_args_close_from (cognitive 37) baml_language/crates/baml_compiler_parser/src/parser.rs:5779— Parser::find_matching_generic_args_close_from has cognitive complexity 37 (threshold 15). Drivers by points: if/else 7 (24 pts), match/switch 2 (7 pts), loops 2 (5 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.
Parser::parse_for_expr (cognitive 35) baml_language/crates/baml_compiler_parser/src/parser.rs:6335— Parser::parse_for_expr has cognitive complexity 35 (threshold 15). Drivers by points: if/else 17 (33 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.
Parser::looks_like_generic_args (cognitive 33) baml_language/crates/baml_compiler_parser/src/parser.rs:7346— Parser::looks_like_generic_args has cognitive complexity 33 (threshold 15). Drivers by points: if/else 8 (22 pts), match/switch 2 (6 pts), loops 2 (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.
Parser::parse_implements_for (cognitive 32) baml_language/crates/baml_compiler_parser/src/parser.rs:4153— Parser::parse_implements_for has cognitive complexity 32 (threshold 15). Drivers by points: if/else 18 (27 pts), boolean chains 4, 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.
Parser::parse_generic_param_list (cognitive 32) baml_language/crates/baml_compiler_parser/src/parser.rs:4279— Parser::parse_generic_param_list has cognitive complexity 32 (threshold 15). Drivers by points: if/else 11 (24 pts), loops 3 (6 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.
Parser::looks_like_config_expression (cognitive 32) baml_language/crates/baml_compiler_parser/src/parser.rs:8462— Parser::looks_like_config_expression has cognitive complexity 32 (threshold 15). Drivers by points: if/else 14 (28 pts), boolean chains 4 (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.
Parser::parse_backtick_content (cognitive 29) baml_language/crates/baml_compiler_parser/src/parser.rs:2585— Parser::parse_backtick_content has cognitive complexity 29 (threshold 15). Drivers by points: if/else 7 (16 pts), loops 4 (12 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.
Parser::parse_implements_block (cognitive 29) baml_language/crates/baml_compiler_parser/src/parser.rs:4065— Parser::parse_implements_block has cognitive complexity 29 (threshold 15). Drivers by points: if/else 15 (24 pts), boolean chains 4, 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.
Parser::looks_like_map (cognitive 29) baml_language/crates/baml_compiler_parser/src/parser.rs:7689— Parser::looks_like_map has cognitive complexity 29 (threshold 15). Drivers by points: if/else 10 (21 pts), loops 3 (6 pts), match/switch 1 (2 pts) (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Parser::parse_for_header_only (cognitive 28) baml_language/crates/baml_compiler_parser/src/parser.rs:2903— Parser::parse_for_header_only has cognitive complexity 28 (threshold 15). Drivers by points: if/else 11 (26 pts), boolean chains 2 (nesting depth added 15). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
Parser::parse_class (cognitive 28) baml_language/crates/baml_compiler_parser/src/parser.rs:3702— Parser::parse_class has cognitive complexity 28 (threshold 15). Drivers by points: if/else 16 (22 pts), boolean chains 4, loops 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.
Parser::parse_interface (cognitive 27) baml_language/crates/baml_compiler_parser/src/parser.rs:3800— Parser::parse_interface has cognitive complexity 27 (threshold 15). Drivers by points: if/else 15 (22 pts), boolean chains 3, 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.
Parser::parse_llm_function_body (cognitive 26) baml_language/crates/baml_compiler_parser/src/parser.rs:4590— Parser::parse_llm_function_body has cognitive complexity 26 (threshold 15). Drivers by points: if/else 12 (20 pts), boolean chains 5, 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.
Parser::looks_like_generic_lambda (cognitive 26) baml_language/crates/baml_compiler_parser/src/parser.rs:7835— Parser::looks_like_generic_lambda has cognitive complexity 26 (threshold 15). Drivers by points: if/else 7 (17 pts), match/switch 1 (5 pts), loops 1 (4 pts) (nesting depth added 17). 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.
Parser::parse_match_expr (cognitive 23) baml_language/crates/baml_compiler_parser/src/parser.rs:5312— Parser::parse_match_expr has cognitive complexity 23 (threshold 15). Drivers by points: if/else 10 (20 pts), loops 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.
Parser::parse_map_literal (cognitive 21) baml_language/crates/baml_compiler_parser/src/parser.rs:7889— Parser::parse_map_literal has cognitive complexity 21 (threshold 15). Drivers by points: if/else 8 (18 pts), boolean chains 2, loops 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Parser::at_header_comment_start (cognitive 20) baml_language/crates/baml_compiler_parser/src/parser.rs:1085— Parser::at_header_comment_start has cognitive complexity 20 (threshold 15). Drivers by points: if/else 6 (10 pts), loops 3 (7 pts), boolean chains 3 (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.
Parser::parse_stmt (cognitive 20) baml_language/crates/baml_compiler_parser/src/parser.rs:4856— Parser::parse_stmt has cognitive complexity 20 (threshold 15). Drivers by points: if/else 18 (20 pts) (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.
Parser::parse_catch_clause (cognitive 20) baml_language/crates/baml_compiler_parser/src/parser.rs:6092— Parser::parse_catch_clause has cognitive complexity 20 (threshold 15). Drivers by points: if/else 13 (17 pts), boolean chains 2, loops 1 (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
Parser::find_token_after_hashes (cognitive 19) baml_language/crates/baml_compiler_parser/src/parser.rs:2097— Parser::find_token_after_hashes has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (11 pts), loops 3 (6 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.
Parser::classify_backtick_interp (cognitive 18) baml_language/crates/baml_compiler_parser/src/parser.rs:2730— Parser::classify_backtick_interp has cognitive complexity 18 (threshold 15). Drivers by points: if/else 9 (13 pts), boolean chains 3, loops 1, match/switch 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.
InferenceContext::finish (cognitive 217) baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:12601— InferenceContext::finish has cognitive complexity 217 (threshold 15). Drivers by points: if/else 51 (121 pts), match/switch 17 (44 pts), loops 21 (33 pts), boolean chains 19 (nesting depth added 109). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
InferenceContext::infer_expr (cognitive 115) baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:2857— InferenceContext::infer_expr has cognitive complexity 115 (threshold 15). Drivers by points: if/else 28 (60 pts), match/switch 11 (27 pts), loops 7 (22 pts), boolean chains 6 (nesting depth added 63). 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.
InferenceContext::check_call_args (cognitive 82) baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:6317— InferenceContext::check_call_args has cognitive complexity 82 (threshold 15). Drivers by points: if/else 22 (44 pts), loops 9 (15 pts), match/switch 7 (13 pts), boolean chains 10 (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.
InferenceContext::infer_catch (cognitive 70) baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:11323— InferenceContext::infer_catch has cognitive complexity 70 (threshold 15). Drivers by points: if/else 24 (50 pts), loops 7 (10 pts), match/switch 3 (6 pts), boolean chains 4 (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.
InferenceContext::sub (cognitive 61) baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:4509— InferenceContext::sub has cognitive complexity 61 (threshold 15). Drivers by points: if/else 22 (36 pts), boolean chains 11, loops 4 (8 pts), match/switch 3 (6 pts) (nesting depth added 21). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
InferenceContext::infer_lambda (cognitive 53) baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:8740— InferenceContext::infer_lambda has cognitive complexity 53 (threshold 15). Drivers by points: if/else 21 (36 pts), match/switch 7 (10 pts), loops 2 (4 pts), boolean chains 3 (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.
InferenceContext::member_callee (cognitive 49) baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:6921— InferenceContext::member_callee has cognitive complexity 49 (threshold 15). Drivers by points: if/else 22 (41 pts), boolean chains 4, match/switch 2 (4 pts) (nesting depth added 21). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
InferenceContext::lower_array_pattern (cognitive 46) baml_language/crates/baml_compiler2_hir_ty/src/infer/pat.rs:1523— InferenceContext::lower_array_pattern has cognitive complexity 46 (threshold 15). Drivers by points: if/else 19 (26 pts), match/switch 5 (8 pts), boolean chains 7, loops 4 (5 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.
InferenceContext::infer_match (cognitive 43) baml_language/crates/baml_compiler2_hir_ty/src/infer/pat.rs:66— InferenceContext::infer_match has cognitive complexity 43 (threshold 15). Drivers by points: if/else 17 (29 pts), loops 7 (12 pts), boolean chains 1, match/switch 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.
InferenceContext::infer_callee (cognitive 43) baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:6660— InferenceContext::infer_callee has cognitive complexity 43 (threshold 15). Drivers by points: if/else 19 (34 pts), boolean chains 8, 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.
InferenceContext::resolve_value_path (cognitive 42) baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:7410— InferenceContext::resolve_value_path has cognitive complexity 42 (threshold 15). Drivers by points: if/else 22 (30 pts), boolean chains 10, match/switch 1 (2 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
InferenceContext::infer_stmt (cognitive 39) baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:3408— InferenceContext::infer_stmt has cognitive complexity 39 (threshold 15). Drivers by points: if/else 11 (21 pts), loops 4 (8 pts), match/switch 3 (6 pts), boolean chains 4 (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.
InferenceContext::attempt (cognitive 37) baml_language/crates/baml_compiler2_hir_ty/src/infer/obligations.rs:386— InferenceContext::attempt has cognitive complexity 37 (threshold 15). Drivers by points: if/else 9 (19 pts), match/switch 5 (11 pts), loops 1 (4 pts), boolean chains 3 (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.
InferenceContext::lower_interface_pattern (cognitive 37) baml_language/crates/baml_compiler2_hir_ty/src/infer/pat.rs:720— InferenceContext::lower_interface_pattern has cognitive complexity 37 (threshold 15). Drivers by points: if/else 12 (17 pts), match/switch 5 (8 pts), boolean chains 7, loops 4 (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.
InferenceContext::lower_class_pattern (cognitive 35) baml_language/crates/baml_compiler2_hir_ty/src/infer/pat.rs:1311— InferenceContext::lower_class_pattern has cognitive complexity 35 (threshold 15). Drivers by points: if/else 11 (12 pts), match/switch 6 (12 pts), boolean chains 6, 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.
InferenceContext::infer_binary (cognitive 34) baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:5208— InferenceContext::infer_binary has cognitive complexity 34 (threshold 15). Drivers by points: if/else 11 (25 pts), match/switch 3 (6 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.
InferenceContext::infer_assign (cognitive 32) baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:4267— InferenceContext::infer_assign has cognitive complexity 32 (threshold 15). Drivers by points: if/else 12 (19 pts), match/switch 5 (9 pts), boolean chains 4 (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.
InferenceContext::field_access_resolved (cognitive 29) baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:10001— InferenceContext::field_access_resolved has cognitive complexity 29 (threshold 15). Drivers by points: if/else 15 (26 pts), boolean chains 2, 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.
InferenceContext::take_unresolved_infer_diagnostics (cognitive 28) baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:12178— InferenceContext::take_unresolved_infer_diagnostics has cognitive complexity 28 (threshold 15). Drivers by points: if/else 8 (16 pts), match/switch 3 (7 pts), loops 4, 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.
InferenceContext::infer_source_object (cognitive 27) baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:9559— InferenceContext::infer_source_object has cognitive complexity 27 (threshold 15). Drivers by points: loops 7 (11 pts), if/else 7 (9 pts), match/switch 3 (7 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.
InferenceContext::infer_exported_object (cognitive 24) baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:9766— InferenceContext::infer_exported_object has cognitive complexity 24 (threshold 15). Drivers by points: loops 9 (14 pts), if/else 7 (9 pts), match/switch 1 (nesting depth added 7). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
InferenceContext::try_solve_bounded_var (cognitive 24) baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:14449— InferenceContext::try_solve_bounded_var has cognitive complexity 24 (threshold 15). Drivers by points: if/else 9 (14 pts), match/switch 3 (6 pts), boolean chains 2, loops 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.
InferenceContext::sub_residue (cognitive 22) baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:4824— InferenceContext::sub_residue has cognitive complexity 22 (threshold 15). Drivers by points: if/else 4 (6 pts), loops 2 (6 pts), match/switch 2 (6 pts), boolean chains 4 (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.
InferenceContext::check_template_interps_strict (cognitive 22) baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:11830— InferenceContext::check_template_interps_strict has cognitive complexity 22 (threshold 15). Drivers by points: if/else 4 (12 pts), match/switch 2 (5 pts), loops 2 (4 pts), boolean chains 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
InferenceContext::confirm_unique_impl (cognitive 18) baml_language/crates/baml_compiler2_hir_ty/src/infer/obligations.rs:588— InferenceContext::confirm_unique_impl has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (16 pts), boolean chains 1, 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.
Duplicated block (16 lines × 2) baml_language/sdks/csharp/bridge_csharp/tools/Baml.Union.LayoutProbe/Program.cs:355— baml_language/sdks/csharp/bridge_csharp/tools/Baml.Union.LayoutProbe/Program.cs:355-370 | baml_language/sdks/csharp/bridge_csharp/tools/Baml.Union.LayoutProbe/Program.cs:405-420 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (16 lines × 2) baml_language/sdks/csharp/bridge_csharp/tools/Baml.Union.LayoutProbe/Program.cs:375— baml_language/sdks/csharp/bridge_csharp/tools/Baml.Union.LayoutProbe/Program.cs:375-390 | baml_language/sdks/csharp/bridge_csharp/tools/Baml.Union.LayoutProbe/Program.cs:441-456 — both copies are in the same file, so extract the block into 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) baml_language/sdks/csharp/bridge_csharp/src/Values/BamlValue.cs:15— baml_language/sdks/csharp/bridge_csharp/src/Values/BamlValue.cs:15-30 | baml_language/sdks/csharp/bridge_csharp/src/Values/BamlValue.cs:36-51 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:1302— baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:1302-1319 | baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:1334-1349 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:3326— baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:3326-3341 | baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:3344-3359 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:3616— baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:3616-3631 | baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:4238-4253 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs:1226— baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs:1226-1241 | baml_language/crates/baml_compiler2_hir_ty/src/interfaces/impl_rules.rs:970-985 — 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) baml_language/crates/baml_compiler2_hir_ty/src/lower.rs:1958— baml_language/crates/baml_compiler2_hir_ty/src/lower.rs:1958-1973 | baml_language/crates/baml_compiler2_hir_ty/src/lower.rs:2157-2172 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler2_mir/src/lower.rs:12439— baml_language/crates/baml_compiler2_mir/src/lower.rs:12439-12454 | baml_language/crates/baml_compiler2_mir/src/lower.rs:12507-12522 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler_parser/src/parser.rs:2977— baml_language/crates/baml_compiler_parser/src/parser.rs:2977-2992 | baml_language/crates/baml_compiler_parser/src/parser.rs:3017-3032 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_fmt/src/ast/expressions.rs:2029— baml_language/crates/baml_fmt/src/ast/expressions.rs:2029-2044 | baml_language/crates/baml_fmt/src/ast/expressions.rs:2587-2602 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_fmt/src/ast/pattern.rs:42— baml_language/crates/baml_fmt/src/ast/pattern.rs:42-57 | baml_language/crates/baml_fmt/src/ast/pattern.rs:71-86 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_ide/src/export.rs:1081— baml_language/crates/baml_ide/src/export.rs:1081-1096 | baml_language/crates/baml_ide/src/export.rs:1109-1124 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_lsp_server/src/playground_server.rs:521— baml_language/crates/baml_lsp_server/src/playground_server.rs:521-536 | baml_language/crates/bridge_wasm/src/runs.rs:469-484 — 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) baml_language/crates/baml_path/src/native/non_windows.rs:12— baml_language/crates/baml_path/src/native/non_windows.rs:12-27 | baml_language/crates/baml_path/src/native/windows.rs:32-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 both call sites, so a change lands once.
Duplicated block (16 lines × 2) baml_language/crates/bex_sap/src/deserializer/coercer/match_string.rs:155— baml_language/crates/bex_sap/src/deserializer/coercer/match_string.rs:155-170 | engine/baml-lib/jsonish/src/deserializer/coercer/match_string.rs:144-159 — before extracting anything, compare `baml_language/crates/bex_sap/src/deserializer/coercer/match_string.rs` and `engine/baml-lib/jsonish/src/deserializer/coercer/match_string.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 52 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (16 lines × 2) baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs:115— baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs:115-130 | engine/baml-lib/jsonish/src/jsonish/parser/fixing_parser/json_parse_state.rs:120-135 — before extracting anything, compare `baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs` and `engine/baml-lib/jsonish/src/jsonish/parser/fixing_parser/json_parse_state.rs` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 575 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (16 lines × 2) baml_language/crates/bex_sap/src/jsonish/parser/multi_json_parser.rs:11— baml_language/crates/bex_sap/src/jsonish/parser/multi_json_parser.rs:11-26 | engine/baml-lib/jsonish/src/jsonish/parser/multi_json_parser.rs:10-25 — 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) baml_language/crates/bex_vm/src/debug.rs:544— baml_language/crates/bex_vm/src/debug.rs:544-559 | engine/baml-vm/src/debug.rs:264-279 — before extracting anything, compare `baml_language/crates/bex_vm/src/debug.rs` and `engine/baml-vm/src/debug.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 57 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (16 lines × 2) baml_language/crates/bex_vm/src/package_baml/array.rs:1065— baml_language/crates/bex_vm/src/package_baml/array.rs:1065-1080 | baml_language/crates/bex_vm/src/package_baml/array.rs:1088-1103 — both copies are in the same file, so extract the block into 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) engine/baml-lib/baml-types/src/baml_value.rs:116— engine/baml-lib/baml-types/src/baml_value.rs:116-131 | engine/baml-lib/baml-types/src/baml_value.rs:913-928 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (16 lines × 2) engine/baml-lib/jsonish/src/deserializer/coercer/ir_ref/coerce_alias.rs:34— engine/baml-lib/jsonish/src/deserializer/coercer/ir_ref/coerce_alias.rs:34-49 | engine/baml-lib/jsonish/src/deserializer/coercer/ir_ref/coerce_enum.rs:59-74 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (16 lines × 2) engine/baml-runtime/src/internal/llm_client/orchestrator/call.rs:117— engine/baml-runtime/src/internal/llm_client/orchestrator/call.rs:117-132 | engine/baml-runtime/src/internal/llm_client/orchestrator/stream.rs:409-424 — before extracting anything, compare `engine/baml-runtime/src/internal/llm_client/orchestrator/call.rs` and `engine/baml-runtime/src/internal/llm_client/orchestrator/stream.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 90 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (16 lines × 2) engine/baml-runtime/src/internal/llm_client/primitive/request.rs:281— engine/baml-runtime/src/internal/llm_client/primitive/request.rs:281-296 | engine/baml-runtime/src/internal/llm_client/primitive/request.rs:339-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 (16 lines × 2) engine/baml-vm/src/vm.rs:1458— engine/baml-vm/src/vm.rs:1458-1473 | engine/baml-vm/src/vm.rs:1642-1657 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Off the main sequence: @b/pkg-grammar — @b/pkg-grammar: abstractness 0.00, instability 0.00, distance 1.00 — zone of pain — concrete and depended on by 3 project(s), so it's rigid to change.
Off the main sequence: @b/pkg-lsp — @b/pkg-lsp: abstractness 0.00, instability 0.00, distance 1.00 — zone of pain — concrete and depended on by 2 project(s), so it's rigid to change.
Off the main sequence: @baml/codemirror-lang-baml — @baml/codemirror-lang-baml: abstractness 0.00, instability 0.00, distance 1.00 — zone of pain — concrete and depended on by 2 project(s), so it's rigid to change.
Off the main sequence: baml-ids — baml-ids: abstractness 0.00, instability 0.00, distance 1.00 — zone of pain — concrete and depended on by 8 project(s), so it's rigid to change.
Off the main sequence: baml-sys — baml-sys: abstractness 0.00, instability 0.00, distance 1.00 — zone of pain — concrete and depended on by 1 project(s), so it's rigid to change.
Off the main sequence: baml-viz-events — baml-viz-events: abstractness 0.00, instability 0.00, distance 1.00 — zone of pain — concrete and depended on by 4 project(s), so it's rigid to change.
Off the main sequence: baml_base — baml_base: abstractness 0.00, instability 0.00, distance 1.00 — zone of pain — concrete and depended on by 32 project(s), so it's rigid to change.
Off the main sequence: baml_path — baml_path: abstractness 0.00, instability 0.00, distance 1.00 — zone of pain — concrete and depended on by 1 project(s), so it's rigid to change.
Off the main sequence: bex_str — bex_str: abstractness 0.00, instability 0.00, distance 1.00 — zone of pain — concrete and depended on by 8 project(s), so it's rigid to change.
Off the main sequence: bstd — bstd: abstractness 0.00, instability 0.00, distance 1.00 — zone of pain — concrete and depended on by 4 project(s), so it's rigid to change.
Off the main sequence: forked_aws_sigv4 — forked_aws_sigv4: abstractness 0.00, instability 0.00, distance 1.00 — zone of pain — concrete and depended on by 3 project(s), so it's rigid to change.
Off the main sequence: forked_aws_smithy_eventstream — forked_aws_smithy_eventstream: abstractness 0.00, instability 0.00, distance 1.00 — zone of pain — concrete and depended on by 1 project(s), so it's rigid to change.
Off the main sequence: sys_glob — sys_glob: abstractness 0.00, instability 0.00, distance 1.00 — zone of pain — concrete and depended on by 2 project(s), so it's rigid to change.
Off the main sequence: sys_regex — sys_regex: abstractness 0.00, instability 0.00, distance 1.00 — zone of pain — concrete and depended on by 2 project(s), so it's rigid to change.
Off the main sequence: btel_settings — btel_settings: abstractness 0.00, instability 0.05, distance 0.95 — zone of pain — concrete and depended on by 19 project(s), so it's rigid to change.
Off the main sequence: btel_types — btel_types: abstractness 0.00, instability 0.05, distance 0.95 — zone of pain — concrete and depended on by 18 project(s), so it's rigid to change.
Off the main sequence: baml_query — baml_query: abstractness 0.06, instability 0.00, distance 0.94 — zone of pain — concrete and depended on by 1 project(s), so it's rigid to change.
Off the main sequence: @baml/ui — @baml/ui: abstractness 0.06, instability 0.00, distance 0.94 — zone of pain — concrete and depended on by 4 project(s), so it's rigid to change.
Off the main sequence: baml_artifact — baml_artifact: abstractness 0.00, instability 0.08, distance 0.92 — zone of pain — concrete and depended on by 12 project(s), so it's rigid to change.
Off the main sequence: internal-baml-diagnostics — internal-baml-diagnostics: abstractness 0.11, instability 0.00, distance 0.89 — zone of pain — concrete and depended on by 11 project(s), so it's rigid to change.
Off the main sequence: baml_compiler_lexer — baml_compiler_lexer: abstractness 0.00, instability 0.13, distance 0.88 — zone of pain — concrete and depended on by 7 project(s), so it's rigid to change.
Off the main sequence: bex_resource_types — bex_resource_types: abstractness 0.14, instability 0.00, distance 0.86 — zone of pain — concrete and depended on by 4 project(s), so it's rigid to change.
Off the main sequence: baml_builtins2 — baml_builtins2: abstractness 0.00, instability 0.15, distance 0.85 — zone of pain — concrete and depended on by 11 project(s), so it's rigid to change.
Off the main sequence: baml_compiler_syntax — baml_compiler_syntax: abstractness 0.02, instability 0.14, distance 0.83 — zone of pain — concrete and depended on by 6 project(s), so it's rigid to change.
Off the main sequence: baml_type_runtime — baml_type_runtime: abstractness 0.00, instability 0.20, distance 0.80 — zone of pain — concrete and depended on by 4 project(s), so it's rigid to change.
baml_ide::annotations::process_body (cognitive 92) baml_language/crates/baml_ide/src/annotations.rs:239— baml_ide::annotations::process_body has cognitive complexity 92 (threshold 15). Drivers by points: if/else 25 (81 pts), loops 5 (11 pts) (nesting depth added 62). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
baml_ide::symbol_pool::build_symbol_pool (cognitive 78) baml_language/crates/baml_ide/src/symbol_pool.rs:97— baml_ide::symbol_pool::build_symbol_pool has cognitive complexity 78 (threshold 15). Drivers by points: if/else 12 (34 pts), loops 15 (33 pts), boolean chains 8, match/switch 1 (3 pts) (nesting depth added 42). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
baml_ide::usages::find_member_usages (cognitive 73) baml_language/crates/baml_ide/src/usages.rs:367— baml_ide::usages::find_member_usages has cognitive complexity 73 (threshold 15). Drivers by points: if/else 17 (60 pts), loops 5 (13 pts) (nesting depth added 51). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
baml_ide::resolve::member_position_at (cognitive 64) baml_language/crates/baml_ide/src/resolve.rs:254— baml_ide::resolve::member_position_at has cognitive complexity 64 (threshold 15). Drivers by points: if/else 11 (31 pts), match/switch 6 (14 pts), loops 4 (11 pts), boolean chains 8 (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.
baml_ide::cursor_context::find_source_expr_ids_at (cognitive 62) baml_language/crates/baml_ide/src/cursor_context.rs:403— baml_ide::cursor_context::find_source_expr_ids_at has cognitive complexity 62 (threshold 15). Drivers by points: if/else 15 (41 pts), match/switch 3 (10 pts), loops 3 (8 pts), boolean chains 3 (nesting depth added 38). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
baml_ide::cfg::ast_test_control_flow_graph_impl (cognitive 57) baml_language/crates/baml_ide/src/cfg.rs:79— baml_ide::cfg::ast_test_control_flow_graph_impl has cognitive complexity 57 (threshold 15). Drivers by points: if/else 15 (50 pts), loops 3 (6 pts), boolean chains 1 (nesting depth added 38). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
baml_ide::describe::describe_locals (cognitive 43) baml_language/crates/baml_ide/src/describe.rs:815— baml_ide::describe::describe_locals has cognitive complexity 43 (threshold 15). Drivers by points: if/else 6 (22 pts), loops 5 (13 pts), match/switch 1 (5 pts), boolean chains 3 (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.
baml_ide::cfg::expand_user_function_calls_in_graph (cognitive 40) baml_language/crates/baml_ide/src/cfg.rs:295— baml_ide::cfg::expand_user_function_calls_in_graph has cognitive complexity 40 (threshold 15). Drivers by points: if/else 15 (37 pts), match/switch 1 (2 pts), loops 1 (nesting depth added 23). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
baml_ide::info::generic_type_parameter_info_at (cognitive 40) baml_language/crates/baml_ide/src/info.rs:1037— baml_ide::info::generic_type_parameter_info_at has cognitive complexity 40 (threshold 15). Drivers by points: if/else 12 (27 pts), match/switch 2 (7 pts), loops 5 (6 pts) (nesting depth added 21). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
baml_ide::tokens::index::index_function (cognitive 37) baml_language/crates/baml_ide/src/tokens/index.rs:145— baml_ide::tokens::index::index_function has cognitive complexity 37 (threshold 15). Drivers by points: if/else 8 (24 pts), match/switch 3 (8 pts), loops 2 (4 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.
baml_ide::resolve::template_position_at (cognitive 31) baml_language/crates/baml_ide/src/resolve.rs:915— baml_ide::resolve::template_position_at has cognitive complexity 31 (threshold 15). Drivers by points: if/else 10 (18 pts), boolean chains 6, match/switch 3 (4 pts), loops 2 (3 pts) (nesting depth added 10). Of this number, 26 points are the body's own statements and 5 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.
baml_ide::completion::members::complete (cognitive 28) baml_language/crates/baml_ide/src/completion/members.rs:21— baml_ide::completion::members::complete has cognitive complexity 28 (threshold 15). Drivers by points: if/else 6 (19 pts), loops 3 (6 pts), boolean chains 2, 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.
baml_ide::resolve::receiver_at_dot (cognitive 28) baml_language/crates/baml_ide/src/resolve.rs:424— baml_ide::resolve::receiver_at_dot has cognitive complexity 28 (threshold 15). Drivers by points: if/else 8 (19 pts), boolean chains 3, loops 2 (3 pts), match/switch 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.
baml_ide::resolve::operator_target_at (cognitive 27) baml_language/crates/baml_ide/src/resolve.rs:1154— baml_ide::resolve::operator_target_at has cognitive complexity 27 (threshold 15). Drivers by points: if/else 9 (16 pts), boolean chains 7, loops 2, match/switch 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.
baml_ide::cfg::merge_callee_graph_under_call_node (cognitive 25) baml_language/crates/baml_ide/src/cfg.rs:845— baml_ide::cfg::merge_callee_graph_under_call_node has cognitive complexity 25 (threshold 15). Drivers by points: if/else 10 (18 pts), loops 4 (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.
baml_ide::resolve::member_access_at (cognitive 25) baml_language/crates/baml_ide/src/resolve.rs:1366— baml_ide::resolve::member_access_at has cognitive complexity 25 (threshold 15). Drivers by points: if/else 8 (20 pts), boolean chains 2, match/switch 1 (2 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.
baml_ide::describe::clean_body_source (cognitive 24) baml_language/crates/baml_ide/src/describe.rs:2384— baml_ide::describe::clean_body_source has cognitive complexity 24 (threshold 15). Drivers by points: if/else 10 (20 pts), boolean chains 2, loops 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.
baml_ide::resolve::object_literal_at (cognitive 23) baml_language/crates/baml_ide/src/resolve.rs:615— baml_ide::resolve::object_literal_at has cognitive complexity 23 (threshold 15). Drivers by points: if/else 7 (19 pts), loops 2 (3 pts), boolean chains 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
baml_ide::resolve::template_driver_at (cognitive 23) baml_language/crates/baml_ide/src/resolve.rs:1052— baml_ide::resolve::template_driver_at has cognitive complexity 23 (threshold 15). Drivers by points: if/else 8 (18 pts), loops 2 (3 pts), boolean chains 2 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
baml_ide::resolve::declaration_name_at (cognitive 23) baml_language/crates/baml_ide/src/resolve.rs:1290— baml_ide::resolve::declaration_name_at has cognitive complexity 23 (threshold 15). Drivers by points: if/else 6 (14 pts), loops 5 (7 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.
baml_ide::search::ranked_candidates (cognitive 23) baml_language/crates/baml_ide/src/search.rs:328— baml_ide::search::ranked_candidates has cognitive complexity 23 (threshold 15). Drivers by points: loops 6 (15 pts), if/else 1 (4 pts), match/switch 1 (4 pts) (nesting depth added 15). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
baml_ide::completion::context::classify (cognitive 21) baml_language/crates/baml_ide/src/completion/context.rs:305— baml_ide::completion::context::classify has cognitive complexity 21 (threshold 15). Drivers by points: if/else 10 (13 pts), match/switch 3 (7 pts), loops 1 (nesting depth added 7). 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.
baml_ide::cfg::ast_control_flow_graph_for_loc (cognitive 20) baml_language/crates/baml_ide/src/cfg.rs:216— baml_ide::cfg::ast_control_flow_graph_for_loc has cognitive complexity 20 (threshold 15). Drivers by points: if/else 8 (18 pts), match/switch 1 (2 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
baml_ide::annotations::file_annotations (cognitive 19) baml_language/crates/baml_ide/src/annotations.rs:124— baml_ide::annotations::file_annotations has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (14 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.
baml_ide::describe::collect_type_expr_deps (cognitive 18) baml_language/crates/baml_ide/src/describe.rs:2033— baml_ide::describe::collect_type_expr_deps has cognitive complexity 18 (threshold 15). Drivers by points: if/else 4 (11 pts), loops 3 (6 pts), match/switch 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. This shape REPEATS in the file: one other method here (baml_ide::describe::collect_type_ref_deps) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
baml_runtime::internal::prompt_renderer::render_output_format::relevant_data_models (cognitive 183) engine/baml-runtime/src/internal/prompt_renderer/render_output_format.rs:236— baml_runtime::internal::prompt_renderer::render_output_format::relevant_data_models has cognitive complexity 183 (threshold 15). Drivers by points: if/else 38 (143 pts), loops 10 (37 pts), match/switch 1 (2 pts), boolean chains 1 (nesting depth added 133). 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.
baml_runtime::internal::llm_client::orchestrator::stream::orchestrate_stream (cognitive 100) engine/baml-runtime/src/internal/llm_client/orchestrator/stream.rs:151— baml_runtime::internal::llm_client::orchestrator::stream::orchestrate_stream has cognitive complexity 100 (threshold 15). Drivers by points: if/else 22 (62 pts), match/switch 11 (33 pts), loops 2 (4 pts), boolean chains 1 (nesting depth added 64). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
baml_runtime::tracingv2::publisher::rpc_converters::extract_blobs_from_trace_data (cognitive 91) engine/baml-runtime/src/tracingv2/publisher/rpc_converters/mod.rs:56— baml_runtime::tracingv2::publisher::rpc_converters::extract_blobs_from_trace_data has cognitive complexity 91 (threshold 15). Drivers by points: if/else 11 (57 pts), loops 5 (20 pts), match/switch 4 (14 pts) (nesting depth added 71). 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.
baml_runtime::internal::llm_client::traits::process_media (cognitive 62) engine/baml-runtime/src/internal/llm_client/traits/mod.rs:560— baml_runtime::internal::llm_client::traits::process_media has cognitive complexity 62 (threshold 15). Drivers by points: if/else 25 (53 pts), match/switch 4 (9 pts) (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.
baml_runtime::cli::dotenv::expand_value (cognitive 36) engine/baml-runtime/src/cli/dotenv/mod.rs:244— baml_runtime::cli::dotenv::expand_value has cognitive complexity 36 (threshold 15). Drivers by points: if/else 8 (19 pts), loops 3 (9 pts), match/switch 2 (5 pts), boolean chains 3 (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.
baml_runtime::cli::init::install_extension_manually (cognitive 34) engine/baml-runtime/src/cli/init.rs:276— baml_runtime::cli::init::install_extension_manually has cognitive complexity 34 (threshold 15). Drivers by points: if/else 6 (22 pts), match/switch 3 (8 pts), boolean chains 2, loops 1 (2 pts) (nesting depth added 22). 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.
baml_runtime::optimize::tui::display_pareto_and_select (cognitive 34) engine/baml-runtime/src/optimize/tui.rs:1683— baml_runtime::optimize::tui::display_pareto_and_select has cognitive complexity 34 (threshold 15). Drivers by points: if/else 12 (22 pts), loops 3 (6 pts), match/switch 1 (5 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.
baml_runtime::tracingv2::storage::storage::build_function_log (cognitive 33) engine/baml-runtime/src/tracingv2/storage/storage.rs:162— baml_runtime::tracingv2::storage::storage::build_function_log has cognitive complexity 33 (threshold 15). Drivers by points: if/else 9 (13 pts), match/switch 5 (11 pts), loops 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.
baml_runtime::optimize::tui::render_prompt_panel (cognitive 30) engine/baml-runtime/src/optimize/tui.rs:1187— baml_runtime::optimize::tui::render_prompt_panel has cognitive complexity 30 (threshold 15). Drivers by points: if/else 7 (18 pts), loops 5 (12 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.
baml_runtime::optimize::tui::syntax_highlight (cognitive 30) engine/baml-runtime/src/optimize/tui.rs:1366— baml_runtime::optimize::tui::syntax_highlight has cognitive complexity 30 (threshold 15). Drivers by points: if/else 15 (26 pts), boolean chains 3, 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.
baml_runtime::cli::dotenv::load_env_from_string (cognitive 29) engine/baml-runtime/src/cli/dotenv/mod.rs:66— baml_runtime::cli::dotenv::load_env_from_string has cognitive complexity 29 (threshold 15). Drivers by points: if/else 6 (14 pts), loops 3 (9 pts), boolean chains 6 (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.
baml_runtime::internal::llm_client::orchestrator::call::orchestrate (cognitive 26) engine/baml-runtime/src/internal/llm_client/orchestrator/call.rs:46— baml_runtime::internal::llm_client::orchestrator::call::orchestrate has cognitive complexity 26 (threshold 15). Drivers by points: if/else 6 (15 pts), match/switch 5 (10 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.
baml_runtime::tracing::threaded_tracer::redact_event (cognitive 26) engine/baml-runtime/src/tracing/threaded_tracer.rs:298— baml_runtime::tracing::threaded_tracer::redact_event has cognitive complexity 26 (threshold 15). Drivers by points: if/else 7 (12 pts), match/switch 4 (8 pts), loops 2 (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.
baml_runtime::internal::llm_client::primitive::stream_request::make_stream_request (cognitive 25) engine/baml-runtime/src/internal/llm_client/primitive/stream_request.rs:45— baml_runtime::internal::llm_client::primitive::stream_request::make_stream_request has cognitive complexity 25 (threshold 15). Drivers by points: if/else 10 (14 pts), match/switch 7 (10 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.
baml_runtime::optimize::tui::render_metadata_panel (cognitive 25) engine/baml-runtime/src/optimize/tui.rs:912— baml_runtime::optimize::tui::render_metadata_panel has cognitive complexity 25 (threshold 15). Drivers by points: if/else 9 (15 pts), loops 2 (8 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.
baml_runtime::control_flow::flatten::step2_hoist_branch_arms::hoist_branch_arms (cognitive 24) engine/baml-runtime/src/control_flow/flatten/step2_hoist_branch_arms.rs:7— baml_runtime::control_flow::flatten::step2_hoist_branch_arms::hoist_branch_arms has cognitive complexity 24 (threshold 15). Drivers by points: if/else 5 (12 pts), loops 5 (12 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.
baml_runtime::optimize::evaluator::failure_location (cognitive 24) engine/baml-runtime/src/optimize/evaluator.rs:381— baml_runtime::optimize::evaluator::failure_location has cognitive complexity 24 (threshold 15). Drivers by points: if/else 8 (12 pts), match/switch 3 (9 pts), boolean chains 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.
baml_runtime::cli::init::generate_main_baml_content (cognitive 23) engine/baml-runtime/src/cli/init.rs:544— baml_runtime::cli::init::generate_main_baml_content has cognitive complexity 23 (threshold 15). Drivers by points: if/else 13 (17 pts), match/switch 4 (6 pts) (nesting depth added 6). 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.
baml_runtime::async_vm_runtime::try_vm_value_from_baml_value (cognitive 22) engine/baml-runtime/src/async_vm_runtime.rs:1231— baml_runtime::async_vm_runtime::try_vm_value_from_baml_value has cognitive complexity 22 (threshold 15). Drivers by points: if/else 6 (13 pts), loops 4 (8 pts), match/switch 1 (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.
baml_runtime::internal::llm_client::primitive::openai::openai_client::responses_content_part (cognitive 22) engine/baml-runtime/src/internal/llm_client/primitive/openai/openai_client.rs:113— baml_runtime::internal::llm_client::primitive::openai::openai_client::responses_content_part has cognitive complexity 22 (threshold 15). Drivers by points: match/switch 5 (12 pts), if/else 4 (8 pts), loops 1 (2 pts) (nesting depth added 12). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own 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.
baml_runtime::internal::prompt_renderer::render_output_format::find_enum_value (cognitive 22) engine/baml-runtime/src/internal/prompt_renderer/render_output_format.rs:172— baml_runtime::internal::prompt_renderer::render_output_format::find_enum_value has cognitive complexity 22 (threshold 15). Drivers by points: if/else 9 (16 pts), boolean chains 3, 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.
baml_runtime::optimize::tui::render_candidate_card (cognitive 21) engine/baml-runtime/src/optimize/tui.rs:765— baml_runtime::optimize::tui::render_candidate_card has cognitive complexity 21 (threshold 15). Drivers by points: if/else 13 (17 pts), loops 1 (3 pts), match/switch 1 (nesting depth added 6). 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.
baml_runtime::optimize::schema_extractor::collect_reachable_types (cognitive 20) engine/baml-runtime/src/optimize/schema_extractor.rs:107— baml_runtime::optimize::schema_extractor::collect_reachable_types has cognitive complexity 20 (threshold 15). Drivers by points: if/else 5 (12 pts), loops 3 (7 pts), match/switch 1 (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.
baml_runtime::internal::llm_client::primitive::openai::response_handler::scan_openai_responses_stream (cognitive 17) engine/baml-runtime/src/internal/llm_client/primitive/openai/response_handler.rs:773— baml_runtime::internal::llm_client::primitive::openai::response_handler::scan_openai_responses_stream has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (14 pts), match/switch 2, boolean chains 1 (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.
baml_runtime::optimize::tui::format_compact_metric (cognitive 17) engine/baml-runtime/src/optimize/tui.rs:1485— baml_runtime::optimize::tui::format_compact_metric has cognitive complexity 17 (threshold 15). Drivers by points: if/else 12 (16 pts), match/switch 1 (nesting depth added 4). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
Duplicated block (15 lines × 2) baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:2940— baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:2940-2954 | baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:3401-3415 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler2_hir_ty/src/lower.rs:2228— baml_language/crates/baml_compiler2_hir_ty/src/lower.rs:2228-2242 | baml_language/crates/baml_compiler2_hir_ty/src/lower.rs:2253-2267 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler2_mir/src/lower.rs:4980— baml_language/crates/baml_compiler2_mir/src/lower.rs:4980-4994 | baml_language/crates/baml_compiler2_mir/src/lower.rs:5536-5550 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_fmt/src/ast/declarations.rs:475— baml_language/crates/baml_fmt/src/ast/declarations.rs:475-489 | baml_language/crates/baml_fmt/src/ast/declarations.rs:2912-2926 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (15 lines × 2) baml_language/crates/baml_type/src/pattern_overlap.rs:267— baml_language/crates/baml_type/src/pattern_overlap.rs:267-281 | baml_language/crates/baml_type/src/unify.rs:713-727 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (15 lines × 2) baml_language/crates/bex_sap/src/deserializer/deserialize_flags.rs:246— baml_language/crates/bex_sap/src/deserializer/deserialize_flags.rs:246-260 | engine/baml-lib/jsonish/src/deserializer/deserialize_flags.rs:249-263 — before extracting anything, compare `baml_language/crates/bex_sap/src/deserializer/deserialize_flags.rs` and `engine/baml-lib/jsonish/src/deserializer/deserialize_flags.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 127 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, 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 (15 lines × 2) baml_language/crates/bex_vm/src/vm.rs:11483— baml_language/crates/bex_vm/src/vm.rs:11483-11497 | baml_language/crates/bex_vm/src/vm.rs:11517-11531 — both copies are in the same file, so extract the block into 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) baml_language/crates/btel_snapshot/src/decode.rs:1431— baml_language/crates/btel_snapshot/src/decode.rs:1431-1445 | baml_language/crates/btel_snapshot/src/tags.rs:115-129 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (15 lines × 2) baml_language/crates/tools_stow/src/main.rs:2111— baml_language/crates/tools_stow/src/main.rs:2111-2125 | baml_language/crates/tools_stow/src/main.rs:2418-2432 — both copies are in the same file, so extract the block into 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) baml_language/sdks/csharp/sdkgen_csharp/src/semantic.rs:3807— baml_language/sdks/csharp/sdkgen_csharp/src/semantic.rs:3807-3821 | baml_language/sdks/csharp/sdkgen_csharp/src/semantic.rs:3925-3939 — both copies are in the same file, so extract the block into 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) baml_language/sdks/python/rust/bridge_python/src/invocation.rs:129— baml_language/sdks/python/rust/bridge_python/src/invocation.rs:129-143 | baml_language/sdks/python/rust/bridge_python/src/invocation.rs:178-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.
Duplicated block (15 lines × 2) baml_language/sdks/rust/bridge_rust/src/function.rs:19— baml_language/sdks/rust/bridge_rust/src/function.rs:19-33 | baml_language/sdks/rust/bridge_rust/src/spec.rs:20-34 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (15 lines × 2) baml_language/sdks/typescript/sdkgen_typescript_shared/src/leaf.rs:238— baml_language/sdks/typescript/sdkgen_typescript_shared/src/leaf.rs:238-252 | baml_language/sdks/typescript/sdkgen_typescript_shared/src/leaf.rs:276-290 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (15 lines × 2) engine/baml-lib/diagnostics/src/error.rs:610— engine/baml-lib/diagnostics/src/error.rs:610-624 | engine/baml-lib/diagnostics/src/warning.rs:44-58 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (15 lines × 2) engine/baml-runtime/src/internal/llm_client/primitive/aws/aws_client.rs:1368— engine/baml-runtime/src/internal/llm_client/primitive/aws/aws_client.rs:1368-1382 | engine/baml-runtime/src/internal/llm_client/primitive/aws/aws_client.rs:1385-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 (15 lines × 2) engine/generators/languages/python/src/watchers.rs:257— engine/generators/languages/python/src/watchers.rs:257-271 | engine/generators/languages/typescript/src/watchers.rs:245-259 — before extracting anything, compare `engine/generators/languages/python/src/watchers.rs` and `engine/generators/languages/typescript/src/watchers.rs` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 146 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, 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 (15 lines × 2) engine/generators/languages/rust/src/ir_to_rust/classes.rs:16— engine/generators/languages/rust/src/ir_to_rust/classes.rs:16-30 | engine/generators/languages/rust/src/ir_to_rust/classes.rs:42-56 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (15 lines × 2) engine/generators/languages/typescript/src/ir_to_ts/functions.rs:10— engine/generators/languages/typescript/src/ir_to_ts/functions.rs:10-24 | engine/generators/languages/typescript/src/ir_to_ts/functions.rs:39-53 — both copies are in the same file, so extract the block into 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) languages/rust/baml/src/codec/helpers.rs:53— languages/rust/baml/src/codec/helpers.rs:53-67 | languages/rust/baml/src/codec/helpers.rs:72-86 — both copies are in the same file, so extract the block into 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) languages/rust/baml/src/runtime.rs:151— languages/rust/baml/src/runtime.rs:151-165 | languages/rust/baml/src/runtime.rs:273-287 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (15 lines × 2) engine/baml-lib/ast/src/ast/config.rs:44— engine/baml-lib/ast/src/ast/config.rs:44-58 | engine/baml-lib/ast/src/ast/template_string.rs:49-79 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (15 lines × 2) baml_language/crates/bridge_cffi/src/ffi/host_value.rs:191— baml_language/crates/bridge_cffi/src/ffi/host_value.rs:191-205 | baml_language/crates/bridge_cffi/src/ffi/host_value.rs:254-270 — both copies are in the same file, so extract the block into 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) engine/baml-lib/llm-client/src/clients/helpers.rs:495— engine/baml-lib/llm-client/src/clients/helpers.rs:495-509 | engine/baml-lib/llm-client/src/clients/helpers.rs:795-809 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (15 lines × 2) engine/language_server/src/server/api/notifications/did_change.rs:66— engine/language_server/src/server/api/notifications/did_change.rs:66-80 | engine/language_server/src/server/api/requests/diagnostic.rs:71-85 — 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 (15 lines × 2) engine/baml-runtime/src/test_executor/output_pretty.rs:80— engine/baml-runtime/src/test_executor/output_pretty.rs:80-94 | engine/baml-runtime/src/test_executor/output_pretty.rs:107-121 — both copies are in the same file, so extract the block into 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) baml_language/sdks/csharp/bridge_csharp/src/Proto/PrimitiveProtocol.cs:286— baml_language/sdks/csharp/bridge_csharp/src/Proto/PrimitiveProtocol.cs:286-302 | baml_language/sdks/csharp/bridge_csharp/src/Proto/PrimitiveProtocol.cs:342-358 — both copies are in the same file, so extract the 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, `baml_language/sdks/csharp/bridge_csharp/src/Proto/PrimitiveProtocol.cs:284` calls `RequireExpectedStreamType` and `baml_language/sdks/csharp/bridge_csharp/src/Proto/PrimitiveProtocol.cs:340` 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 (17 lines × 2) baml_language/crates/baml_compiler2_mir/src/lower.rs:10797— baml_language/crates/baml_compiler2_mir/src/lower.rs:10797-10813 | baml_language/crates/baml_compiler2_mir/src/lower.rs:11223-11239 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_ide/src/listing.rs:262— baml_language/crates/baml_ide/src/listing.rs:262-278 | baml_language/crates/baml_ide/src/listing.rs:333-349 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (17 lines × 2) baml_language/crates/baml_lsp_server/src/playground_server.rs:1954— baml_language/crates/baml_lsp_server/src/playground_server.rs:1954-1970 | baml_language/crates/baml_lsp_server/src/playground_server.rs:1987-2003 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_lsp_server/src/playground_server.rs:2209— baml_language/crates/baml_lsp_server/src/playground_server.rs:2209-2225 | baml_language/crates/baml_lsp_server/src/playground_server.rs:2247-2263 — both copies are in the same file, so extract the block into 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) baml_language/crates/bex_vm/src/package_baml/array.rs:157— baml_language/crates/bex_vm/src/package_baml/array.rs:157-173 | baml_language/crates/bex_vm/src/package_baml/root.rs:917-933 — 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 (17 lines × 2) baml_language/crates/bex_vm/src/package_baml/array.rs:1111— baml_language/crates/bex_vm/src/package_baml/array.rs:1111-1127 | baml_language/crates/bex_vm/src/package_baml/array.rs:1139-1155 — both copies are in the same file, so extract the block into 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) baml_language/crates/bex_vm/src/package_baml/ops.rs:521— baml_language/crates/bex_vm/src/package_baml/ops.rs:521-537 | baml_language/crates/bex_vm/src/package_baml/ops.rs:554-570 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (17 lines × 2) baml_language/crates/bex_vm/src/vm.rs:11430— baml_language/crates/bex_vm/src/vm.rs:11430-11446 | baml_language/crates/bex_vm/src/vm.rs:11491-11507 — both copies are in the same file, so extract the block into 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) baml_language/crates/btel_snapshot/src/graph.rs:332— baml_language/crates/btel_snapshot/src/graph.rs:332-348 | baml_language/crates/btel_snapshot/src/shape.rs:154-170 — 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 (17 lines × 2) baml_language/sdks/go/sdkgen_go/src/names.rs:431— baml_language/sdks/go/sdkgen_go/src/names.rs:431-447 | baml_language/sdks/go/sdkgen_go/src/names.rs:530-546 — both copies are in the same file, so extract the block into 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) engine/baml-lib/ast/src/formatter/mod.rs:296— engine/baml-lib/ast/src/formatter/mod.rs:296-312 | engine/baml-lib/ast/src/formatter/mod.rs:349-365 — both copies are in the same file, so extract the block into 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) engine/baml-lib/ast/src/parser/parse_expression.rs:234— engine/baml-lib/ast/src/parser/parse_expression.rs:234-250 | engine/baml-lib/ast/src/parser/parse_expression.rs:425-441 — both copies are in the same file, so extract the block into 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) engine/baml-lib/jsonish/src/helpers/mod.rs:299— engine/baml-lib/jsonish/src/helpers/mod.rs:299-315 | engine/baml-runtime/src/internal/prompt_renderer/render_output_format.rs:514-530 — before extracting anything, compare `engine/baml-lib/jsonish/src/helpers/mod.rs` and `engine/baml-runtime/src/internal/prompt_renderer/render_output_format.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 48 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (17 lines × 2) engine/baml-runtime/src/internal/llm_client/mod.rs:330— engine/baml-runtime/src/internal/llm_client/mod.rs:330-346 | engine/baml-runtime/src/internal/llm_client/mod.rs:360-376 — both copies are in the same file, so extract the block into 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) engine/baml-runtime/src/runtime_methods/prepare_function.rs:119— engine/baml-runtime/src/runtime_methods/prepare_function.rs:119-135 | engine/baml-runtime/src/runtime_methods/prepare_function.rs:161-177 — both copies are in the same file, so extract the block into 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) engine/baml-runtime/src/types/response.rs:432— engine/baml-runtime/src/types/response.rs:432-448 | engine/baml-runtime/src/types/response.rs:463-479 — both copies are in the same file, so extract the block into 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) engine/language_client_cffi/src/raw_ptr_wrapper/type_builder/objects.rs:424— engine/language_client_cffi/src/raw_ptr_wrapper/type_builder/objects.rs:424-440 | engine/language_client_cffi/src/raw_ptr_wrapper/type_builder/objects.rs:448-464 — both copies are in the same file, so extract the block into 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) languages/rust/baml/src/codec/helpers.rs:14— languages/rust/baml/src/codec/helpers.rs:14-30 | languages/rust/baml/src/lib.rs:149-165 — 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 (17 lines × 2) baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs:67— baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs:67-83 | engine/baml-lib/jsonish/src/jsonish/parser/fixing_parser/json_parse_state.rs:71-87 — before extracting anything, compare `baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs` and `engine/baml-lib/jsonish/src/jsonish/parser/fixing_parser/json_parse_state.rs` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 575 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (17 lines × 2) engine/baml-runtime/src/async_interpreter_runtime.rs:723— engine/baml-runtime/src/async_interpreter_runtime.rs:723-739 | engine/baml-runtime/src/async_vm_runtime.rs:1035-1051 — before extracting anything, compare `engine/baml-runtime/src/async_interpreter_runtime.rs` and `engine/baml-runtime/src/async_vm_runtime.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 92 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (17 lines × 2) baml_language/crates/baml_query_btel/src/ingest.rs:1429— baml_language/crates/baml_query_btel/src/ingest.rs:1429-1445 | baml_language/crates/baml_query_btel/src/ingest.rs:1775-1793 — both copies are in the same file, so extract the block into 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) REDACTED:53— REDACTED:53-69 | REDACTED:96-112 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:53` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (17 lines × 2) engine/language_client_go/pkg/rawobjects_constructors.go:37— engine/language_client_go/pkg/rawobjects_constructors.go:37-53 | engine/language_client_go/pkg/rawobjects_constructors.go:75-91 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `engine/language_client_go/pkg/rawobjects_constructors.go:37` it begins part-way through the construct above it, so those 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.
InferenceContext::finish (cyclomatic 201) baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:12601— InferenceContext::finish has cyclomatic complexity 201 (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.
InferenceContext::infer_expr (cyclomatic 78) baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:2857— InferenceContext::infer_expr has cyclomatic complexity 78 (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.
InferenceContext::sub (cyclomatic 52) baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:4509— InferenceContext::sub has cyclomatic complexity 52 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
InferenceContext::check_call_args (cyclomatic 47) baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:6317— InferenceContext::check_call_args 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.
InferenceContext::infer_catch (cyclomatic 35) baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:11323— InferenceContext::infer_catch has cyclomatic complexity 35 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
InferenceContext::infer_stmt (cyclomatic 32) baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:3408— InferenceContext::infer_stmt has cyclomatic complexity 32 (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.
InferenceContext::infer_lambda (cyclomatic 32) baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:8740— InferenceContext::infer_lambda 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.
InferenceContext::member_callee (cyclomatic 31) baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:6921— InferenceContext::member_callee 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.
InferenceContext::resolve_value_path (cyclomatic 31) baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:7410— InferenceContext::resolve_value_path 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.
InferenceContext::infer_callee (cyclomatic 30) baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:6660— InferenceContext::infer_callee 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.
InferenceContext::lower_array_pattern (cyclomatic 29) baml_language/crates/baml_compiler2_hir_ty/src/infer/pat.rs:1523— InferenceContext::lower_array_pattern has cyclomatic complexity 29 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
InferenceContext::lower_interface_pattern (cyclomatic 27) baml_language/crates/baml_compiler2_hir_ty/src/infer/pat.rs:720— InferenceContext::lower_interface_pattern has cyclomatic complexity 27 (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.
InferenceContext::infer_match (cyclomatic 26) baml_language/crates/baml_compiler2_hir_ty/src/infer/pat.rs:66— InferenceContext::infer_match 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.
InferenceContext::infer_binary (cyclomatic 26) baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:5208— InferenceContext::infer_binary 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.
InferenceContext::attempt (cyclomatic 25) baml_language/crates/baml_compiler2_hir_ty/src/infer/obligations.rs:386— InferenceContext::attempt 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.
InferenceContext::lower_class_pattern (cyclomatic 24) baml_language/crates/baml_compiler2_hir_ty/src/infer/pat.rs:1311— InferenceContext::lower_class_pattern 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.
InferenceContext::infer_assign (cyclomatic 21) baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:4267— InferenceContext::infer_assign 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.
InferenceContext::field_access_resolved (cyclomatic 21) baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:10001— InferenceContext::field_access_resolved 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.
InferenceContext::take_unresolved_infer_diagnostics (cyclomatic 18) baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:12178— InferenceContext::take_unresolved_infer_diagnostics 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.
InferenceContext::seed_implicit_llm_schema (cyclomatic 17) baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:6149— InferenceContext::seed_implicit_llm_schema has cyclomatic complexity 17 (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.
InferenceContext::infer_source_object (cyclomatic 17) baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:9559— InferenceContext::infer_source_object 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.
InferenceContext::infer_exported_object (cyclomatic 17) baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:9766— InferenceContext::infer_exported_object has cyclomatic complexity 17 (threshold 15). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
InferenceContext::try_solve_bounded_var (cyclomatic 16) baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:14449— InferenceContext::try_solve_bounded_var 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.
bex_vm::debug::display_instruction_textual (cyclomatic 109) baml_language/crates/bex_vm/src/debug.rs:756— bex_vm::debug::display_instruction_textual has cyclomatic complexity 109 (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.
bex_vm::package_baml::root::render_to_sink (cyclomatic 46) baml_language/crates/bex_vm/src/package_baml/root.rs:523— bex_vm::package_baml::root::render_to_sink 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.
bex_vm::package_baml::csv::scan_record (cyclomatic 43) baml_language/crates/bex_vm/src/package_baml/csv.rs:855— bex_vm::package_baml::csv::scan_record 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.
bex_vm::package_baml::csv::parse_reader_options (cyclomatic 34) baml_language/crates/bex_vm/src/package_baml/csv.rs:371— bex_vm::package_baml::csv::parse_reader_options 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.
bex_vm::package_baml::sap::empty_value (cyclomatic 34) baml_language/crates/bex_vm/src/package_baml/sap.rs:1567— bex_vm::package_baml::sap::empty_value has cyclomatic complexity 34 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
bex_vm::package_baml::root::deep_copy_value_recursive (cyclomatic 32) baml_language/crates/bex_vm/src/package_baml/root.rs:768— bex_vm::package_baml::root::deep_copy_value_recursive 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.
bex_vm::package_baml::csv::poll_record (cyclomatic 24) baml_language/crates/bex_vm/src/package_baml/csv.rs:1211— bex_vm::package_baml::csv::poll_record 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.
bex_vm::package_reflect::graft::relocate (cyclomatic 24) baml_language/crates/bex_vm/src/package_reflect/graft.rs:1172— bex_vm::package_reflect::graft::relocate 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.
bex_vm::package_baml::csv::convert_cell (cyclomatic 23) baml_language/crates/bex_vm/src/package_baml/csv.rs:1426— bex_vm::package_baml::csv::convert_cell 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.
bex_vm::package_baml::json::path::select (cyclomatic 22) baml_language/crates/bex_vm/src/package_baml/json/path.rs:14— bex_vm::package_baml::json::path::select 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.
bex_vm::package_reflect::type_class::render_type_value_source (cyclomatic 22) baml_language/crates/bex_vm/src/package_reflect/type_class.rs:1240— bex_vm::package_reflect::type_class::render_type_value_source 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.
bex_vm::package_baml::json::copy_json (cyclomatic 21) baml_language/crates/bex_vm/src/package_baml/json/mod.rs:273— bex_vm::package_baml::json::copy_json 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.
bex_vm::debug::display_instruction (cyclomatic 20) baml_language/crates/bex_vm/src/debug.rs:113— bex_vm::debug::display_instruction has cyclomatic complexity 20 (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.
bex_vm::call_specialize::specialize_calls (cyclomatic 17) baml_language/crates/bex_vm/src/call_specialize.rs:7— bex_vm::call_specialize::specialize_calls 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.
bex_vm::package_baml::csv::decode_record_to_instance (cyclomatic 17) baml_language/crates/bex_vm/src/package_baml/csv.rs:1560— bex_vm::package_baml::csv::decode_record_to_instance 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.
bex_vm::package_baml::json::decode::decode_one (cyclomatic 17) baml_language/crates/bex_vm/src/package_baml/json/decode.rs:791— bex_vm::package_baml::json::decode::decode_one 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.
bex_vm::package_reflect::type_class::first_open_interface (cyclomatic 17) baml_language/crates/bex_vm/src/package_reflect/type_class.rs:844— bex_vm::package_reflect::type_class::first_open_interface 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.
bex_vm::package_reflect::type_class::expanded_type_value_nominals (cyclomatic 17) baml_language/crates/bex_vm/src/package_reflect/type_class.rs:1170— bex_vm::package_reflect::type_class::expanded_type_value_nominals 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.
bex_vm::debug::display_bytecode (cyclomatic 16) baml_language/crates/bex_vm/src/debug.rs:537— bex_vm::debug::display_bytecode 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.
bex_vm::package_baml::csv::parse_writer_options (cyclomatic 16) baml_language/crates/bex_vm/src/package_baml/csv.rs:494— bex_vm::package_baml::csv::parse_writer_options 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.
bex_vm::package_baml::csv::value_cell_text (cyclomatic 16) baml_language/crates/bex_vm/src/package_baml/csv.rs:1963— bex_vm::package_baml::csv::value_cell_text 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.
bex_vm::package_reflect::runtime_class_builder::planned_pending_type (cyclomatic 16) baml_language/crates/bex_vm/src/package_reflect/runtime_class_builder.rs:810— bex_vm::package_reflect::runtime_class_builder::planned_pending_type 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.
baml_compiler2_emit::stack_carry::is_stack_carry_use_safe (cognitive 90) baml_language/crates/baml_compiler2_emit/src/stack_carry.rs:178— baml_compiler2_emit::stack_carry::is_stack_carry_use_safe has cognitive complexity 90 (threshold 15). Drivers by points: if/else 24 (68 pts), loops 4 (11 pts), match/switch 4 (9 pts), boolean chains 2 (nesting depth added 56). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
baml_compiler2_emit::stack_carry::simulate_terminator_stack (cognitive 69) baml_language/crates/baml_compiler2_emit/src/stack_carry.rs:575— baml_compiler2_emit::stack_carry::simulate_terminator_stack has cognitive complexity 69 (threshold 15). Drivers by points: if/else 29 (63 pts), boolean chains 3, loops 1 (2 pts), match/switch 1 (nesting depth added 35). 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.
baml_compiler2_emit::analysis::collect_uses_in_terminator (cognitive 46) baml_language/crates/baml_compiler2_emit/src/analysis.rs:867— baml_compiler2_emit::analysis::collect_uses_in_terminator has cognitive complexity 46 (threshold 15). Drivers by points: if/else 16 (39 pts), loops 3 (6 pts), match/switch 1 (nesting depth added 26). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
baml_compiler2_emit::analysis::classify_locals (cognitive 35) baml_language/crates/baml_compiler2_emit/src/analysis.rs:1394— baml_compiler2_emit::analysis::classify_locals has cognitive complexity 35 (threshold 15). Drivers by points: if/else 17 (24 pts), boolean chains 9, loops 1, match/switch 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.
baml_compiler2_emit::pull_semantics::walk_rvalue_pull (cognitive 33) baml_language/crates/baml_compiler2_emit/src/pull_semantics.rs:386— baml_compiler2_emit::pull_semantics::walk_rvalue_pull has cognitive complexity 33 (threshold 15). Drivers by points: loops 11 (27 pts), if/else 1 (3 pts), match/switch 2 (3 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.
baml_compiler2_emit::analysis::collect_def_use (cognitive 30) baml_language/crates/baml_compiler2_emit/src/analysis.rs:606— baml_compiler2_emit::analysis::collect_def_use has cognitive complexity 30 (threshold 15). Drivers by points: if/else 4 (15 pts), loops 4 (8 pts), match/switch 2 (7 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.
baml_compiler2_emit::analysis::compute_dominators (cognitive 27) baml_language/crates/baml_compiler2_emit/src/analysis.rs:532— baml_compiler2_emit::analysis::compute_dominators has cognitive complexity 27 (threshold 15). Drivers by points: if/else 4 (16 pts), loops 4 (10 pts), boolean chains 1 (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
baml_compiler2_emit::package::type_pass (cognitive 25) baml_language/crates/baml_compiler2_emit/src/package/mod.rs:189— baml_compiler2_emit::package::type_pass has cognitive complexity 25 (threshold 15). Drivers by points: loops 12 (18 pts), if/else 2 (6 pts), boolean chains 1 (nesting depth added 10). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
baml_compiler2_emit::collect_lambda_capture_infos (cognitive 24) baml_language/crates/baml_compiler2_emit/src/lib.rs:785— baml_compiler2_emit::collect_lambda_capture_infos has cognitive complexity 24 (threshold 15). Drivers by points: if/else 5 (17 pts), loops 3 (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.
baml_compiler2_emit::analysis::is_return_phi (cognitive 23) baml_language/crates/baml_compiler2_emit/src/analysis.rs:1785— baml_compiler2_emit::analysis::is_return_phi has cognitive complexity 23 (threshold 15). Drivers by points: if/else 7 (13 pts), match/switch 4 (8 pts), loops 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.
baml_compiler2_emit::compute_function_metadata (cognitive 22) baml_language/crates/baml_compiler2_emit/src/lib.rs:298— baml_compiler2_emit::compute_function_metadata has cognitive complexity 22 (threshold 15). Drivers by points: if/else 15 (16 pts), match/switch 5, 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.
baml_compiler2_emit::package::finish::fill_interface_defaults (cognitive 20) baml_language/crates/baml_compiler2_emit/src/package/finish.rs:142— baml_compiler2_emit::package::finish::fill_interface_defaults has cognitive complexity 20 (threshold 15). Drivers by points: if/else 4 (14 pts), loops 3 (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.
baml_compiler2_emit::analysis::predecessors_cover_block (cognitive 19) baml_language/crates/baml_compiler2_emit/src/analysis.rs:1610— baml_compiler2_emit::analysis::predecessors_cover_block has cognitive complexity 19 (threshold 15). Drivers by points: if/else 9 (16 pts), boolean chains 2, 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.
baml_compiler2_emit::stack_carry::simulate_stack_consuming_aggregate (cognitive 18) baml_language/crates/baml_compiler2_emit/src/stack_carry.rs:1174— baml_compiler2_emit::stack_carry::simulate_stack_consuming_aggregate has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (13 pts), loops 4, 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.
baml_compiler2_emit::analysis::rematerializable (cognitive 17) baml_language/crates/baml_compiler2_emit/src/analysis.rs:1309— baml_compiler2_emit::analysis::rematerializable has cognitive complexity 17 (threshold 15). Drivers by points: if/else 12 (13 pts), boolean chains 3, match/switch 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.
baml_compiler2_emit::analysis::is_call_result_aggregate_operand (cognitive 17) baml_language/crates/baml_compiler2_emit/src/analysis.rs:1998— baml_compiler2_emit::analysis::is_call_result_aggregate_operand has cognitive complexity 17 (threshold 15). Drivers by points: if/else 9 (15 pts), boolean chains 1, 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.
baml_compiler2_emit::package::finish::fill_class_methods (cognitive 17) baml_language/crates/baml_compiler2_emit/src/package/finish.rs:196— baml_compiler2_emit::package::finish::fill_class_methods has cognitive complexity 17 (threshold 15). Drivers by points: if/else 3 (11 pts), loops 3 (6 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.
baml_compiler2_emit::pull_semantics::resolve_constant_function_item_inner (cognitive 17) baml_language/crates/baml_compiler2_emit/src/pull_semantics.rs:282— baml_compiler2_emit::pull_semantics::resolve_constant_function_item_inner has cognitive complexity 17 (threshold 15). Drivers by points: if/else 4 (11 pts), match/switch 3 (6 pts) (nesting depth added 10). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
baml_compiler2_emit::stack_carry::simulate_statement_stack (cognitive 17) baml_language/crates/baml_compiler2_emit/src/stack_carry.rs:460— baml_compiler2_emit::stack_carry::simulate_statement_stack has cognitive complexity 17 (threshold 15). Drivers by points: match/switch 4 (10 pts), if/else 2 (7 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.
baml_compiler2_emit::package::bodies::emit_bodies_parallel (cognitive 16) baml_language/crates/baml_compiler2_emit/src/package/bodies.rs:244— baml_compiler2_emit::package::bodies::emit_bodies_parallel has cognitive complexity 16 (threshold 15). Drivers by points: if/else 3 (7 pts), match/switch 2 (5 pts), loops 3 (4 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
baml_compiler2_emit::package::bodies::merge_item (cognitive 16) baml_language/crates/baml_compiler2_emit/src/package/bodies.rs:374— baml_compiler2_emit::package::bodies::merge_item has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (12 pts), loops 2, boolean chains 1, match/switch 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.
baml_compiler2_emit::package::finish::emit_tail (cognitive 16) baml_language/crates/baml_compiler2_emit/src/package/finish.rs:324— baml_compiler2_emit::package::finish::emit_tail has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (8 pts), loops 3 (5 pts), match/switch 1 (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.
D30 · Dependency Vulnerabilities· Medium advisory (unsound) · ×22
LoweringContext::lower_call_with_callee (cyclomatic 70) baml_language/crates/baml_compiler2_mir/src/lower.rs:8243— LoweringContext::lower_call_with_callee has cyclomatic complexity 70 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
LoweringContext::try_lower_as_switch (cyclomatic 61) baml_language/crates/baml_compiler2_mir/src/lower.rs:12653— LoweringContext::try_lower_as_switch has cyclomatic complexity 61 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
LoweringContext::lower_stmt (cyclomatic 45) baml_language/crates/baml_compiler2_mir/src/lower.rs:11823— LoweringContext::lower_stmt has cyclomatic complexity 45 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
LoweringContext::lower_pattern_test_with_catch_policy (cyclomatic 41) baml_language/crates/baml_compiler2_mir/src/lower.rs:13859— LoweringContext::lower_pattern_test_with_catch_policy has cyclomatic complexity 41 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
LoweringContext::lower_expr_inner (cyclomatic 39) baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:1958— LoweringContext::lower_expr_inner 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.
LoweringContext::lower_path_expr (cyclomatic 39) baml_language/crates/baml_compiler2_mir/src/lower.rs:6431— LoweringContext::lower_path_expr 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.
LoweringContext::lower_expr (cyclomatic 38) baml_language/crates/baml_compiler2_mir/src/lower.rs:5949— LoweringContext::lower_expr 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.
LoweringContext::lower_binary_expr (cyclomatic 37) baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:2210— LoweringContext::lower_binary_expr 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.
LoweringContext::lower_match_arm (cyclomatic 33) baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:2870— LoweringContext::lower_match_arm has cyclomatic complexity 33 (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.
LoweringContext::lower_object_literal (cyclomatic 32) baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:5376— LoweringContext::lower_object_literal has cyclomatic complexity 32 (threshold 15). Of this number, 28 points are the body's own statements and 4 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.
LoweringContext::lower_block_expr (cyclomatic 27) baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:1826— LoweringContext::lower_block_expr 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.
LoweringContext::lower_catch_arm (cyclomatic 24) baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:3378— LoweringContext::lower_catch_arm 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.
LoweringContext::try_lower_assignment (cyclomatic 22) baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:2412— LoweringContext::try_lower_assignment has cyclomatic complexity 22 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
LoweringContext::lower_spawn_expr (cyclomatic 21) baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:2041— LoweringContext::lower_spawn_expr 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.
LoweringContext::lower_lvalue (cyclomatic 21) baml_language/crates/baml_compiler2_mir/src/lower.rs:12283— LoweringContext::lower_lvalue 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.
LoweringContext::lower_multi_segment_path_as_field_chain (cyclomatic 20) baml_language/crates/baml_compiler2_mir/src/lower.rs:6810— LoweringContext::lower_multi_segment_path_as_field_chain 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.
LoweringContext::check_intrinsic (cyclomatic 20) baml_language/crates/baml_compiler2_mir/src/lower.rs:9226— LoweringContext::check_intrinsic 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.
LoweringContext::lower_unary_expr (cyclomatic 19) baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:2506— LoweringContext::lower_unary_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.
LoweringContext::lower_member_access (cyclomatic 18) baml_language/crates/baml_compiler2_mir/src/lower.rs:10383— LoweringContext::lower_member_access 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.
LoweringContext::lower_let_parts (cyclomatic 16) baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:5764— LoweringContext::lower_let_parts 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.
LoweringContext::lower_match_chain (cyclomatic 16) baml_language/crates/baml_compiler2_mir/src/lower.rs:13086— LoweringContext::lower_match_chain has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This is NOT this file's highest cyclomatic complexity: LoweringContext::convert_binop (cyclomatic 18) 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.
Boundary violation [package:relative-cross-package] baml_language/sdks/typescript/bridge_typescript_web/typescript_src/index.ts:8— baml_language/sdks/typescript/bridge_typescript_web/typescript_src/index.ts:8 reaches into another package with a relative path (./shared/stream.js) — import the package by name instead.
Boundary violation [package:relative-cross-package] baml_language/sdks/typescript/bridge_typescript_web/typescript_src/index.ts:17— baml_language/sdks/typescript/bridge_typescript_web/typescript_src/index.ts:17 reaches into another package with a relative path (./shared/errors.js) — import the package by name instead.
Boundary violation [package:relative-cross-package] baml_language/sdks/typescript/bridge_typescript_web/typescript_src/native.ts:40— baml_language/sdks/typescript/bridge_typescript_web/typescript_src/native.ts:40 reaches into another package with a relative path (./shared/errors.js) — import the package by name instead.
Boundary violation [package:relative-cross-package] baml_language/sdks/typescript/bridge_typescript_web/typescript_src/platform.ts:2— baml_language/sdks/typescript/bridge_typescript_web/typescript_src/platform.ts:2 reaches into another package with a relative path (./shared/errors.js) — import the package by name instead.
Boundary violation [package:relative-cross-package] baml_language/sdks/typescript/sdkgen_typescript_shared/src/invocation_facade.ts:1— baml_language/sdks/typescript/sdkgen_typescript_shared/src/invocation_facade.ts:1 reaches into another package with a relative path (./vendor/trace/index.js) — import the package by name instead.
Boundary violation [package:relative-cross-package] baml_language/sdks/typescript/sdkgen_typescript_shared/src/invocation_facade.ts:2— baml_language/sdks/typescript/sdkgen_typescript_shared/src/invocation_facade.ts:2 reaches into another package with a relative path (./baml/spawn/index.js) — import the package by name instead.
Boundary violation [package:third-party-deep-import] tools/stdlib-matrix/extractors/ts-surface.mjs:181— tools/stdlib-matrix/extractors/ts-surface.mjs:181 imports typescript/lib/typescript.js, reaching past a declared dependency's public entry into its build output — that path is the package's toolchain layout, not its API, and a minor version bump can relocate it with no semver signal. Import from the package's documented entry point instead.
Boundary violation [package:deep-import] typescript/apps/fiddle-web-app/app/[project_id]/_components/ProjectView.tsx:26— typescript/apps/fiddle-web-app/app/[project_id]/_components/ProjectView.tsx:26 imports @baml/playground-common/lib/feedback_widget, which the target package's REDACTED `exports` does not declare — use a declared entry or declare the subpath.
Boundary violation [package:test-suite-dependency] REDACTED:15— REDACTED:15 imports typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/prompt-preview/test-panel/test-runner.ts, a module inside the test suite — test helpers carry no compatibility contract and are maintained for the suite, not as an API, so production code that depends on one is coupled to a module nobody keeps stable. Move the shared helper into a source directory both layers may depend on.
Boundary violation [package:test-suite-dependency] typescript/packages/playground-common/src/features/detail-panel/components/DetailPanel.tsx:26— typescript/packages/playground-common/src/features/detail-panel/components/DetailPanel.tsx:26 imports typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/prompt-preview/test-panel/test-runner.ts, a module inside the test suite — test helpers carry no compatibility contract and are maintained for the suite, not as an API, so production code that depends on one is coupled to a module nobody keeps stable. Move the shared helper into a source directory both layers may depend on.
Boundary violation [package:third-party-deep-import] typescript/packages/playground-common/src/features/graph/layout/node/algorithms/elk-mermaid.ts:1— typescript/packages/playground-common/src/features/graph/layout/node/algorithms/elk-mermaid.ts:1 imports elkjs/lib/elk.bundled.js, reaching past a declared dependency's public entry into its build output — that path is the package's toolchain layout, not its API, and a minor version bump can relocate it with no semver signal. Import from the package's documented entry point instead.
Boundary violation [package:test-suite-dependency] typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/side-bar/function-item.tsx:9— typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/side-bar/function-item.tsx:9 imports typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/prompt-preview/test-panel/atoms.ts, a module inside the test suite — test helpers carry no compatibility contract and are maintained for the suite, not as an API, so production code that depends on one is coupled to a module nobody keeps stable. Move the shared helper into a source directory both layers may depend on.
Boundary violation [package:test-suite-dependency] typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/side-bar/function-item.tsx:13— typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/side-bar/function-item.tsx:13 imports typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/prompt-preview/test-panel/testStateUtils.ts, a module inside the test suite — test helpers carry no compatibility contract and are maintained for the suite, not as an API, so production code that depends on one is coupled to a module nobody keeps stable. Move the shared helper into a source directory both layers may depend on.
Boundary violation [package:test-suite-dependency] typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/side-bar/index.tsx:36— typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/side-bar/index.tsx:36 imports typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/prompt-preview/test-panel/test-runner.ts, a module inside the test suite — test helpers carry no compatibility contract and are maintained for the suite, not as an API, so production code that depends on one is coupled to a module nobody keeps stable. Move the shared helper into a source directory both layers may depend on.
Boundary violation [package:test-suite-dependency] typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/side-bar/index.tsx:37— typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/side-bar/index.tsx:37 imports typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/prompt-preview/test-panel/atoms.ts, a module inside the test suite — test helpers carry no compatibility contract and are maintained for the suite, not as an API, so production code that depends on one is coupled to a module nobody keeps stable. Move the shared helper into a source directory both layers may depend on.
Boundary violation [package:test-suite-dependency] typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/side-bar/test-item.tsx:21— typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/side-bar/test-item.tsx:21 imports typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/prompt-preview/test-panel/atoms.ts, a module inside the test suite — test helpers carry no compatibility contract and are maintained for the suite, not as an API, so production code that depends on one is coupled to a module nobody keeps stable. Move the shared helper into a source directory both layers may depend on.
Boundary violation [package:test-suite-dependency] typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/side-bar/test-item.tsx:25— typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/side-bar/test-item.tsx:25 imports typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/prompt-preview/test-panel/test-runner.ts, a module inside the test suite — test helpers carry no compatibility contract and are maintained for the suite, not as an API, so production code that depends on one is coupled to a module nobody keeps stable. Move the shared helper into a source directory both layers may depend on.
Boundary violation [package:test-suite-dependency] typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/side-bar/test-item.tsx:26— typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/side-bar/test-item.tsx:26 imports typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/prompt-preview/test-panel/testStateUtils.ts, a module inside the test suite — test helpers carry no compatibility contract and are maintained for the suite, not as an API, so production code that depends on one is coupled to a module nobody keeps stable. Move the shared helper into a source directory both layers may depend on.
Boundary violation [package:deep-import] typescript2/app-promptfiddle/src/playground/baml-lsp-worker.ts:20— typescript2/app-promptfiddle/src/playground/baml-lsp-worker.ts:20 imports @b/pkg-playground/wasm-panic, which the target package's REDACTED `exports` does not declare — use a declared entry or declare the subpath.
Boundary violation [package:third-party-deep-import] typescript2/app-type-quiz/src/highlight.ts:9— typescript2/app-type-quiz/src/highlight.ts:9 imports highlight.js/lib/core, reaching past a declared dependency's public entry into its build output — that path is the package's toolchain layout, not its API, and a minor version bump can relocate it with no semver signal. Import from the package's documented entry point instead.
Boundary violation [package:third-party-deep-import] typescript2/pkg-playground/src/graph/layout.ts:1— typescript2/pkg-playground/src/graph/layout.ts:1 imports elkjs/lib/elk.bundled.js, reaching past a declared dependency's public entry into its build output — that path is the package's toolchain layout, not its API, and a minor version bump can relocate it with no semver signal. Import from the package's documented entry point instead.
X24 · Document value interpolated into markup unescaped· Untrusted text written into markup unescaped · ×21
Untrusted text written into markup unescaped engine/baml-runtime/src/control_flow/mermaid-sandbox/app/components/MermaidDiagram.tsx:75— `svg` is text this program did not author, and it is written into the text of an element through `dangerouslySetInnerHTML` with nothing encoding it for that place. Whoever controls the value controls the markup: it can close the element or attribute it sits in and open a script of its own. Encode it for HTML at this site, render it through the framework's escaping output, or sanitise it if it must stay markup.
Untrusted text written into markup unescaped typescript/packages/playground-common/src/graph-primitives/edges/EdgeController/useEdgeDraggable.tsx:144— ``* { cursor: ${cursorStyle} !important; }`` is text this program did not author, and it is written into the text of an element through `innerHTML` with nothing encoding it for that place. Whoever controls the value controls the markup: it can close the element or attribute it sits in and open a script of its own. Encode it for HTML at this site, render it through the framework's escaping output, or sanitise it if it must stay markup.
Untrusted text written into markup unescaped typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/prompt-preview/prompt-preview-curl.tsx:378— `finalHtml` is text this program did not author, and it is written into the text of an element through `dangerouslySetInnerHTML` with nothing encoding it for that place. Whoever controls the value controls the markup: it can close the element or attribute it sits in and open a script of its own. Encode it for HTML at this site, render it through the framework's escaping output, or sanitise it if it must stay markup.
Untrusted text written into markup unescaped typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/prompt-preview/webview-media.tsx:615— `url` is text this program did not author, and it is written into a script or style context through `innerHTML` with nothing encoding it for that place. Whoever controls the value controls the markup: it can close the element or attribute it sits in and open a script of its own. A script or style context needs its own escaping (or a JSON serialiser that escapes `<`); better, pass the value through a data attribute.
Untrusted text written into markup unescaped REDACTED:84— `Object.entries(THEMES).map(([theme,prefix])=>`
${prefix} [data-chart=${id}] {
${colorConfig.map(([key,itemConfig])=>{…` is text this program did not author, and it is written into the text of an element through `dangerouslySetInnerHTML` with nothing encoding it for that place. Whoever controls the value controls the markup: it can close the element or attribute it sits in and open a script of its own. Encode it for HTML at this site, render it through the framework's escaping output, or sanitise it if it must stay markup.
Untrusted text written into markup unescaped typescript2/app-beps/src/components/ui/mermaid-diagram.tsx:78— `svg` is text this program did not author, and it is written into the text of an element through `dangerouslySetInnerHTML` with nothing encoding it for that place. Whoever controls the value controls the markup: it can close the element or attribute it sits in and open a script of its own. Encode it for HTML at this site, render it through the framework's escaping output, or sanitise it if it must stay markup.
Untrusted text written into markup unescaped REDACTED:213— `html` is text this program did not author, and it is written into the text of an element through `dangerouslySetInnerHTML` with nothing encoding it for that place. Whoever controls the value controls the markup: it can close the element or attribute it sits in and open a script of its own. Encode it for HTML at this site, render it through the framework's escaping output, or sanitise it if it must stay markup.
Untrusted text written into markup unescaped typescript2/app-website/app/atb/_components/code-view.tsx:107— `html` is text this program did not author, and it is written into the text of an element through `dangerouslySetInnerHTML` with nothing encoding it for that place. Whoever controls the value controls the markup: it can close the element or attribute it sits in and open a script of its own. Encode it for HTML at this site, render it through the framework's escaping output, or sanitise it if it must stay markup.
Untrusted text written into markup unescaped typescript2/app-website/app/baml-intro/_components/TenetsAccordion.tsx:115— `file` is text this program did not author, and it is written into the text of an element through `innerHTML` with nothing encoding it for that place. Whoever controls the value controls the markup: it can close the element or attribute it sits in and open a script of its own. Encode it for HTML at this site, render it through the framework's escaping output, or sanitise it if it must stay markup.
Untrusted text written into markup unescaped typescript2/app-website/app/baml-intro/_components/TenetsAccordion.tsx:145— `text` is text this program did not author, and it is written into the text of an element through `innerHTML` with nothing encoding it for that place. Whoever controls the value controls the markup: it can close the element or attribute it sits in and open a script of its own. Encode it for HTML at this site, render it through the framework's escaping output, or sanitise it if it must stay markup.
Untrusted text written into markup unescaped typescript2/app-website/app/baml-intro/_components/TenetsAccordion.tsx:491— `name` is text this program did not author, and it is written into the text of an element through `innerHTML` with nothing encoding it for that place. Whoever controls the value controls the markup: it can close the element or attribute it sits in and open a script of its own. Encode it for HTML at this site, render it through the framework's escaping output, or sanitise it if it must stay markup.
Untrusted text written into markup unescaped typescript2/app-website/app/baml-intro/_components/TenetsAccordion.tsx:508— `s.name` is text this program did not author, and it is written into the text of an element through `innerHTML` with nothing encoding it for that place. Whoever controls the value controls the markup: it can close the element or attribute it sits in and open a script of its own. Encode it for HTML at this site, render it through the framework's escaping output, or sanitise it if it must stay markup.
Untrusted text written into markup unescaped typescript2/app-website/app/baml-intro/_components/TenetsAccordion.tsx:509— `COLOR[s.cat]` is text this program did not author, and it is written into a script or style context through `innerHTML` with nothing encoding it for that place. Whoever controls the value controls the markup: it can close the element or attribute it sits in and open a script of its own. A script or style context needs its own escaping (or a JSON serialiser that escapes `<`); better, pass the value through a data attribute.
Untrusted text written into markup unescaped REDACTED:103— `highlighted` is text this program did not author, and it is written into the text of an element through `dangerouslySetInnerHTML` with nothing encoding it for that place. Whoever controls the value controls the markup: it can close the element or attribute it sits in and open a script of its own. Encode it for HTML at this site, render it through the framework's escaping output, or sanitise it if it must stay markup.
Untrusted text written into markup unescaped typescript2/app-website/components/magicui/syntax-typing-animation.tsx:94— `highlightedCode` is text this program did not author, and it is written into the text of an element through `dangerouslySetInnerHTML` with nothing encoding it for that place. Whoever controls the value controls the markup: it can close the element or attribute it sits in and open a script of its own. Encode it for HTML at this site, render it through the framework's escaping output, or sanitise it if it must stay markup.
Untrusted text written into markup unescaped REDACTED:45— `JSON.stringify(data)` is text this program did not author, and it is written into the text of an element through `dangerouslySetInnerHTML` with nothing encoding it for that place. Whoever controls the value controls the markup: it can close the element or attribute it sits in and open a script of its own. Encode it for HTML at this site, render it through the framework's escaping output, or sanitise it if it must stay markup.
Untrusted text written into markup unescaped REDACTED:65— `highlightedText` is text this program did not author, and it is written into the text of an element through `dangerouslySetInnerHTML` with nothing encoding it for that place. Whoever controls the value controls the markup: it can close the element or attribute it sits in and open a script of its own. Encode it for HTML at this site, render it through the framework's escaping output, or sanitise it if it must stay markup.
Untrusted text written into markup unescaped REDACTED:391— `badge.className` is text this program did not author, and it is written into a quoted attribute value through markup built here with nothing encoding it for that place. Whoever controls the value controls the markup: it can close the element or attribute it sits in and open a script of its own. Encode it for HTML at this site, render it through the framework's escaping output, or sanitise it if it must stay markup.
Untrusted text written into markup unescaped REDACTED:410— `kind` is text this program did not author, and it is written into a quoted attribute value through markup built here with nothing encoding it for that place. Whoever controls the value controls the markup: it can close the element or attribute it sits in and open a script of its own. Encode it for HTML at this site, render it through the framework's escaping output, or sanitise it if it must stay markup.
Untrusted text written into markup unescaped REDACTED:456— `side` is text this program did not author, and it is written into a quoted attribute value through markup built here with nothing encoding it for that place. Whoever controls the value controls the markup: it can close the element or attribute it sits in and open a script of its own. Encode it for HTML at this site, render it through the framework's escaping output, or sanitise it if it must stay markup.
Untrusted text written into markup unescaped REDACTED:494— `location` is text this program did not author, and it is written into the text of an element through markup this function returns with nothing encoding it for that place. Whoever controls the value controls the markup: it can close the element or attribute it sits in and open a script of its own. Encode it for HTML at this site, render it through the framework's escaping output, or sanitise it if it must stay markup.
D30 · Dependency Vulnerabilities· Medium vulnerability · ×20
Duplicated block (18 lines × 2) baml_language/sdks/csharp/bridge_csharp/src/Generated/V1/BamlGeneratedProgram.cs:198— baml_language/sdks/csharp/bridge_csharp/src/Generated/V1/BamlGeneratedProgram.cs:198-215 | baml_language/sdks/csharp/bridge_csharp/src/Generated/V1/BamlGeneratedProgram.cs:234-251 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `baml_language/sdks/csharp/bridge_csharp/src/Generated/V1/BamlGeneratedProgram.cs:198` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (18 lines × 2) baml_language/crates/baml_builtins2_codegen/src/codegen.rs:873— baml_language/crates/baml_builtins2_codegen/src/codegen.rs:873-890 | baml_language/crates/baml_builtins2_codegen/src/codegen.rs:971-988 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (18 lines × 2) baml_language/crates/baml_cli/src/run_command.rs:743— baml_language/crates/baml_cli/src/run_command.rs:743-760 | baml_language/crates/baml_cli/src/run_command.rs:1180-1197 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (18 lines × 2) baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:2386— baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:2386-2403 | baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:2840-2857 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (18 lines × 2) baml_language/crates/baml_compiler2_visualization/src/control_flow/flatten.rs:487— baml_language/crates/baml_compiler2_visualization/src/control_flow/flatten.rs:487-504 | engine/baml-runtime/src/control_flow/flatten/step2_hoist_branch_arms.rs:74-91 — before extracting anything, compare `baml_language/crates/baml_compiler2_visualization/src/control_flow/flatten.rs` and `engine/baml-runtime/src/control_flow/flatten/step2_hoist_branch_arms.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 56 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, 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 (18 lines × 2) baml_language/crates/baml_compiler2_visualization/src/control_flow/from_ast.rs:320— baml_language/crates/baml_compiler2_visualization/src/control_flow/from_ast.rs:320-337 | baml_language/crates/baml_compiler2_visualization/src/control_flow/from_ast.rs:471-488 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (18 lines × 2) baml_language/crates/baml_lsp_server/src/playground_seam.rs:1079— baml_language/crates/baml_lsp_server/src/playground_seam.rs:1079-1096 | baml_language/crates/bridge_wasm/src/playground.rs:578-595 — 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 (18 lines × 2) baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs:238— baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs:238-255 | engine/baml-lib/jsonish/src/jsonish/parser/fixing_parser/json_parse_state.rs:268-285 — before extracting anything, compare `baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs` and `engine/baml-lib/jsonish/src/jsonish/parser/fixing_parser/json_parse_state.rs` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 575 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, 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 (18 lines × 2) baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs:357— baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs:357-374 | engine/baml-lib/jsonish/src/jsonish/parser/fixing_parser/json_parse_state.rs:384-401 — before extracting anything, compare `baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs` and `engine/baml-lib/jsonish/src/jsonish/parser/fixing_parser/json_parse_state.rs` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 575 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, 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 (18 lines × 2) baml_language/crates/bex_vm/src/vm.rs:5598— baml_language/crates/bex_vm/src/vm.rs:5598-5615 | baml_language/crates/bex_vm/src/vm.rs:5713-5730 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (18 lines × 2) baml_language/crates/bex_vm/src/vm.rs:9735— baml_language/crates/bex_vm/src/vm.rs:9735-9752 | baml_language/crates/bex_vm/src/vm.rs:9800-9817 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (18 lines × 2) baml_language/crates/bex_vm/src/vm.rs:11456— baml_language/crates/bex_vm/src/vm.rs:11456-11473 | baml_language/crates/bex_vm/src/vm.rs:11525-11542 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (18 lines × 2) baml_language/crates/bridge_cffi/src/ffi/handle.rs:199— baml_language/crates/bridge_cffi/src/ffi/handle.rs:199-216 | baml_language/crates/bridge_cffi/src/ffi/handle.rs:290-307 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (18 lines × 2) baml_language/crates/btel_recorder/src/lib.rs:292— baml_language/crates/btel_recorder/src/lib.rs:292-309 | baml_language/crates/btel_recorder/src/lib.rs:316-333 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (18 lines × 2) engine/baml-runtime/src/optimize/storage.rs:215— engine/baml-runtime/src/optimize/storage.rs:215-232 | engine/baml-runtime/src/optimize/tui.rs:1236-1253 — 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 (18 lines × 2) engine/generators/languages/python/src/watchers.rs:89— engine/generators/languages/python/src/watchers.rs:89-106 | engine/generators/languages/typescript/src/watchers.rs:93-110 — before extracting anything, compare `engine/generators/languages/python/src/watchers.rs` and `engine/generators/languages/typescript/src/watchers.rs` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 146 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, 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 (18 lines × 2) engine/language_client_ruby/ext/ruby_ffi/src/ruby_to_json.rs:221— engine/language_client_ruby/ext/ruby_ffi/src/ruby_to_json.rs:221-238 | engine/language_client_ruby/ext/ruby_ffi/src/ruby_to_json.rs:244-261 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (18 lines × 2) scripts/ffi-debug/analyze_ffi.py:580— scripts/ffi-debug/analyze_ffi.py:580-597 | scripts/ffi-debug/analyze_ffi.py:600-617 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (18 lines × 2) baml_language/sdks/go/baml_go/runtime.go:412— baml_language/sdks/go/baml_go/runtime.go:412-429 | baml_language/sdks/go/baml_go/runtime.go:464-481 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `baml_language/sdks/go/baml_go/runtime.go:412` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. The matched lines also register a scope-exit action (a `defer`-style statement) that runs when the function holding them returns: moved into a called unit it would run when THAT unit returns instead — before the caller uses what it releases — so keep the registration at the call site and extract only the work around it, or have the extracted unit hand the resource back for the caller to register.
Duplicated block (18 lines × 2) engine/generators/utils/test_harness/src/lib.rs:134— engine/generators/utils/test_harness/src/lib.rs:134-151 | engine/generators/utils/test_harness/src/lib.rs:216-233 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Sync-over-async blocking integ-tests/python/baml_example_tracing.py:50— `main` is async and calls time.sleep — a blocking call inside async code stalls the event loop — every other task on it waits for as long as it runs.
Sync-over-async blocking engine/baml-runtime/src/cli/optimize.rs:167— `run` is async and calls thread::sleep — a blocking call inside async code stalls the executor thread, and every task scheduled on it for as long as it runs.
Sync-over-async blocking typescript2/app-speedtest/api-server.mjs:29— `existsSync` in `loadRuns` blocks the event loop until it finishes — a blocking call inside async code stalls the event loop — every other request waits for as long as it runs.
Sync-over-async blocking typescript2/app-speedtest/api-server.mjs:34— `existsSync` in `loadRuns` blocks the event loop until it finishes — a blocking call inside async code stalls the event loop — every other request waits for as long as it runs.
Sync-over-async blocking typescript2/app-speedtest/api-server.mjs:44— `existsSync` in `loadRuns` blocks the event loop until it finishes — a blocking call inside async code stalls the event loop — every other request waits for as long as it runs.
Sync-over-async blocking typescript2/app-speedtest/api-server.mjs:64— `existsSync` in `loadRuns` blocks the event loop until it finishes — a blocking call inside async code stalls the event loop — every other request waits for as long as it runs.
Sync-over-async blocking — 13 blocking call(s) on async work (.Wait()/.GetAwaiter().GetResult()) — these waste a thread and can deadlock wherever a synchronization context is in play (a UI thread, or a caller that has one).
Sync-over-async blocking baml_language/sdks/csharp/bridge_csharp/src/Generated/V1/BamlGeneratedProgram.cs:32— `.GetAwaiter().GetResult()` blocks this thread until the async work completes — it wastes a thread-pool thread for as long as the work runs and can deadlock wherever a synchronization context is in play (a UI thread, or a caller that has one).
Sync-over-async blocking baml_language/sdks/csharp/bridge_csharp/src/Generated/V1/BamlGeneratedProgram.cs:160— `.GetAwaiter().GetResult()` blocks this thread until the async work completes — it wastes a thread-pool thread for as long as the work runs and can deadlock wherever a synchronization context is in play (a UI thread, or a caller that has one).
Sync-over-async blocking baml_language/sdks/csharp/bridge_csharp/src/Values/BamlFunctionSpec.cs:27— `.GetAwaiter().GetResult()` blocks this thread until the async work completes — it wastes a thread-pool thread for as long as the work runs and can deadlock wherever a synchronization context is in play (a UI thread, or a caller that has one).
Sync-over-async blocking baml_language/sdks/csharp/bridge_csharp/src/Values/BamlFunctionSpec.cs:45— `.GetAwaiter().GetResult()` blocks this thread until the async work completes — it wastes a thread-pool thread for as long as the work runs and can deadlock wherever a synchronization context is in play (a UI thread, or a caller that has one).
Sync-over-async blocking baml_language/sdks/csharp/bridge_csharp/src/Values/BamlFunctionSpec.cs:63— `.GetAwaiter().GetResult()` blocks this thread until the async work completes — it wastes a thread-pool thread for as long as the work runs and can deadlock wherever a synchronization context is in play (a UI thread, or a caller that has one).
Sync-over-async blocking baml_language/sdks/csharp/bridge_csharp/src/Values/BamlFunctionSpec.cs:79— `.GetAwaiter().GetResult()` blocks this thread until the async work completes — it wastes a thread-pool thread for as long as the work runs and can deadlock wherever a synchronization context is in play (a UI thread, or a caller that has one).
Sync-over-async blocking baml_language/sdks/csharp/bridge_csharp/src/Values/BamlFunctionSpec.cs:91— `.GetAwaiter().GetResult()` blocks this thread until the async work completes — it wastes a thread-pool thread for as long as the work runs and can deadlock wherever a synchronization context is in play (a UI thread, or a caller that has one).
Sync-over-async blocking baml_language/sdks/csharp/bridge_csharp/src/Values/BamlFunctionSpec.cs:103— `.GetAwaiter().GetResult()` blocks this thread until the async work completes — it wastes a thread-pool thread for as long as the work runs and can deadlock wherever a synchronization context is in play (a UI thread, or a caller that has one).
Sync-over-async blocking baml_language/sdks/csharp/bridge_csharp/src/Values/BamlFunctionSpec.cs:121— `.GetAwaiter().GetResult()` blocks this thread until the async work completes — it wastes a thread-pool thread for as long as the work runs and can deadlock wherever a synchronization context is in play (a UI thread, or a caller that has one).
Sync-over-async blocking baml_language/sdks/csharp/bridge_csharp/src/Values/BamlFunctionSpec.cs:136— `.GetAwaiter().GetResult()` blocks this thread until the async work completes — it wastes a thread-pool thread for as long as the work runs and can deadlock wherever a synchronization context is in play (a UI thread, or a caller that has one).
Sync-over-async blocking baml_language/sdks/csharp/bridge_csharp/src/Values/BamlFunctionSpec.cs:147— `.GetAwaiter().GetResult()` blocks this thread until the async work completes — it wastes a thread-pool thread for as long as the work runs and can deadlock wherever a synchronization context is in play (a UI thread, or a caller that has one).
Sync-over-async blocking baml_language/sdks/csharp/bridge_csharp/src/Values/BamlPrompt.cs:37— `.GetAwaiter().GetResult()` blocks this thread until the async work completes — it wastes a thread-pool thread for as long as the work runs and can deadlock wherever a synchronization context is in play (a UI thread, or a caller that has one).
Sync-over-async blocking baml_language/sdks/csharp/bridge_csharp/src/Values/BamlPrompt.cs:53— `.GetAwaiter().GetResult()` blocks this thread until the async work completes — it wastes a thread-pool thread for as long as the work runs and can deadlock wherever a synchronization context is in play (a UI thread, or a caller that has one).
baml_compiler2_mir::optimize::verify_definite_assignment (cyclomatic 84) baml_language/crates/baml_compiler2_mir/src/optimize.rs:1934— baml_compiler2_mir::optimize::verify_definite_assignment has cyclomatic complexity 84 (threshold 15). Of this number, 82 points are the body's own statements and 2 belong to one function item inside it that branches. To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
baml_compiler2_mir::optimize::verify_mir (cyclomatic 65) baml_language/crates/baml_compiler2_mir/src/optimize.rs:1586— baml_compiler2_mir::optimize::verify_mir has cyclomatic complexity 65 (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.
baml_compiler2_mir::pretty::write_terminator (cyclomatic 40) baml_language/crates/baml_compiler2_mir/src/pretty.rs:317— baml_compiler2_mir::pretty::write_terminator 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.
baml_compiler2_mir::pretty::write_rvalue (cyclomatic 39) baml_language/crates/baml_compiler2_mir/src/pretty.rs:557— baml_compiler2_mir::pretty::write_rvalue has cyclomatic complexity 39 (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.
baml_compiler2_mir::optimize::values::fold (cyclomatic 37) baml_language/crates/baml_compiler2_mir/src/optimize/values.rs:96— baml_compiler2_mir::optimize::values::fold 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.
baml_compiler2_mir::optimize::eliminate_dead_locals (cyclomatic 33) baml_language/crates/baml_compiler2_mir/src/optimize.rs:1229— baml_compiler2_mir::optimize::eliminate_dead_locals 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.
baml_compiler2_mir::optimize::collect_place_bound_locals (cyclomatic 24) baml_language/crates/baml_compiler2_mir/src/optimize.rs:340— baml_compiler2_mir::optimize::collect_place_bound_locals 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. This shape REPEATS in the file: one other method here (baml_compiler2_mir::optimize::collect_place_bound_locals::scan_rvalue) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
baml_compiler2_mir::memory::spawn_shared_cells (cyclomatic 22) baml_language/crates/baml_compiler2_mir/src/memory.rs:331— baml_compiler2_mir::memory::spawn_shared_cells 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.
baml_compiler2_mir::optimize::count_in_rvalue (cyclomatic 21) baml_language/crates/baml_compiler2_mir/src/optimize.rs:672— baml_compiler2_mir::optimize::count_in_rvalue 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.
baml_compiler2_mir::optimize::propagate_copies (cyclomatic 20) baml_language/crates/baml_compiler2_mir/src/optimize.rs:858— baml_compiler2_mir::optimize::propagate_copies 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.
baml_compiler2_mir::optimize::values::fold_constants (cyclomatic 20) baml_language/crates/baml_compiler2_mir/src/optimize/values.rs:21— baml_compiler2_mir::optimize::values::fold_constants 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.
baml_compiler2_mir::memory::walk_rvalue_places (cyclomatic 19) baml_language/crates/baml_compiler2_mir/src/memory.rs:133— baml_compiler2_mir::memory::walk_rvalue_places 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.
baml_compiler2_mir::optimize::collect_place_bound_locals::scan_rvalue (cyclomatic 19) baml_language/crates/baml_compiler2_mir/src/optimize.rs:378— baml_compiler2_mir::optimize::collect_place_bound_locals::scan_rvalue 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. This shape REPEATS in the file: one other method here (baml_compiler2_mir::optimize::collect_place_bound_locals) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
baml_compiler2_mir::optimize::apply_subst_to_rvalue (cyclomatic 19) baml_language/crates/baml_compiler2_mir/src/optimize.rs:1080— baml_compiler2_mir::optimize::apply_subst_to_rvalue 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. This shape REPEATS in the file: one other method here (baml_compiler2_mir::optimize::remap_rvalue) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
baml_compiler2_mir::optimize::remap_rvalue (cyclomatic 19) baml_language/crates/baml_compiler2_mir/src/optimize.rs:1407— baml_compiler2_mir::optimize::remap_rvalue 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. This shape REPEATS in the file: one other method here (baml_compiler2_mir::optimize::apply_subst_to_rvalue) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
baml_compiler2_mir::memory::walk_rvalue_type_slots (cyclomatic 18) baml_language/crates/baml_compiler2_mir/src/memory.rs:197— baml_compiler2_mir::memory::walk_rvalue_type_slots 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.
baml_compiler2_mir::lower::lower_tir_template (cyclomatic 16) baml_language/crates/baml_compiler2_mir/src/lower.rs:365— baml_compiler2_mir::lower::lower_tir_template has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This is NOT this file's highest cyclomatic complexity: LoweringContext::convert_binop (cyclomatic 18) 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.
baml_compiler2_mir::pretty::write_statement (cyclomatic 16) baml_language/crates/baml_compiler2_mir/src/pretty.rs:245— baml_compiler2_mir::pretty::write_statement 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.
baml_compiler2_hir_ty::infer::const_fold_binary (cyclomatic 68) baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:131— baml_compiler2_hir_ty::infer::const_fold_binary has cyclomatic complexity 68 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
baml_compiler2_hir_ty::interfaces::impl_rules::validate_impl_signatures (cyclomatic 57) baml_language/crates/baml_compiler2_hir_ty/src/interfaces/impl_rules.rs:1035— baml_compiler2_hir_ty::interfaces::impl_rules::validate_impl_signatures has cyclomatic complexity 57 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
baml_compiler2_hir_ty::package_interface::validate_row_identities (cyclomatic 49) baml_language/crates/baml_compiler2_hir_ty/src/package_interface.rs:1021— baml_compiler2_hir_ty::package_interface::validate_row_identities 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.
baml_compiler2_hir_ty::defaults::collect_default_expr_forward_references (cyclomatic 44) baml_language/crates/baml_compiler2_hir_ty/src/defaults.rs:77— baml_compiler2_hir_ty::defaults::collect_default_expr_forward_references has cyclomatic complexity 44 (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.
baml_compiler2_hir_ty::interfaces::impl_rules::impl_data (cyclomatic 43) baml_language/crates/baml_compiler2_hir_ty/src/interfaces/impl_rules.rs:208— baml_compiler2_hir_ty::interfaces::impl_rules::impl_data 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.
baml_compiler2_hir_ty::exhaustiveness::write_ty_identity (cyclomatic 38) baml_language/crates/baml_compiler2_hir_ty/src/exhaustiveness.rs:312— baml_compiler2_hir_ty::exhaustiveness::write_ty_identity 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.
baml_compiler2_hir_ty::infer::trace_hooks::checked_declaration (cyclomatic 33) baml_language/crates/baml_compiler2_hir_ty/src/infer/trace_hooks.rs:60— baml_compiler2_hir_ty::infer::trace_hooks::checked_declaration 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.
baml_compiler2_hir_ty::impls::hash_eligible_within_depth::visit (cyclomatic 30) baml_language/crates/baml_compiler2_hir_ty/src/impls.rs:1532— baml_compiler2_hir_ty::impls::hash_eligible_within_depth::visit 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.
baml_compiler2_hir_ty::lower::interface_lowering_diagnostics (cyclomatic 27) baml_language/crates/baml_compiler2_hir_ty/src/lower.rs:2909— baml_compiler2_hir_ty::lower::interface_lowering_diagnostics has cyclomatic complexity 27 (threshold 15). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
baml_compiler2_hir_ty::interfaces::match_ty_pattern_into (cyclomatic 26) baml_language/crates/baml_compiler2_hir_ty/src/interfaces.rs:972— baml_compiler2_hir_ty::interfaces::match_ty_pattern_into has cyclomatic complexity 26 (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.
baml_compiler2_hir_ty::method_resolution::lookup_impl_member (cyclomatic 25) baml_language/crates/baml_compiler2_hir_ty/src/method_resolution.rs:492— baml_compiler2_hir_ty::method_resolution::lookup_impl_member 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.
baml_compiler2_hir_ty::coherence::unify_into_at (cyclomatic 23) baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs:248— baml_compiler2_hir_ty::coherence::unify_into_at 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.
baml_compiler2_hir_ty::impls::match_pattern (cyclomatic 23) baml_language/crates/baml_compiler2_hir_ty/src/impls.rs:2148— baml_compiler2_hir_ty::impls::match_pattern 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.
baml_compiler2_hir_ty::infer::infer_body_impl (cyclomatic 20) baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:1724— baml_compiler2_hir_ty::infer::infer_body_impl has cyclomatic complexity 20 (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.
baml_compiler2_hir_ty::interfaces::collect_type_generic_bound_errors (cyclomatic 20) baml_language/crates/baml_compiler2_hir_ty/src/interfaces.rs:1604— baml_compiler2_hir_ty::interfaces::collect_type_generic_bound_errors 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.
baml_compiler2_hir_ty::infer::reachability::add_diagnostics (cyclomatic 17) baml_language/crates/baml_compiler2_hir_ty/src/infer/reachability.rs:17— baml_compiler2_hir_ty::infer::reachability::add_diagnostics 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.
baml_compiler2_hir_ty::init_io::evaluated_calls_impl (cyclomatic 17) baml_language/crates/baml_compiler2_hir_ty/src/init_io.rs:141— baml_compiler2_hir_ty::init_io::evaluated_calls_impl 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.
Parser::parse_expr_bp (cyclomatic 40) baml_language/crates/baml_compiler_parser/src/parser.rs:6603— Parser::parse_expr_bp 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. This is NOT this file's highest cyclomatic complexity: baml_compiler_parser::parser::token_kind_to_syntax_kind (cyclomatic 97) 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.
Parser::parse_primary_expr (cyclomatic 36) baml_language/crates/baml_compiler_parser/src/parser.rs:7149— Parser::parse_primary_expr has cyclomatic complexity 36 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages. This is NOT this file's highest cyclomatic complexity: baml_compiler_parser::parser::token_kind_to_syntax_kind (cyclomatic 97) 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.
Parser::parse_type_primary (cyclomatic 24) baml_language/crates/baml_compiler_parser/src/parser.rs:3182— Parser::parse_type_primary 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. This is NOT this file's highest cyclomatic complexity: baml_compiler_parser::parser::token_kind_to_syntax_kind (cyclomatic 97) 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.
Parser::function_body_start (cyclomatic 22) baml_language/crates/baml_compiler_parser/src/parser.rs:3971— Parser::function_body_start has cyclomatic complexity 22 (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. This is NOT this file's highest cyclomatic complexity: baml_compiler_parser::parser::token_kind_to_syntax_kind (cyclomatic 97) 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.
Parser::looks_like_map (cyclomatic 21) baml_language/crates/baml_compiler_parser/src/parser.rs:7689— Parser::looks_like_map 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. This is NOT this file's highest cyclomatic complexity: baml_compiler_parser::parser::token_kind_to_syntax_kind (cyclomatic 97) 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.
Parser::parse_class (cyclomatic 20) baml_language/crates/baml_compiler_parser/src/parser.rs:3702— Parser::parse_class 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. This is NOT this file's highest cyclomatic complexity: baml_compiler_parser::parser::token_kind_to_syntax_kind (cyclomatic 97) 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.
Parser::parse_implements_for (cyclomatic 20) baml_language/crates/baml_compiler_parser/src/parser.rs:4153— Parser::parse_implements_for 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. This is NOT this file's highest cyclomatic complexity: baml_compiler_parser::parser::token_kind_to_syntax_kind (cyclomatic 97) 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.
Parser::parse_interface (cyclomatic 19) baml_language/crates/baml_compiler_parser/src/parser.rs:3800— Parser::parse_interface has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This is NOT this file's highest cyclomatic complexity: baml_compiler_parser::parser::token_kind_to_syntax_kind (cyclomatic 97) 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.
Parser::looks_like_config_expression (cyclomatic 19) baml_language/crates/baml_compiler_parser/src/parser.rs:8462— Parser::looks_like_config_expression has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This is NOT this file's highest cyclomatic complexity: baml_compiler_parser::parser::token_kind_to_syntax_kind (cyclomatic 97) 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.
Parser::parse_implements_block (cyclomatic 18) baml_language/crates/baml_compiler_parser/src/parser.rs:4065— Parser::parse_implements_block has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This is NOT this file's highest cyclomatic complexity: baml_compiler_parser::parser::token_kind_to_syntax_kind (cyclomatic 97) 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.
Parser::parse_llm_function_body (cyclomatic 18) baml_language/crates/baml_compiler_parser/src/parser.rs:4590— Parser::parse_llm_function_body has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This is NOT this file's highest cyclomatic complexity: baml_compiler_parser::parser::token_kind_to_syntax_kind (cyclomatic 97) 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.
Parser::looks_like_generic_args (cyclomatic 18) baml_language/crates/baml_compiler_parser/src/parser.rs:7346— Parser::looks_like_generic_args has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This is NOT this file's highest cyclomatic complexity: baml_compiler_parser::parser::token_kind_to_syntax_kind (cyclomatic 97) 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.
Parser::parse_object_literal_fields (cyclomatic 18) baml_language/crates/baml_compiler_parser/src/parser.rs:8074— Parser::parse_object_literal_fields has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This is NOT this file's highest cyclomatic complexity: baml_compiler_parser::parser::token_kind_to_syntax_kind (cyclomatic 97) 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.
Parser::looks_like_qualified_projection (cyclomatic 17) baml_language/crates/baml_compiler_parser/src/parser.rs:715— Parser::looks_like_qualified_projection 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: baml_compiler_parser::parser::token_kind_to_syntax_kind (cyclomatic 97) 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.
Parser::find_matching_generic_args_close_from (cyclomatic 17) baml_language/crates/baml_compiler_parser/src/parser.rs:5779— Parser::find_matching_generic_args_close_from 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: baml_compiler_parser::parser::token_kind_to_syntax_kind (cyclomatic 97) 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.
Parser::classify_backtick_interp (cyclomatic 16) baml_language/crates/baml_compiler_parser/src/parser.rs:2730— Parser::classify_backtick_interp has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This is NOT this file's highest cyclomatic complexity: baml_compiler_parser::parser::token_kind_to_syntax_kind (cyclomatic 97) 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.
Parser::parse_stmt (cyclomatic 16) baml_language/crates/baml_compiler_parser/src/parser.rs:4856— Parser::parse_stmt 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. This is NOT this file's highest cyclomatic complexity: baml_compiler_parser::parser::token_kind_to_syntax_kind (cyclomatic 97) 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.
D4 · Code Duplication· Members sharing a duplicated core (4 members, 50+ identical tokens) · ×17
Members sharing a duplicated core (4 members, 50+ identical tokens) baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:1129— baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:1129-1169 | baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:1180-1222 | baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:1267-1357 | baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:1378-1439 — 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) baml_language/crates/baml_compiler2_mir/src/lower.rs:8994— baml_language/crates/baml_compiler2_mir/src/lower.rs:8994-9060 | baml_language/crates/baml_compiler2_mir/src/lower.rs:9076-9136 | baml_language/crates/baml_compiler2_mir/src/lower.rs:9138-9201 | baml_language/crates/baml_compiler2_mir/src/lower.rs:9226-9300 — 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) baml_language/crates/baml_fmt/src/ast/pattern.rs:278— baml_language/crates/baml_fmt/src/ast/pattern.rs:278-295 | baml_language/crates/baml_fmt/src/ast/pattern.rs:569-585 | baml_language/crates/baml_fmt/src/ast/pattern.rs:708-756 | baml_language/crates/baml_fmt/src/ast/pattern.rs:1082-1110 — 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) baml_language/crates/bex_sap/src/deserializer/coercer/coerce_primitive.rs:120— baml_language/crates/bex_sap/src/deserializer/coercer/coerce_primitive.rs:120-217 | baml_language/crates/bex_sap/src/deserializer/coercer/coerce_primitive.rs:308-398 | baml_language/crates/bex_sap/src/deserializer/coercer/coerce_primitive.rs:445-519 | baml_language/crates/bex_sap/src/deserializer/coercer/coerce_primitive.rs:557-629 — 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) baml_language/crates/bex_vm/src/package_baml/array.rs:1063— baml_language/crates/bex_vm/src/package_baml/array.rs:1063-1084 | baml_language/crates/bex_vm/src/package_baml/array.rs:1086-1107 | baml_language/crates/bex_vm/src/package_baml/array.rs:1109-1131 | baml_language/crates/bex_vm/src/package_baml/array.rs:1137-1159 — 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) baml_language/crates/bex_vm/src/package_baml/csv.rs:2344— baml_language/crates/bex_vm/src/package_baml/csv.rs:2344-2373 | baml_language/crates/bex_vm/src/package_baml/csv.rs:2379-2406 | baml_language/crates/bex_vm/src/package_baml/csv.rs:2626-2647 | baml_language/crates/bex_vm/src/package_baml/csv.rs:2653-2677 — 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) baml_language/crates/bex_vm/src/package_reflect/graft.rs:1097— baml_language/crates/bex_vm/src/package_reflect/graft.rs:1097-1139 | baml_language/crates/bex_vm/src/package_reflect/graft.rs:1177-1306 | baml_language/crates/bex_vm_types/src/types/object.rs:170-199 | baml_language/crates/bex_vm_types/src/types/object.rs:203-233 — 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) baml_language/sdks/csharp/sdkgen_csharp/src/semantic.rs:819— baml_language/sdks/csharp/sdkgen_csharp/src/semantic.rs:819-893 | baml_language/sdks/csharp/sdkgen_csharp/src/semantic.rs:895-976 | baml_language/sdks/csharp/sdkgen_csharp/src/semantic.rs:4212-4302 | baml_language/sdks/csharp/sdkgen_csharp/src/semantic.rs:4402-4525 — 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) engine/baml-lib/ast/src/ast/field.rs:209— engine/baml-lib/ast/src/ast/field.rs:209-219 | engine/baml-lib/ast/src/ast/field.rs:221-231 | engine/baml-lib/ast/src/ast/field.rs:233-243 | engine/baml-lib/ast/src/ast/field.rs:245-258 — 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) engine/baml-lib/llm-client/src/clients/anthropic.rs:85— engine/baml-lib/llm-client/src/clients/anthropic.rs:85-97 | engine/baml-lib/llm-client/src/clients/aws_bedrock.rs:151-163 | engine/baml-lib/llm-client/src/clients/google_ai.rs:84-96 | engine/baml-lib/llm-client/src/clients/vertex.rs:224-236 — 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) engine/baml-runtime/src/internal/llm_client/primitive/anthropic/anthropic_client.rs:133— engine/baml-runtime/src/internal/llm_client/primitive/anthropic/anthropic_client.rs:133-175 | engine/baml-runtime/src/internal/llm_client/primitive/aws/aws_client.rs:472-514 | engine/baml-runtime/src/internal/llm_client/primitive/google/googleai_client.rs:165-208 | engine/baml-runtime/src/internal/llm_client/primitive/vertex/vertex_client.rs:189-232 — 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) engine/baml-runtime/src/internal/llm_client/primitive/anthropic/anthropic_client.rs:177— engine/baml-runtime/src/internal/llm_client/primitive/anthropic/anthropic_client.rs:177-219 | engine/baml-runtime/src/internal/llm_client/primitive/aws/aws_client.rs:516-558 | engine/baml-runtime/src/internal/llm_client/primitive/google/googleai_client.rs:121-163 | engine/baml-runtime/src/internal/llm_client/primitive/vertex/vertex_client.rs:145-187 — 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) engine/generators/languages/go/src/ir_to_go/classes.rs:8— engine/generators/languages/go/src/ir_to_go/classes.rs:8-25 | engine/generators/languages/go/src/ir_to_go/classes.rs:27-44 | engine/generators/languages/ruby/src/ir_to_rb/classes.rs:8-25 | engine/generators/languages/ruby/src/ir_to_rb/classes.rs:27-44 — 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) engine/generators/languages/rust/src/ir_to_rust/classes.rs:15— engine/generators/languages/rust/src/ir_to_rust/classes.rs:15-35 | engine/generators/languages/rust/src/ir_to_rust/classes.rs:41-61 | engine/generators/languages/typescript/src/ir_to_ts/classes.rs:8-24 | engine/generators/languages/typescript/src/ir_to_ts/classes.rs:26-42 — 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) engine/language_client_cffi/src/ffi/functions.rs:78— engine/language_client_cffi/src/ffi/functions.rs:78-134 | engine/language_client_cffi/src/ffi/functions.rs:142-227 | engine/language_client_cffi/src/ffi/functions.rs:253-321 | engine/language_client_cffi/src/ffi/functions.rs:357-424 — 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) engine/language_client_cffi/src/raw_ptr_wrapper/type_builder/objects.rs:257— engine/language_client_cffi/src/raw_ptr_wrapper/type_builder/objects.rs:257-264 | engine/language_client_cffi/src/raw_ptr_wrapper/type_builder/objects.rs:504-511 | engine/language_client_cffi/src/raw_ptr_wrapper/type_builder/objects.rs:622-629 | engine/language_client_cffi/src/raw_ptr_wrapper/type_builder/objects.rs:794-801 — 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) engine/language_client_cffi/src/raw_ptr_wrapper/type_builder/objects.rs:266— engine/language_client_cffi/src/raw_ptr_wrapper/type_builder/objects.rs:266-273 | engine/language_client_cffi/src/raw_ptr_wrapper/type_builder/objects.rs:495-502 | engine/language_client_cffi/src/raw_ptr_wrapper/type_builder/objects.rs:613-620 | engine/language_client_cffi/src/raw_ptr_wrapper/type_builder/objects.rs:785-792 — 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.
baml_cffi_macros::export_baml_fn (cognitive 185) engine/baml_cffi_macros/src/lib.rs:6— baml_cffi_macros::export_baml_fn has cognitive complexity 185 (threshold 15). Drivers by points: if/else 78 (170 pts), match/switch 4 (13 pts), boolean chains 1, loops 1 (nesting depth added 101). 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.
baml_cffi_macros::is_result_option_vec_rawptrtype (cognitive 105) engine/baml_cffi_macros/src/lib.rs:1043— baml_cffi_macros::is_result_option_vec_rawptrtype has cognitive complexity 105 (threshold 15). Drivers by points: if/else 14 (105 pts) (nesting depth added 91). 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.
baml_cffi_macros::generate_param_extraction (cognitive 72) engine/baml_cffi_macros/src/lib.rs:1167— baml_cffi_macros::generate_param_extraction has cognitive complexity 72 (threshold 15). Drivers by points: if/else 18 (69 pts), match/switch 1 (3 pts) (nesting depth added 53). 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.
baml_cffi_macros::is_result_vec_rawptrtype (cognitive 55) engine/baml_cffi_macros/src/lib.rs:912— baml_cffi_macros::is_result_vec_rawptrtype has cognitive complexity 55 (threshold 15). Drivers by points: if/else 10 (55 pts) (nesting depth added 45). 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. This shape REPEATS in the file: 3 other methods here (baml_cffi_macros::is_result_option_rawptrtype, baml_cffi_macros::is_result_option_bamlvalue, baml_cffi_macros::is_result_option_string) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 4 times rather than 4 independent problems. Splitting this body alone leaves the other 3 exactly as they are. Where these are variations on one operation, the change that clears all 4 is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
baml_cffi_macros::is_result_option_rawptrtype (cognitive 55) engine/baml_cffi_macros/src/lib.rs:975— baml_cffi_macros::is_result_option_rawptrtype has cognitive complexity 55 (threshold 15). Drivers by points: if/else 10 (55 pts) (nesting depth added 45). 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. This shape REPEATS in the file: 3 other methods here (baml_cffi_macros::is_result_vec_rawptrtype, baml_cffi_macros::is_result_option_bamlvalue, baml_cffi_macros::is_result_option_string) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 4 times rather than 4 independent problems. Splitting this body alone leaves the other 3 exactly as they are. Where these are variations on one operation, the change that clears all 4 is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
baml_cffi_macros::is_result_option_bamlvalue (cognitive 55) engine/baml_cffi_macros/src/lib.rs:1009— baml_cffi_macros::is_result_option_bamlvalue has cognitive complexity 55 (threshold 15). Drivers by points: if/else 10 (55 pts) (nesting depth added 45). 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. This shape REPEATS in the file: 3 other methods here (baml_cffi_macros::is_result_vec_rawptrtype, baml_cffi_macros::is_result_option_rawptrtype, baml_cffi_macros::is_result_option_string) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 4 times rather than 4 independent problems. Splitting this body alone leaves the other 3 exactly as they are. Where these are variations on one operation, the change that clears all 4 is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
baml_cffi_macros::is_result_option_string (cognitive 55) engine/baml_cffi_macros/src/lib.rs:1094— baml_cffi_macros::is_result_option_string has cognitive complexity 55 (threshold 15). Drivers by points: if/else 10 (55 pts) (nesting depth added 45). 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. This shape REPEATS in the file: 3 other methods here (baml_cffi_macros::is_result_vec_rawptrtype, baml_cffi_macros::is_result_option_rawptrtype, baml_cffi_macros::is_result_option_bamlvalue) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 4 times rather than 4 independent problems. Splitting this body alone leaves the other 3 exactly as they are. Where these are variations on one operation, the change that clears all 4 is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
baml_cffi_macros::is_result_vec_convertible_to_rawptr (cognitive 45) engine/baml_cffi_macros/src/lib.rs:946— baml_cffi_macros::is_result_vec_convertible_to_rawptr has cognitive complexity 45 (threshold 15). Drivers by points: if/else 9 (45 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.
baml_cffi_macros::is_convertible_to_rawptr (cognitive 41) engine/baml_cffi_macros/src/lib.rs:595— baml_cffi_macros::is_convertible_to_rawptr has cognitive complexity 41 (threshold 15). Drivers by points: if/else 10 (40 pts), boolean chains 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.
baml_cffi_macros::export_baml_new_fn (cognitive 32) engine/baml_cffi_macros/src/lib.rs:1728— baml_cffi_macros::export_baml_new_fn has cognitive complexity 32 (threshold 15). Drivers by points: if/else 16 (28 pts), 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.
baml_cffi_macros::is_either_convertible_to_rawptr (cognitive 22) engine/baml_cffi_macros/src/lib.rs:684— baml_cffi_macros::is_either_convertible_to_rawptr has cognitive complexity 22 (threshold 15). Drivers by points: if/else 6 (21 pts), boolean chains 1 (nesting depth added 15). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
baml_cffi_macros::is_vec_rawptrtype (cognitive 21) engine/baml_cffi_macros/src/lib.rs:819— baml_cffi_macros::is_vec_rawptrtype has cognitive complexity 21 (threshold 15). Drivers by points: if/else 6 (21 pts) (nesting depth added 15). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function. This shape REPEATS in the file: 4 other methods here (baml_cffi_macros::is_option_rawptrtype, baml_cffi_macros::is_result_bamlvalue, baml_cffi_macros::is_result_rawptrtype, …) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 5 times rather than 5 independent problems. Splitting this body alone leaves the other 4 exactly as they are. Where these are variations on one operation, the change that clears all 5 is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
baml_cffi_macros::is_option_rawptrtype (cognitive 21) engine/baml_cffi_macros/src/lib.rs:838— baml_cffi_macros::is_option_rawptrtype has cognitive complexity 21 (threshold 15). Drivers by points: if/else 6 (21 pts) (nesting depth added 15). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function. This shape REPEATS in the file: 4 other methods here (baml_cffi_macros::is_vec_rawptrtype, baml_cffi_macros::is_result_bamlvalue, baml_cffi_macros::is_result_rawptrtype, …) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 5 times rather than 5 independent problems. Splitting this body alone leaves the other 4 exactly as they are. Where these are variations on one operation, the change that clears all 5 is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
baml_cffi_macros::is_result_bamlvalue (cognitive 21) engine/baml_cffi_macros/src/lib.rs:857— baml_cffi_macros::is_result_bamlvalue has cognitive complexity 21 (threshold 15). Drivers by points: if/else 6 (21 pts) (nesting depth added 15). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function. This shape REPEATS in the file: 4 other methods here (baml_cffi_macros::is_vec_rawptrtype, baml_cffi_macros::is_option_rawptrtype, baml_cffi_macros::is_result_rawptrtype, …) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 5 times rather than 5 independent problems. Splitting this body alone leaves the other 4 exactly as they are. Where these are variations on one operation, the change that clears all 5 is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
baml_cffi_macros::is_result_rawptrtype (cognitive 21) engine/baml_cffi_macros/src/lib.rs:893— baml_cffi_macros::is_result_rawptrtype has cognitive complexity 21 (threshold 15). Drivers by points: if/else 6 (21 pts) (nesting depth added 15). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function. This shape REPEATS in the file: 4 other methods here (baml_cffi_macros::is_vec_rawptrtype, baml_cffi_macros::is_option_rawptrtype, baml_cffi_macros::is_result_bamlvalue, …) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 5 times rather than 5 independent problems. Splitting this body alone leaves the other 4 exactly as they are. Where these are variations on one operation, the change that clears all 5 is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
baml_cffi_macros::is_result_bool (cognitive 21) engine/baml_cffi_macros/src/lib.rs:1128— baml_cffi_macros::is_result_bool has cognitive complexity 21 (threshold 15). Drivers by points: if/else 6 (21 pts) (nesting depth added 15). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function. This shape REPEATS in the file: 4 other methods here (baml_cffi_macros::is_vec_rawptrtype, baml_cffi_macros::is_option_rawptrtype, baml_cffi_macros::is_result_bamlvalue, …) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 5 times rather than 5 independent problems. Splitting this body alone leaves the other 4 exactly as they are. Where these are variations on one operation, the change that clears all 5 is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
baml_compiler2_mir::optimize::verify_definite_assignment (cognitive 129) baml_language/crates/baml_compiler2_mir/src/optimize.rs:1934— baml_compiler2_mir::optimize::verify_definite_assignment has cognitive complexity 129 (threshold 15). Drivers by points: if/else 25 (65 pts), loops 17 (37 pts), match/switch 11 (26 pts), boolean chains 1 (nesting depth added 75). Of this number, 127 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.
baml_compiler2_mir::optimize::verify_mir (cognitive 90) baml_language/crates/baml_compiler2_mir/src/optimize.rs:1586— baml_compiler2_mir::optimize::verify_mir has cognitive complexity 90 (threshold 15). Drivers by points: loops 21 (59 pts), if/else 7 (17 pts), match/switch 5 (13 pts), boolean chains 1 (nesting depth added 56). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
baml_compiler2_mir::pretty::write_terminator (cognitive 59) baml_language/crates/baml_compiler2_mir/src/pretty.rs:317— baml_compiler2_mir::pretty::write_terminator has cognitive complexity 59 (threshold 15). Drivers by points: if/else 16 (39 pts), loops 6 (14 pts), match/switch 3 (6 pts) (nesting depth added 34). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
baml_compiler2_mir::optimize::eliminate_dead_locals (cognitive 50) baml_language/crates/baml_compiler2_mir/src/optimize.rs:1229— baml_compiler2_mir::optimize::eliminate_dead_locals has cognitive complexity 50 (threshold 15). Drivers by points: if/else 14 (28 pts), loops 9 (13 pts), match/switch 2 (6 pts), boolean chains 3 (nesting depth added 22). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
baml_compiler2_mir::optimize::collect_place_bound_locals (cognitive 45) baml_language/crates/baml_compiler2_mir/src/optimize.rs:340— baml_compiler2_mir::optimize::collect_place_bound_locals has cognitive complexity 45 (threshold 15). Drivers by points: loops 11 (29 pts), match/switch 5 (9 pts), if/else 4 (7 pts) (nesting depth added 25). Of this number, 27 points are the body's own statements and 18 belong to 4 function items inside it that branch. To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
baml_compiler2_mir::optimize::values::fold_constants (cognitive 45) baml_language/crates/baml_compiler2_mir/src/optimize/values.rs:21— baml_compiler2_mir::optimize::values::fold_constants has cognitive complexity 45 (threshold 15). Drivers by points: if/else 11 (32 pts), loops 4 (7 pts), match/switch 2 (5 pts), boolean chains 1 (nesting depth added 27). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
baml_compiler2_mir::pretty::write_rvalue (cognitive 41) baml_language/crates/baml_compiler2_mir/src/pretty.rs:557— baml_compiler2_mir::pretty::write_rvalue has cognitive complexity 41 (threshold 15). Drivers by points: if/else 10 (27 pts), loops 5 (11 pts), match/switch 2 (3 pts) (nesting depth added 24). 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.
baml_compiler2_mir::optimize::propagate_copies (cognitive 40) baml_language/crates/baml_compiler2_mir/src/optimize.rs:858— baml_compiler2_mir::optimize::propagate_copies has cognitive complexity 40 (threshold 15). Drivers by points: if/else 9 (24 pts), loops 7 (10 pts), match/switch 1 (4 pts), boolean chains 2 (nesting depth added 21). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
baml_compiler2_mir::memory::spawn_shared_cells (cognitive 37) baml_language/crates/baml_compiler2_mir/src/memory.rs:331— baml_compiler2_mir::memory::spawn_shared_cells has cognitive complexity 37 (threshold 15). Drivers by points: if/else 8 (18 pts), loops 7 (12 pts), match/switch 3 (6 pts), boolean chains 1 (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
baml_compiler2_mir::optimize::values::materialize_operand_prefixes (cognitive 30) baml_language/crates/baml_compiler2_mir/src/optimize/values.rs:416— baml_compiler2_mir::optimize::values::materialize_operand_prefixes has cognitive complexity 30 (threshold 15). Drivers by points: if/else 6 (22 pts), loops 4 (7 pts), boolean chains 1 (nesting depth added 19). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
baml_compiler2_mir::optimize::values::fold (cognitive 26) baml_language/crates/baml_compiler2_mir/src/optimize/values.rs:96— baml_compiler2_mir::optimize::values::fold has cognitive complexity 26 (threshold 15). Drivers by points: match/switch 7 (17 pts), if/else 3 (7 pts), boolean chains 2 (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.
baml_compiler2_mir::optimize::reorder_blocks_rpo (cognitive 23) baml_language/crates/baml_compiler2_mir/src/optimize.rs:2390— baml_compiler2_mir::optimize::reorder_blocks_rpo has cognitive complexity 23 (threshold 15). Drivers by points: if/else 7 (14 pts), loops 6 (8 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.
baml_compiler2_mir::optimize::merge_passthrough_blocks (cognitive 20) baml_language/crates/baml_compiler2_mir/src/optimize.rs:275— baml_compiler2_mir::optimize::merge_passthrough_blocks has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (14 pts), loops 4 (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.
baml_compiler2_mir::optimize::values::live_out (cognitive 20) baml_language/crates/baml_compiler2_mir/src/optimize/values.rs:321— baml_compiler2_mir::optimize::values::live_out has cognitive complexity 20 (threshold 15). Drivers by points: if/else 8 (14 pts), loops 2 (4 pts), match/switch 1 (2 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
baml_compiler2_mir::optimize::values::eliminate_dead_stores (cognitive 19) baml_language/crates/baml_compiler2_mir/src/optimize/values.rs:250— baml_compiler2_mir::optimize::values::eliminate_dead_stores has cognitive complexity 19 (threshold 15). Drivers by points: loops 5 (9 pts), if/else 3 (8 pts), boolean chains 2 (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.
baml_compiler2_mir::optimize::values::simplify_boolean_diamonds (cognitive 17) baml_language/crates/baml_compiler2_mir/src/optimize/values.rs:180— baml_compiler2_mir::optimize::values::simplify_boolean_diamonds has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (15 pts), boolean chains 1, 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.
Duplicated block (8 lines × 3) baml_language/crates/baml_compiler2_hir_ty/src/package_interface.rs:2215— baml_language/crates/baml_compiler2_hir_ty/src/package_interface.rs:2215-2222 | baml_language/crates/baml_compiler2_hir_ty/src/package_interface.rs:2226-2233 | baml_language/crates/baml_compiler2_hir_ty/src/package_interface.rs:2235-2242 — 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) baml_language/crates/baml_fmt/src/ast/expressions.rs:3416— baml_language/crates/baml_fmt/src/ast/expressions.rs:3416-3426 | baml_language/crates/baml_fmt/src/ast/expressions.rs:3465-3472 | baml_language/crates/baml_fmt/src/ast/expressions.rs:3518-3525 — 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) baml_language/crates/bex_vm/src/package_reflect/reflect.rs:1176— baml_language/crates/bex_vm/src/package_reflect/reflect.rs:1176-1183 | baml_language/crates/bex_vm/src/package_reflect/reflect.rs:1818-1825 | baml_language/crates/bex_vm_types/src/types/package.rs:301-308 — 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 (8 lines × 3) baml_language/crates/bex_vm/src/vm.rs:7137— baml_language/crates/bex_vm/src/vm.rs:7137-7144 | baml_language/crates/bex_vm/src/vm.rs:7151-7158 | baml_language/crates/bex_vm/src/vm.rs:7165-7172 — 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) baml_language/crates/bex_vm/src/vm.rs:10000— baml_language/crates/bex_vm/src/vm.rs:10000-10007 | baml_language/crates/bex_vm/src/vm.rs:10953-10960 | baml_language/crates/bex_vm/src/vm.rs:11044-11051 — 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) engine/baml-lib/baml-types/src/baml_value.rs:518— engine/baml-lib/baml-types/src/baml_value.rs:518-525 | engine/baml-lib/baml-types/src/baml_value.rs:655-662 | engine/baml-lib/baml-types/src/baml_value.rs:792-799 — 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) engine/baml-lib/baml-types/src/expr.rs:160— engine/baml-lib/baml-types/src/expr.rs:160-167 | engine/baml-lib/baml-types/src/expr.rs:183-190 | engine/baml-lib/baml-types/src/expr.rs:206-213 — 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) engine/baml-runtime/src/cli/repl.rs:288— engine/baml-runtime/src/cli/repl.rs:288-295 | engine/baml-runtime/src/cli/repl.rs:481-493 | engine/baml-runtime/src/cli/repl.rs:644-656 — 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) engine/baml-runtime/src/optimize/applier.rs:368— engine/baml-runtime/src/optimize/applier.rs:368-375 | engine/baml-runtime/src/optimize/applier.rs:411-418 | engine/baml-runtime/src/optimize/applier.rs:508-515 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (8 lines × 3) languages/rust/baml/src/runtime.rs:83— languages/rust/baml/src/runtime.rs:83-90 | languages/rust/baml/src/runtime.rs:352-359 | languages/rust/baml/src/runtime.rs:452-459 — 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) engine/generators/languages/go/src/package.rs:76— engine/generators/languages/go/src/package.rs:76-83 | engine/generators/languages/rust/src/package.rs:77-84 | engine/generators/languages/typescript/src/package.rs:68-75 — before extracting anything, compare `engine/generators/languages/go/src/package.rs` and `engine/generators/languages/rust/src/package.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 30 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, 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) baml_language/crates/baml_compiler2_ast/src/lower_cst.rs:1385— baml_language/crates/baml_compiler2_ast/src/lower_cst.rs:1385-1392 | baml_language/crates/baml_compiler2_ast/src/lower_cst.rs:1431-1438 | baml_language/crates/baml_compiler2_ast/src/lower_cst.rs:1854-1862 — 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) baml_language/crates/bex_sap/src/jsonish/value.rs:262— baml_language/crates/bex_sap/src/jsonish/value.rs:262-269 | engine/baml-lib/baml-types/src/value_expr.rs:409-416 | engine/baml-lib/jsonish/src/jsonish/value.rs:204-211 — before extracting anything, compare `baml_language/crates/bex_sap/src/jsonish/value.rs` and `engine/baml-lib/jsonish/src/jsonish/value.rs` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 160 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, 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) baml_language/sdks/python/src/baml_bridge/typemap.py:100— baml_language/sdks/python/src/baml_bridge/typemap.py:100-109 | baml_language/sdks/python/src/baml_bridge/typemap.py:120-127 | baml_language/sdks/python/src/baml_bridge/typemap.py:138-145 — 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 `baml_language/sdks/python/src/baml_bridge/typemap.py:100` it begins part-way through the construct above it, so those exact lines 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) baml_language/sdks/go/baml_go/container.go:87— baml_language/sdks/go/baml_go/container.go:87-95 | baml_language/sdks/go/baml_go/container.go:167-174 | baml_language/sdks/go/baml_go/container.go:188-195 — 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) baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:455— baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:455-462 | baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:589-596 | baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:734-741 — 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 `baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:455` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. 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.
baml_ide::symbol_pool::build_symbol_pool (cyclomatic 36) baml_language/crates/baml_ide/src/symbol_pool.rs:97— baml_ide::symbol_pool::build_symbol_pool has cyclomatic complexity 36 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
baml_ide::resolve::member_position_at (cyclomatic 34) baml_language/crates/baml_ide/src/resolve.rs:254— baml_ide::resolve::member_position_at has cyclomatic complexity 34 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
baml_ide::annotations::process_body (cyclomatic 31) baml_language/crates/baml_ide/src/annotations.rs:239— baml_ide::annotations::process_body 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.
baml_ide::cursor_context::find_source_expr_ids_at (cyclomatic 27) baml_language/crates/baml_ide/src/cursor_context.rs:403— baml_ide::cursor_context::find_source_expr_ids_at 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.
baml_ide::resolve::template_position_at (cyclomatic 25) baml_language/crates/baml_ide/src/resolve.rs:915— baml_ide::resolve::template_position_at has cyclomatic complexity 25 (threshold 15). Of this number, 17 points are the body's own statements and 8 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.
baml_ide::tokens::classify_token (cyclomatic 25) baml_language/crates/baml_ide/src/tokens.rs:966— baml_ide::tokens::classify_token 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.
baml_ide::info::generic_type_parameter_info_at (cyclomatic 22) baml_language/crates/baml_ide/src/info.rs:1037— baml_ide::info::generic_type_parameter_info_at 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.
baml_ide::resolve::operator_target_at (cyclomatic 22) baml_language/crates/baml_ide/src/resolve.rs:1154— baml_ide::resolve::operator_target_at 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.
baml_ide::usages::find_member_usages (cyclomatic 22) baml_language/crates/baml_ide/src/usages.rs:367— baml_ide::usages::find_member_usages 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.
baml_ide::completion::context::classify (cyclomatic 20) baml_language/crates/baml_ide/src/completion/context.rs:305— baml_ide::completion::context::classify 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.
baml_ide::cfg::ast_test_control_flow_graph_impl (cyclomatic 19) baml_language/crates/baml_ide/src/cfg.rs:79— baml_ide::cfg::ast_test_control_flow_graph_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.
baml_ide::tokens::index::index_function (cyclomatic 18) baml_language/crates/baml_ide/src/tokens/index.rs:145— baml_ide::tokens::index::index_function 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.
baml_ide::resolve::receiver_at_dot (cyclomatic 17) baml_language/crates/baml_ide/src/resolve.rs:424— baml_ide::resolve::receiver_at_dot 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.
baml_ide::cfg::expand_user_function_calls_in_graph (cyclomatic 16) baml_language/crates/baml_ide/src/cfg.rs:295— baml_ide::cfg::expand_user_function_calls_in_graph 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.
baml_ide::describe::describe_locals (cyclomatic 16) baml_language/crates/baml_ide/src/describe.rs:815— baml_ide::describe::describe_locals 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.
D30 · Dependency Vulnerabilities· Medium advisory (unmaintained) · ×15
Duplicated block (7 lines × 3) baml_language/crates/baml_compiler2_emit/src/items.rs:1084— baml_language/crates/baml_compiler2_emit/src/items.rs:1084-1090 | baml_language/crates/baml_compiler2_emit/src/lib.rs:1177-1186 | baml_language/crates/baml_compiler2_emit/src/package/bodies.rs:89-96 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times.
Duplicated block (7 lines × 3) baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:163— baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:163-169 | baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:213-219 | baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:241-247 — 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) baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:161— baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:161-167 | baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:211-217 | baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:257-263 — 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) baml_language/crates/baml_fmt/src/ast/declarations.rs:402— baml_language/crates/baml_fmt/src/ast/declarations.rs:402-409 | baml_language/crates/baml_fmt/src/ast/expressions.rs:2794-2800 | baml_language/crates/baml_fmt/src/ast/expressions.rs:3735-3742 — before extracting anything, compare `baml_language/crates/baml_fmt/src/ast/declarations.rs` and `baml_language/crates/baml_fmt/src/ast/expressions.rs` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 124 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (7 lines × 3) baml_language/crates/baml_ide/src/describe.rs:1106— baml_language/crates/baml_ide/src/describe.rs:1106-1112 | baml_language/crates/baml_ide/src/describe.rs:1127-1133 | baml_language/crates/baml_ide/src/describe.rs:1938-1944 — 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) baml_language/crates/bex_vm/src/debug.rs:588— baml_language/crates/bex_vm/src/debug.rs:588-594 | baml_language/crates/bex_vm/src/debug.rs:1175-1181 | engine/baml-vm/src/debug.rs:309-315 — before extracting anything, compare `baml_language/crates/bex_vm/src/debug.rs` and `engine/baml-vm/src/debug.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 57 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (7 lines × 3) engine/baml-lib/jsonish/src/deserializer/coercer/coerce_primitive.rs:237— engine/baml-lib/jsonish/src/deserializer/coercer/coerce_primitive.rs:237-243 | engine/baml-lib/jsonish/src/deserializer/coercer/coerce_primitive.rs:331-337 | engine/baml-lib/jsonish/src/deserializer/coercer/coerce_primitive.rs:393-399 — 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) engine/baml-lib/llm-client/src/clients/google_ai.rs:143— engine/baml-lib/llm-client/src/clients/google_ai.rs:143-149 | engine/baml-lib/llm-client/src/clients/openai.rs:198-204 | engine/baml-lib/llm-client/src/clients/vertex.rs:305-311 — 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) engine/baml-runtime/src/internal/llm_client/primitive/anthropic/response_handler.rs:68— engine/baml-runtime/src/internal/llm_client/primitive/anthropic/response_handler.rs:68-74 | engine/baml-runtime/src/internal/llm_client/primitive/vertex/response_handler.rs:50-56 | engine/baml-runtime/src/internal/llm_client/primitive/vertex/response_handler.rs:73-79 — `engine/baml-runtime/src/internal/llm_client/primitive/anthropic/response_handler.rs` and `engine/baml-runtime/src/internal/llm_client/primitive/vertex/response_handler.rs` 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 5 separate duplicated blocks between them, totalling at least 39 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.
Duplicated block (7 lines × 3) engine/baml-runtime/src/lib.rs:291— engine/baml-runtime/src/lib.rs:291-297 | engine/baml-runtime/src/lib.rs:326-332 | engine/baml-runtime/src/types/stream.rs:160-166 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart.
Duplicated block (7 lines × 3) engine/language_client_ruby/ext/ruby_ffi/src/types/log_collector.rs:102— engine/language_client_python/src/types/log_collector.rs:65-71 | engine/language_client_ruby/ext/ruby_ffi/src/types/log_collector.rs:102-108 | engine/language_client_typescript/src/types/log_collector.rs:52-58 — before extracting anything, compare `engine/language_client_ruby/ext/ruby_ffi/src/types/log_collector.rs` and `engine/language_client_typescript/src/types/log_collector.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 36 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (7 lines × 3) engine/language_client_ruby/ext/ruby_ffi/src/types/log_collector.rs:110— engine/language_client_python/src/types/log_collector.rs:73-79 | engine/language_client_ruby/ext/ruby_ffi/src/types/log_collector.rs:110-116 | engine/language_client_typescript/src/types/log_collector.rs:61-67 — before extracting anything, compare `engine/language_client_ruby/ext/ruby_ffi/src/types/log_collector.rs` and `engine/language_client_typescript/src/types/log_collector.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 36 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (7 lines × 3) baml_language/crates/bex_sap/src/jsonish/value.rs:271— baml_language/crates/bex_sap/src/jsonish/value.rs:271-277 | engine/baml-lib/baml-types/src/value_expr.rs:388-394 | engine/baml-lib/jsonish/src/jsonish/value.rs:213-219 — before extracting anything, compare `baml_language/crates/bex_sap/src/jsonish/value.rs` and `engine/baml-lib/jsonish/src/jsonish/value.rs` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 160 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (7 lines × 3) engine/baml-lib/ast/src/ast/baml_vis/mermaid_debug.rs:273— engine/baml-lib/ast/src/ast/baml_vis/mermaid_debug.rs:273-279 | engine/baml-lib/ast/src/ast/baml_vis/mermaid_debug.rs:310-316 | engine/baml-lib/ast/src/ast/baml_vis/mermaid_debug.rs:371-377 — 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) engine/generators/utils/type_test_spec/src/lib.rs:129— engine/generators/utils/type_test_spec/src/lib.rs:129-135 | engine/generators/utils/type_test_spec/src/lib.rs:165-171 | engine/generators/utils/type_test_spec/src/lib.rs:259-265 — 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.
Low cohesion: NativeSysOps (LCOM4 59) baml_language/crates/sys_native/src/lib.rs:127— NativeSysOps's methods fall into 59 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 59 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: ClassPropertyBuilder (LCOM4 10) engine/baml-runtime/src/type_builder/mod.rs:85— ClassPropertyBuilder's methods fall into 10 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 10 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
Low cohesion: EnumValueBuilder (LCOM4 10) engine/baml-runtime/src/type_builder/mod.rs:162— EnumValueBuilder's methods fall into 10 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 10 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
Low cohesion: BexVm (LCOM4 7) baml_language/crates/bex_vm/src/vm.rs:1779— BexVm's methods fall into 7 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 7 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
Low cohesion: ProjectDatabase (LCOM4 6) baml_language/crates/baml_db/src/db.rs:130— ProjectDatabase's methods fall into 6 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 6 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
Low cohesion: Ty (LCOM4 6) baml_language/crates/baml_type/src/interned.rs:100— Ty's methods fall into 6 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 6 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
Low cohesion: Reporter (LCOM4 5) baml_language/crates/baml_cli/src/reporter.rs:65— Reporter'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: BamlVideo (LCOM4 5) baml_language/sdks/python/rust/bridge_python/src/media.rs:275— BamlVideo'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: BamlPdf (LCOM4 5) baml_language/sdks/python/rust/bridge_python/src/media.rs:281— BamlPdf'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: WasmHttp (LCOM4 4) baml_language/crates/bridge_wasm/src/wasm_http.rs:35— WasmHttp's methods fall into 4 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 4 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
Low cohesion: BamlImage (LCOM4 4) baml_language/sdks/python/rust/bridge_python/src/media.rs:263— BamlImage's methods fall into 4 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 4 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
Low cohesion: BamlAudio (LCOM4 4) baml_language/sdks/python/rust/bridge_python/src/media.rs:269— BamlAudio's methods fall into 4 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 4 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
Low cohesion: IntermediateRepr (LCOM4 4) engine/baml-lib/baml-core/src/ir/repr.rs:40— IntermediateRepr's methods fall into 4 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 4 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
Low cohesion: EnumBuilder (LCOM4 4) engine/baml-runtime/src/type_builder/mod.rs:154— EnumBuilder's methods fall into 4 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 4 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
Low cohesion: FunctionResultStream (LCOM4 4) engine/baml-runtime/src/types/stream.rs:29— FunctionResultStream'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.
BexVm::run_compact (cyclomatic 331) baml_language/crates/bex_vm/src/vm.rs:9465— BexVm::run_compact has cyclomatic complexity 331 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
BexVm::execute_call_from_locals_offset (cyclomatic 45) baml_language/crates/bex_vm/src/vm.rs:7515— BexVm::execute_call_from_locals_offset has cyclomatic complexity 45 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
BexVm::cmpop_values (cyclomatic 36) baml_language/crates/bex_vm/src/vm.rs:9051— BexVm::cmpop_values 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.
BexVm::set_entry_point_with_type_values (cyclomatic 34) baml_language/crates/bex_vm/src/vm.rs:5200— BexVm::set_entry_point_with_type_values has cyclomatic complexity 34 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
BexVm::unwind_exception (cyclomatic 34) baml_language/crates/bex_vm/src/vm.rs:6811— BexVm::unwind_exception has cyclomatic complexity 34 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
BexVm::value_concrete_ty (cyclomatic 28) baml_language/crates/bex_vm/src/vm.rs:4612— BexVm::value_concrete_ty 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. This is NOT this file's highest cyclomatic complexity: bex_vm::vm::value_type_tag (cyclomatic 30) 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.
BexVm::bigint_binop (cyclomatic 25) baml_language/crates/bex_vm/src/vm.rs:5875— BexVm::bigint_binop 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. This is NOT this file's highest cyclomatic complexity: bex_vm::vm::value_type_tag (cyclomatic 30) 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.
BexVm::binop_values (cyclomatic 22) baml_language/crates/bex_vm/src/vm.rs:9205— BexVm::binop_values has cyclomatic complexity 22 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing. This is NOT this file's highest cyclomatic complexity: bex_vm::vm::value_type_tag (cyclomatic 30) 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.
BexVm::exec_compact (cyclomatic 22) baml_language/crates/bex_vm/src/vm.rs:9299— BexVm::exec_compact 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. This is NOT this file's highest cyclomatic complexity: bex_vm::vm::value_type_tag (cyclomatic 30) 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.
BexVm::forward_roots (cyclomatic 21) baml_language/crates/bex_vm/src/vm.rs:12149— BexVm::forward_roots 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. This is NOT this file's highest cyclomatic complexity: bex_vm::vm::value_type_tag (cyclomatic 30) 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.
BexVm::begin_error_evidence (cyclomatic 19) baml_language/crates/bex_vm/src/vm/error_evidence.rs:346— BexVm::begin_error_evidence 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.
BexVm::value_runtime_package (cyclomatic 19) baml_language/crates/bex_vm/src/vm.rs:4872— BexVm::value_runtime_package 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. This is NOT this file's highest cyclomatic complexity: bex_vm::vm::value_type_tag (cyclomatic 30) 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.
BexVm::resume_compiled (cyclomatic 18) baml_language/crates/bex_vm/src/vm/compiled_rt/frame.rs:206— BexVm::resume_compiled 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.
BexVm::finish_trace_hook_config (cyclomatic 18) baml_language/crates/bex_vm/src/vm.rs:2890— BexVm::finish_trace_hook_config has cyclomatic complexity 18 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages. This is NOT this file's highest cyclomatic complexity: bex_vm::vm::value_type_tag (cyclomatic 30) 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.
BexVm::run_compact (cognitive 579) baml_language/crates/bex_vm/src/vm.rs:9465— BexVm::run_compact has cognitive complexity 579 (threshold 15). Drivers by points: if/else 159 (442 pts), match/switch 39 (117 pts), boolean chains 13, loops 3 (7 pts) (nesting depth added 365). 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.
BexVm::unwind_exception (cognitive 84) baml_language/crates/bex_vm/src/vm.rs:6811— BexVm::unwind_exception has cognitive complexity 84 (threshold 15). Drivers by points: if/else 28 (67 pts), match/switch 5 (13 pts), boolean chains 3, loops 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.
BexVm::execute_call_from_locals_offset (cognitive 67) baml_language/crates/bex_vm/src/vm.rs:7515— BexVm::execute_call_from_locals_offset has cognitive complexity 67 (threshold 15). Drivers by points: if/else 27 (49 pts), match/switch 9 (14 pts), boolean chains 4 (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.
BexVm::set_entry_point_with_type_values (cognitive 51) baml_language/crates/bex_vm/src/vm.rs:5200— BexVm::set_entry_point_with_type_values has cognitive complexity 51 (threshold 15). Drivers by points: if/else 19 (31 pts), match/switch 7 (15 pts), boolean chains 5 (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.
BexVm::exec_compact (cognitive 43) baml_language/crates/bex_vm/src/vm.rs:9299— BexVm::exec_compact has cognitive complexity 43 (threshold 15). Drivers by points: if/else 8 (24 pts), match/switch 4 (14 pts), loops 3 (5 pts) (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.
BexVm::bigint_binop (cognitive 42) baml_language/crates/bex_vm/src/vm.rs:5875— BexVm::bigint_binop has cognitive complexity 42 (threshold 15). Drivers by points: if/else 16 (29 pts), match/switch 7 (13 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.
BexVm::value_matches_type_constant_with_type_args (cognitive 33) baml_language/crates/bex_vm/src/vm.rs:4207— BexVm::value_matches_type_constant_with_type_args has cognitive complexity 33 (threshold 15). Drivers by points: if/else 6 (16 pts), match/switch 5 (13 pts), loops 1 (4 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.
BexVm::forward_roots (cognitive 30) baml_language/crates/bex_vm/src/vm.rs:12149— BexVm::forward_roots has cognitive complexity 30 (threshold 15). Drivers by points: if/else 9 (18 pts), loops 8 (9 pts), boolean chains 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.
BexVm::handler_contexts (cognitive 29) baml_language/crates/bex_vm/src/vm.rs:3510— BexVm::handler_contexts has cognitive complexity 29 (threshold 15). Drivers by points: if/else 9 (20 pts), match/switch 2 (5 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.
BexVm::finish_trace_hook_config (cognitive 23) baml_language/crates/bex_vm/src/vm.rs:2890— BexVm::finish_trace_hook_config has cognitive complexity 23 (threshold 15). Drivers by points: if/else 13 (17 pts), boolean chains 3, match/switch 2 (3 pts) (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.
BexVm::cmpop_values (cognitive 22) baml_language/crates/bex_vm/src/vm.rs:9051— BexVm::cmpop_values has cognitive complexity 22 (threshold 15). Drivers by points: match/switch 9 (15 pts), if/else 5, boolean chains 2 (nesting depth added 6). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own 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.
BexVm::value_concrete_ty (cognitive 18) baml_language/crates/bex_vm/src/vm.rs:4612— BexVm::value_concrete_ty has cognitive complexity 18 (threshold 15). Drivers by points: match/switch 6 (11 pts), if/else 5 (7 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.
BexVm::begin_error_evidence (cognitive 17) baml_language/crates/bex_vm/src/vm/error_evidence.rs:346— BexVm::begin_error_evidence has cognitive complexity 17 (threshold 15). Drivers by points: if/else 10, boolean chains 4, match/switch 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.
BexVm::any_frame_position (cognitive 16) baml_language/crates/bex_vm/src/vm/compiled_rt/record.rs:649— BexVm::any_frame_position has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (11 pts), boolean chains 2, match/switch 1 (2 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.
baml_compiler::thir::typecheck::typecheck_expression (cognitive 412) engine/baml-compiler/src/thir/typecheck.rs:1486— baml_compiler::thir::typecheck::typecheck_expression has cognitive complexity 412 (threshold 15). Drivers by points: if/else 86 (242 pts), match/switch 43 (137 pts), loops 6 (21 pts), boolean chains 12 (nesting depth added 265). 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.
baml_compiler::thir::interpret::evaluate_block_with_control_flow::handle_statement (cognitive 161) engine/baml-compiler/src/thir/interpret.rs:533— baml_compiler::thir::interpret::evaluate_block_with_control_flow::handle_statement has cognitive complexity 161 (threshold 15). Drivers by points: if/else 20 (76 pts), match/switch 27 (76 pts), loops 4 (9 pts) (nesting depth added 110). 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.
baml_compiler::thir::interpret::evaluate_expr_with_context (cognitive 119) engine/baml-compiler/src/thir/interpret.rs:1639— baml_compiler::thir::interpret::evaluate_expr_with_context has cognitive complexity 119 (threshold 15). Drivers by points: if/else 25 (50 pts), match/switch 16 (42 pts), loops 9 (27 pts) (nesting depth added 69). 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.
baml_compiler::thir::interpret::evaluate_method_call (cognitive 70) engine/baml-compiler/src/thir/interpret.rs:2797— baml_compiler::thir::interpret::evaluate_method_call has cognitive complexity 70 (threshold 15). Drivers by points: if/else 30 (63 pts), match/switch 4 (7 pts) (nesting depth added 36). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
baml_compiler::thir::typecheck::typecheck_statement (cognitive 59) engine/baml-compiler/src/thir/typecheck.rs:923— baml_compiler::thir::typecheck::typecheck_statement has cognitive complexity 59 (threshold 15). Drivers by points: if/else 24 (50 pts), match/switch 5 (9 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.
baml_compiler::thir::interpret::check_watch_changes (cognitive 49) engine/baml-compiler/src/thir/interpret.rs:180— baml_compiler::thir::interpret::check_watch_changes has cognitive complexity 49 (threshold 15). Drivers by points: loops 9 (21 pts), if/else 6 (18 pts), match/switch 4 (10 pts) (nesting depth added 30). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
baml_compiler::thir::interpret::evaluate_binary_op (cognitive 49) engine/baml-compiler/src/thir/interpret.rs:2341— baml_compiler::thir::interpret::evaluate_binary_op has cognitive complexity 49 (threshold 15). Drivers by points: match/switch 16 (28 pts), if/else 7 (21 pts) (nesting depth added 26). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own 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.
baml_compiler::codegen::compile_thir_to_bytecode (cognitive 34) engine/baml-compiler/src/codegen.rs:48— baml_compiler::codegen::compile_thir_to_bytecode has cognitive complexity 34 (threshold 15). Drivers by points: loops 19 (24 pts), if/else 2 (5 pts), match/switch 2 (5 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.
baml_compiler::hir::lowering::lower_stmt_with_options (cognitive 34) engine/baml-compiler/src/hir/lowering.rs:472— baml_compiler::hir::lowering::lower_stmt_with_options has cognitive complexity 34 (threshold 15). Drivers by points: if/else 14 (29 pts), match/switch 3 (5 pts) (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.
baml_compiler::hir::lowering::type_ir_from_ast (cognitive 25) engine/baml-compiler/src/hir/lowering.rs:115— baml_compiler::hir::lowering::type_ir_from_ast has cognitive complexity 25 (threshold 15). Drivers by points: if/else 11 (17 pts), match/switch 4 (6 pts), loops 1 (2 pts) (nesting depth added 9). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
baml_compiler::thir::typecheck::typecheck_returning_context (cognitive 25) engine/baml-compiler/src/thir/typecheck.rs:41— baml_compiler::thir::typecheck::typecheck_returning_context has cognitive complexity 25 (threshold 15). Drivers by points: if/else 5 (12 pts), loops 9 (11 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.
baml_compiler::hir::lowering::extract_watch_options_fields (cognitive 22) engine/baml-compiler/src/hir/lowering.rs:339— baml_compiler::hir::lowering::extract_watch_options_fields has cognitive complexity 22 (threshold 15). Drivers by points: if/else 5 (11 pts), match/switch 2 (9 pts), loops 1 (2 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.
baml_compiler::thir::interpret::parse_json_to_baml_value (cognitive 22) engine/baml-compiler/src/thir/interpret.rs:2589— baml_compiler::thir::interpret::parse_json_to_baml_value has cognitive complexity 22 (threshold 15). Drivers by points: if/else 7 (10 pts), loops 5 (10 pts), match/switch 2 (nesting depth added 8). None of this is in the body itself: all 22 points belong to 2 function items inside it that branch (json_to_baml, json_to_baml_inferred). 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.
baml_compiler::thir::interpret::assign_to_expr (cognitive 16) engine/baml-compiler/src/thir/interpret.rs:1450— baml_compiler::thir::interpret::assign_to_expr has cognitive complexity 16 (threshold 15). Drivers by points: match/switch 4 (11 pts), if/else 1 (4 pts), 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.
BexEngine::run_thread_event_loop_inner (cognitive 216) baml_language/crates/bex_engine/src/lib.rs:5882— BexEngine::run_thread_event_loop_inner has cognitive complexity 216 (threshold 15). Drivers by points: if/else 55 (165 pts), match/switch 12 (38 pts), boolean chains 9, loops 2 (4 pts) (nesting depth added 138). 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.
BexEngine::materialize_external_node (cognitive 74) baml_language/crates/bex_engine/src/conversion.rs:1413— BexEngine::materialize_external_node has cognitive complexity 74 (threshold 15). Drivers by points: if/else 21 (42 pts), match/switch 11 (23 pts), boolean chains 5, loops 2 (4 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.
BexEngine::validate_host_return_schema (cognitive 69) baml_language/crates/bex_engine/src/conversion.rs:3865— BexEngine::validate_host_return_schema has cognitive complexity 69 (threshold 15). Drivers by points: if/else 15 (45 pts), match/switch 8 (15 pts), loops 3 (9 pts) (nesting depth added 43). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
BexEngine::call_callable_with_outcome_impl (cognitive 45) baml_language/crates/bex_engine/src/lib.rs:4049— BexEngine::call_callable_with_outcome_impl has cognitive complexity 45 (threshold 15). Drivers by points: if/else 12 (22 pts), match/switch 9 (16 pts), loops 4 (7 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.
BexEngine::call_resolved_with_trace (cognitive 42) baml_language/crates/bex_engine/src/lib.rs:3441— BexEngine::call_resolved_with_trace has cognitive complexity 42 (threshold 15). Drivers by points: if/else 15 (27 pts), loops 4 (7 pts), match/switch 3 (5 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.
BexEngine::shutdown_with_deadline (cognitive 40) baml_language/crates/bex_engine/src/lib.rs:2859— BexEngine::shutdown_with_deadline has cognitive complexity 40 (threshold 15). Drivers by points: if/else 15 (28 pts), loops 4 (6 pts), boolean chains 3, match/switch 2 (3 pts) (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
BexEngine::convert_heap_ptr_to_external_with_type (cognitive 30) baml_language/crates/bex_engine/src/conversion.rs:597— BexEngine::convert_heap_ptr_to_external_with_type has cognitive complexity 30 (threshold 15). Drivers by points: if/else 10 (22 pts), match/switch 4 (7 pts), boolean chains 1 (nesting depth added 15). 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.
BexEngine::new_with_config (cognitive 30) baml_language/crates/bex_engine/src/lib.rs:1876— BexEngine::new_with_config has cognitive complexity 30 (threshold 15). Drivers by points: if/else 5 (14 pts), match/switch 7 (12 pts), loops 3 (4 pts) (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
BexEngine::projected_surface (cognitive 27) baml_language/crates/bex_engine/src/lib.rs:7006— BexEngine::projected_surface has cognitive complexity 27 (threshold 15). Drivers by points: if/else 8 (14 pts), match/switch 6 (10 pts), loops 2, boolean chains 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
BexEngine::runtime_schema_overlay (cognitive 19) baml_language/crates/bex_engine/src/lib.rs:2620— BexEngine::runtime_schema_overlay has cognitive complexity 19 (threshold 15). Drivers by points: if/else 5 (12 pts), loops 3 (5 pts), match/switch 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.
BexEngine::landed_kind_admitted (cognitive 18) baml_language/crates/bex_engine/src/conversion.rs:4464— BexEngine::landed_kind_admitted has cognitive complexity 18 (threshold 15). Drivers by points: match/switch 8 (16 pts), boolean chains 2 (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.
BexEngine::synth_ty_from_value (cognitive 16) baml_language/crates/bex_engine/src/conversion.rs:928— BexEngine::synth_ty_from_value has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (10 pts), match/switch 3 (5 pts), boolean chains 1 (nesting depth added 6). 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.
BexEngine::runtime_type_overlay (cognitive 16) baml_language/crates/bex_engine/src/lib.rs:2538— BexEngine::runtime_type_overlay has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (10 pts), loops 3 (6 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.
cargo_stow::generate_dependency_graph_svg (cognitive 214) baml_language/crates/tools_stow/src/main.rs:1626— cargo_stow::generate_dependency_graph_svg has cognitive complexity 214 (threshold 15). Drivers by points: if/else 70 (147 pts), loops 31 (43 pts), boolean chains 13, match/switch 5 (11 pts) (nesting depth added 95). Of this number, 211 points are the body's own statements and 3 belong to 2 function items inside it that branch. 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.
cargo_stow::main (cognitive 50) baml_language/crates/tools_stow/src/main.rs:2577— cargo_stow::main has cognitive complexity 50 (threshold 15). Drivers by points: if/else 16 (27 pts), loops 10 (14 pts), match/switch 4 (9 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.
cargo_stow::check_workspace_dependencies (cognitive 38) baml_language/crates/tools_stow/src/main.rs:1058— cargo_stow::check_workspace_dependencies has cognitive complexity 38 (threshold 15). Drivers by points: if/else 6 (22 pts), loops 5 (16 pts) (nesting depth added 27). 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.
cargo_stow::extract_features_from_dep (cognitive 30) baml_language/crates/tools_stow/src/main.rs:704— cargo_stow::extract_features_from_dep has cognitive complexity 30 (threshold 15). Drivers by points: if/else 8 (22 pts), loops 2 (8 pts) (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.
cargo_stow::check_dependencies_sorted (cognitive 30) baml_language/crates/tools_stow/src/main.rs:1158— cargo_stow::check_dependencies_sorted has cognitive complexity 30 (threshold 15). Drivers by points: if/else 8 (25 pts), loops 2 (5 pts) (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.
cargo_stow::get_crate_dependencies (cognitive 27) baml_language/crates/tools_stow/src/main.rs:752— cargo_stow::get_crate_dependencies has cognitive complexity 27 (threshold 15). Drivers by points: loops 5 (16 pts), if/else 4 (11 pts) (nesting depth added 18). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline. This shape REPEATS in the file: one other method here (cargo_stow::collect_dep_names) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
cargo_stow::collect_dep_names (cognitive 27) baml_language/crates/tools_stow/src/main.rs:789— cargo_stow::collect_dep_names has cognitive complexity 27 (threshold 15). Drivers by points: loops 5 (16 pts), if/else 4 (11 pts) (nesting depth added 18). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline. This shape REPEATS in the file: one other method here (cargo_stow::get_crate_dependencies) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
cargo_stow::parse_path_points (cognitive 21) baml_language/crates/tools_stow/src/main.rs:1480— cargo_stow::parse_path_points has cognitive complexity 21 (threshold 15). Drivers by points: if/else 6 (15 pts), boolean chains 3, match/switch 1 (2 pts), loops 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
cargo_stow::find_best_manifest (cognitive 20) baml_language/crates/tools_stow/src/main.rs:553— cargo_stow::find_best_manifest has cognitive complexity 20 (threshold 15). Drivers by points: if/else 6 (19 pts), loops 1 (nesting depth added 13). 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.
cargo_stow::fix_cargo_toml (cognitive 20) baml_language/crates/tools_stow/src/main.rs:1304— cargo_stow::fix_cargo_toml has cognitive complexity 20 (threshold 15). Drivers by points: if/else 5 (15 pts), loops 2 (4 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.
cargo_stow::glob_match_recursive (cognitive 19) baml_language/crates/tools_stow/src/main.rs:451— cargo_stow::glob_match_recursive has cognitive complexity 19 (threshold 15). Drivers by points: if/else 10 (15 pts), boolean chains 2, 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.
cargo_stow::check_dependency_restrictions (cognitive 18) baml_language/crates/tools_stow/src/main.rs:1108— cargo_stow::check_dependency_restrictions has cognitive complexity 18 (threshold 15). Drivers by points: if/else 4 (9 pts), loops 4 (7 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.
cargo_stow::check_crate_naming_convention (cognitive 16) baml_language/crates/tools_stow/src/main.rs:890— cargo_stow::check_crate_naming_convention has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (13 pts), boolean chains 2, 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.
internal_baml_core::ir::ir_helpers::get_dummy_value (cognitive 48) engine/baml-lib/baml-core/src/ir/ir_helpers/mod.rs:394— internal_baml_core::ir::ir_helpers::get_dummy_value has cognitive complexity 48 (threshold 15). Drivers by points: if/else 22 (39 pts), match/switch 5 (9 pts) (nesting depth added 21). Of this number, 47 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.
internal_baml_core::validate_type_builder_entries (cognitive 39) engine/baml-lib/baml-core/src/lib.rs:195— internal_baml_core::validate_type_builder_entries has cognitive complexity 39 (threshold 15). Drivers by points: if/else 7 (29 pts), match/switch 3 (9 pts), 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.
internal_baml_core::validate::validation_pipeline::validations::classes::assert_no_field_name_collisions (cognitive 31) engine/baml-lib/baml-core/src/validate/validation_pipeline/validations/classes.rs:73— internal_baml_core::validate::validation_pipeline::validations::classes::assert_no_field_name_collisions has cognitive complexity 31 (threshold 15). Drivers by points: if/else 6 (20 pts), loops 4 (6 pts), match/switch 2 (5 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.
internal_baml_core::validate::validation_pipeline::validations::types::validate_type_constraints (cognitive 28) engine/baml-lib/baml-core/src/validate/validation_pipeline/validations/types.rs:123— internal_baml_core::validate::validation_pipeline::validations::types::validate_type_constraints has cognitive complexity 28 (threshold 15). Drivers by points: match/switch 5 (14 pts), if/else 5 (13 pts), loops 1 (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.
internal_baml_core::validate::validation_pipeline::validations::functions::validate (cognitive 27) engine/baml-lib/baml-core/src/validate/validation_pipeline/validations/functions.rs:12— internal_baml_core::validate::validation_pipeline::validations::functions::validate has cognitive complexity 27 (threshold 15). Drivers by points: match/switch 6 (15 pts), if/else 3 (7 pts), loops 3 (5 pts) (nesting depth added 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
internal_baml_core::validate::generator_loader::v2::parse_generator (cognitive 26) engine/baml-lib/baml-core/src/validate/generator_loader/v2.rs:62— internal_baml_core::validate::generator_loader::v2::parse_generator has cognitive complexity 26 (threshold 15). Drivers by points: match/switch 11 (16 pts), if/else 5 (10 pts) (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.
internal_baml_core::validate::validation_pipeline::validations::expr_fns::validate_expression (cognitive 25) engine/baml-lib/baml-core/src/validate/validation_pipeline/validations/expr_fns.rs:286— internal_baml_core::validate::validation_pipeline::validations::expr_fns::validate_expression has cognitive complexity 25 (threshold 15). Drivers by points: if/else 5 (10 pts), loops 4 (8 pts), match/switch 3 (6 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.
internal_baml_core::validate::validation_pipeline::validations::template_strings::validate (cognitive 22) engine/baml-lib/baml-core/src/validate/validation_pipeline/validations/template_strings.rs:9— internal_baml_core::validate::validation_pipeline::validations::template_strings::validate has cognitive complexity 22 (threshold 15). Drivers by points: match/switch 4 (10 pts), if/else 3 (7 pts), loops 3 (5 pts) (nesting depth added 12). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own 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.
internal_baml_core::validate::validation_pipeline::validations::classes::validate (cognitive 19) engine/baml-lib/baml-core/src/validate/validation_pipeline/validations/classes.rs:19— internal_baml_core::validate::validation_pipeline::validations::classes::validate has cognitive complexity 19 (threshold 15). Drivers by points: if/else 3 (12 pts), loops 3 (5 pts), match/switch 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.
internal_baml_core::validate::validation_pipeline::validations::expr_fns::validate_stmt (cognitive 19) engine/baml-lib/baml-core/src/validate/validation_pipeline/validations/expr_fns.rs:158— internal_baml_core::validate::validation_pipeline::validations::expr_fns::validate_stmt has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (12 pts), match/switch 3 (7 pts) (nesting depth added 10). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
internal_baml_core::ir::repr::specialize_generics (cognitive 18) engine/baml-lib/baml-core/src/ir/repr.rs:3104— internal_baml_core::ir::repr::specialize_generics has cognitive complexity 18 (threshold 15). Drivers by points: if/else 4 (9 pts), loops 4 (8 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.
internal_baml_core::validate::validation_pipeline::validations::expr_fns::validate_expr_fns (cognitive 18) engine/baml-lib/baml-core/src/validate/validation_pipeline/validations/expr_fns.rs:59— internal_baml_core::validate::validation_pipeline::validations::expr_fns::validate_expr_fns has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (11 pts), loops 4 (5 pts), match/switch 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.
internal_baml_core::validate::validation_pipeline::validations::cycle::insert_required_class_deps (cognitive 17) engine/baml-lib/baml-core/src/validate/validation_pipeline/validations/cycle.rs:166— internal_baml_core::validate::validation_pipeline::validations::cycle::insert_required_class_deps has cognitive complexity 17 (threshold 15). Drivers by points: if/else 4 (12 pts), match/switch 2 (3 pts), loops 1 (2 pts) (nesting depth added 10). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
Duplicated block (10 lines × 3) baml_language/crates/baml_compiler2_mir/src/lower.rs:1064— baml_language/crates/baml_compiler2_mir/src/lower.rs:1064-1073 | baml_language/crates/baml_compiler2_mir/src/lower.rs:1432-1441 | baml_language/crates/baml_compiler2_mir/src/lower.rs:1447-1456 — 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) baml_language/crates/baml_compiler2_mir/src/lower.rs:6134— baml_language/crates/baml_compiler2_mir/src/lower.rs:6134-6143 | baml_language/crates/baml_compiler2_mir/src/lower.rs:10187-10196 | baml_language/crates/baml_compiler2_mir/src/lower.rs:12576-12585 — 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) baml_language/crates/baml_db/src/check.rs:702— baml_language/crates/baml_db/src/check.rs:702-711 | baml_language/crates/baml_db/src/check.rs:754-763 | baml_language/crates/baml_db/src/check.rs:778-787 — 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) baml_language/crates/baml_fmt/src/ast/attributes.rs:344— baml_language/crates/baml_fmt/src/ast/attributes.rs:344-353 | baml_language/crates/baml_fmt/src/ast/declarations.rs:461-470 | baml_language/crates/baml_fmt/src/ast/expressions.rs:2953-2962 — before extracting anything, compare `baml_language/crates/baml_fmt/src/ast/attributes.rs` and `baml_language/crates/baml_fmt/src/ast/declarations.rs` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 70 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (10 lines × 3) baml_language/crates/baml_fmt/src/ast/declarations.rs:236— baml_language/crates/baml_fmt/src/ast/declarations.rs:236-245 | baml_language/crates/baml_fmt/src/ast/declarations.rs:1630-1639 | baml_language/crates/baml_fmt/src/ast/interfaces.rs:96-105 — before extracting anything, compare `baml_language/crates/baml_fmt/src/ast/declarations.rs` and `baml_language/crates/baml_fmt/src/ast/interfaces.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 32 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (10 lines × 3) baml_language/crates/bex_sap/src/deserializer/coercer/coerce_primitive.rs:182— baml_language/crates/bex_sap/src/deserializer/coercer/coerce_primitive.rs:182-191 | baml_language/crates/bex_sap/src/deserializer/coercer/coerce_primitive.rs:363-372 | baml_language/crates/bex_sap/src/deserializer/coercer/coerce_primitive.rs:484-493 — 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) baml_language/crates/bex_vm/src/vm.rs:6188— baml_language/crates/bex_vm/src/vm.rs:6188-6197 | baml_language/crates/bex_vm/src/vm.rs:6202-6211 | baml_language/crates/bex_vm/src/vm.rs:6216-6225 — 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) engine/baml-schema-wasm/src/runtime_wasm/mod.rs:2070— engine/baml-schema-wasm/src/runtime_wasm/mod.rs:2070-2079 | engine/baml-schema-wasm/src/runtime_wasm/mod.rs:2652-2661 | engine/baml-schema-wasm/src/runtime_wasm/mod.rs:2927-2936 — 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) engine/baml_cffi_macros/src/lib.rs:1200— engine/baml_cffi_macros/src/lib.rs:1200-1209 | engine/baml_cffi_macros/src/lib.rs:1344-1353 | engine/baml_cffi_macros/src/lib.rs:1869-1878 — 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) baml_language/crates/bex_vm/src/types.rs:64— baml_language/crates/bex_vm/src/types.rs:64-73 | baml_language/crates/bex_vm/src/types.rs:75-84 | engine/baml-vm/src/types.rs:257-266 — 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 (10 lines × 3) baml_language/crates/bex_sap/src/deserializer/coercer/mod.rs:353— baml_language/crates/bex_sap/src/deserializer/coercer/mod.rs:353-362 | baml_language/crates/bex_sap/src/deserializer/coercer/mod.rs:372-381 | baml_language/crates/bex_sap/src/deserializer/coercer/mod.rs:440-451 — 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) engine/baml-runtime/src/tracing/mod.rs:1112— engine/baml-runtime/src/tracing/mod.rs:1112-1121 | engine/baml-runtime/src/tracing/mod.rs:1126-1135 | engine/baml-runtime/src/tracing/mod.rs:1178-1187 — 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) baml_language/crates/baml_compiler2_ast/src/lower_cst.rs:1555— baml_language/crates/baml_compiler2_ast/src/lower_cst.rs:1555-1564 | baml_language/crates/baml_compiler2_ast/src/lower_cst.rs:1566-1575 | baml_language/crates/baml_compiler2_ast/src/lower_cst.rs:1598-1607 — 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.
baml_compiler::thir::typecheck::typecheck_expression (cyclomatic 210) engine/baml-compiler/src/thir/typecheck.rs:1486— baml_compiler::thir::typecheck::typecheck_expression has cyclomatic complexity 210 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
baml_compiler::thir::interpret::evaluate_block_with_control_flow::handle_statement (cyclomatic 101) engine/baml-compiler/src/thir/interpret.rs:533— baml_compiler::thir::interpret::evaluate_block_with_control_flow::handle_statement has cyclomatic complexity 101 (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.
baml_compiler::thir::typecheck::typecheck_returning_context (cyclomatic 62) engine/baml-compiler/src/thir/typecheck.rs:41— baml_compiler::thir::typecheck::typecheck_returning_context 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.
baml_compiler::thir::interpret::evaluate_expr_with_context (cyclomatic 58) engine/baml-compiler/src/thir/interpret.rs:1639— baml_compiler::thir::interpret::evaluate_expr_with_context has cyclomatic complexity 58 (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.
baml_compiler::thir::interpret::evaluate_binary_op (cyclomatic 56) engine/baml-compiler/src/thir/interpret.rs:2341— baml_compiler::thir::interpret::evaluate_binary_op has cyclomatic complexity 56 (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.
baml_compiler::thir::interpret::evaluate_method_call (cyclomatic 49) engine/baml-compiler/src/thir/interpret.rs:2797— baml_compiler::thir::interpret::evaluate_method_call 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.
baml_compiler::thir::typecheck::typecheck_statement (cyclomatic 40) engine/baml-compiler/src/thir/typecheck.rs:923— baml_compiler::thir::typecheck::typecheck_statement 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.
baml_compiler::hir::lowering::lower_stmt_with_options (cyclomatic 33) engine/baml-compiler/src/hir/lowering.rs:472— baml_compiler::hir::lowering::lower_stmt_with_options 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.
baml_compiler::codegen::compile_thir_to_bytecode (cyclomatic 26) engine/baml-compiler/src/codegen.rs:48— baml_compiler::codegen::compile_thir_to_bytecode has cyclomatic complexity 26 (threshold 15). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
baml_compiler::thir::interpret::parse_json_to_baml_value (cyclomatic 23) engine/baml-compiler/src/thir/interpret.rs:2589— baml_compiler::thir::interpret::parse_json_to_baml_value has cyclomatic complexity 23 (threshold 15). Most of this is not in the body itself: 1 of the 23 points is its own statement and the rest belongs to 2 function items inside it that branch (json_to_baml, json_to_baml_inferred). 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.
baml_compiler::thir::interpret::check_watch_changes (cyclomatic 22) engine/baml-compiler/src/thir/interpret.rs:180— baml_compiler::thir::interpret::check_watch_changes has cyclomatic complexity 22 (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.
baml_compiler::hir::lowering::type_ir_from_ast (cyclomatic 21) engine/baml-compiler/src/hir/lowering.rs:115— baml_compiler::hir::lowering::type_ir_from_ast 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.
baml_runtime::internal::prompt_renderer::render_output_format::relevant_data_models (cyclomatic 54) engine/baml-runtime/src/internal/prompt_renderer/render_output_format.rs:236— baml_runtime::internal::prompt_renderer::render_output_format::relevant_data_models 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.
baml_runtime::internal::llm_client::orchestrator::stream::orchestrate_stream (cyclomatic 35) engine/baml-runtime/src/internal/llm_client/orchestrator/stream.rs:151— baml_runtime::internal::llm_client::orchestrator::stream::orchestrate_stream has cyclomatic complexity 35 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
baml_runtime::tracingv2::storage::storage::build_function_log (cyclomatic 30) engine/baml-runtime/src/tracingv2/storage/storage.rs:162— baml_runtime::tracingv2::storage::storage::build_function_log has cyclomatic complexity 30 (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.
baml_runtime::internal::llm_client::traits::process_media (cyclomatic 29) engine/baml-runtime/src/internal/llm_client/traits/mod.rs:560— baml_runtime::internal::llm_client::traits::process_media has cyclomatic complexity 29 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
baml_runtime::optimize::evaluator::failure_location (cyclomatic 24) engine/baml-runtime/src/optimize/evaluator.rs:381— baml_runtime::optimize::evaluator::failure_location 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.
baml_runtime::tracingv2::publisher::rpc_converters::extract_blobs_from_trace_data (cyclomatic 23) engine/baml-runtime/src/tracingv2/publisher/rpc_converters/mod.rs:56— baml_runtime::tracingv2::publisher::rpc_converters::extract_blobs_from_trace_data 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.
baml_runtime::async_vm_runtime::try_vm_value_from_baml_value (cyclomatic 20) engine/baml-runtime/src/async_vm_runtime.rs:1231— baml_runtime::async_vm_runtime::try_vm_value_from_baml_value 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.
baml_runtime::internal::llm_client::primitive::stream_request::make_stream_request (cyclomatic 20) engine/baml-runtime/src/internal/llm_client/primitive/stream_request.rs:45— baml_runtime::internal::llm_client::primitive::stream_request::make_stream_request has cyclomatic complexity 20 (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.
baml_runtime::internal::llm_client::primitive::openai::response_handler::scan_openai_responses_stream (cyclomatic 18) engine/baml-runtime/src/internal/llm_client/primitive/openai/response_handler.rs:773— baml_runtime::internal::llm_client::primitive::openai::response_handler::scan_openai_responses_stream 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.
baml_runtime::optimize::tui::display_pareto_and_select (cyclomatic 18) engine/baml-runtime/src/optimize/tui.rs:1683— baml_runtime::optimize::tui::display_pareto_and_select 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.
baml_runtime::cli::init::generate_main_baml_content (cyclomatic 17) engine/baml-runtime/src/cli/init.rs:544— baml_runtime::cli::init::generate_main_baml_content has cyclomatic complexity 17 (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.
baml_runtime::internal::prompt_renderer::render_output_format::find_enum_value (cyclomatic 16) engine/baml-runtime/src/internal/prompt_renderer/render_output_format.rs:172— baml_runtime::internal::prompt_renderer::render_output_format::find_enum_value 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.
sdkgen_csharp::semantic::render_program (cognitive 67) baml_language/sdks/csharp/sdkgen_csharp/src/semantic.rs:3218— sdkgen_csharp::semantic::render_program has cognitive complexity 67 (threshold 15). Drivers by points: loops 19 (35 pts), if/else 17 (32 pts) (nesting depth added 31). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
sdkgen_csharp::semantic::generate_program_inner (cognitive 63) baml_language/sdks/csharp/sdkgen_csharp/src/semantic.rs:379— sdkgen_csharp::semantic::generate_program_inner has cognitive complexity 63 (threshold 15). Drivers by points: loops 21 (35 pts), if/else 11 (24 pts), boolean chains 4 (nesting depth added 27). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
sdkgen_csharp::semantic::collect_methods (cognitive 47) baml_language/sdks/csharp/sdkgen_csharp/src/semantic.rs:1230— sdkgen_csharp::semantic::collect_methods has cognitive complexity 47 (threshold 15). Drivers by points: if/else 19 (37 pts), loops 4 (7 pts), match/switch 1 (2 pts), boolean chains 1 (nesting depth added 22). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
sdkgen_csharp::semantic::require_supported_type_inner (cognitive 39) baml_language/sdks/csharp/sdkgen_csharp/src/semantic.rs:1766— sdkgen_csharp::semantic::require_supported_type_inner has cognitive complexity 39 (threshold 15). Drivers by points: if/else 9 (21 pts), match/switch 5 (10 pts), boolean chains 6, 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.
sdkgen_csharp::semantic::collect_functions (cognitive 34) baml_language/sdks/csharp/sdkgen_csharp/src/semantic.rs:1563— sdkgen_csharp::semantic::collect_functions has cognitive complexity 34 (threshold 15). Drivers by points: if/else 15 (30 pts), loops 2 (3 pts), boolean chains 1 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
sdkgen_csharp::semantic::render_functions (cognitive 34) baml_language/sdks/csharp/sdkgen_csharp/src/semantic.rs:2345— sdkgen_csharp::semantic::render_functions has cognitive complexity 34 (threshold 15). Drivers by points: if/else 16 (28 pts), loops 3 (5 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.
sdkgen_csharp::semantic::collect_type_closure (cognitive 27) baml_language/sdks/csharp/sdkgen_csharp/src/semantic.rs:2240— sdkgen_csharp::semantic::collect_type_closure has cognitive complexity 27 (threshold 15). Drivers by points: if/else 8 (15 pts), loops 5 (10 pts), boolean chains 1, match/switch 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.
sdkgen_csharp::semantic::encode_type_metadata (cognitive 22) baml_language/sdks/csharp/sdkgen_csharp/src/semantic.rs:4402— sdkgen_csharp::semantic::encode_type_metadata has cognitive complexity 22 (threshold 15). Drivers by points: match/switch 4 (8 pts), loops 3 (7 pts), if/else 3 (6 pts), boolean chains 1 (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.
sdkgen_csharp::semantic::render_class (cognitive 18) baml_language/sdks/csharp/sdkgen_csharp/src/semantic.rs:2737— sdkgen_csharp::semantic::render_class has cognitive complexity 18 (threshold 15). Drivers by points: if/else 10 (11 pts), loops 4 (7 pts) (nesting depth added 4). 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.
sdkgen_csharp::semantic::render_returned_callable_wrappers (cognitive 17) baml_language/sdks/csharp/sdkgen_csharp/src/semantic.rs:6457— sdkgen_csharp::semantic::render_returned_callable_wrappers has cognitive complexity 17 (threshold 15). Drivers by points: if/else 10 (16 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.
sdkgen_csharp::semantic::collect_enums (cognitive 16) baml_language/sdks/csharp/sdkgen_csharp/src/semantic.rs:1490— sdkgen_csharp::semantic::collect_enums has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (12 pts), loops 2 (3 pts), boolean chains 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
sdkgen_csharp::semantic::render_method_argument_builder (cognitive 16) baml_language/sdks/csharp/sdkgen_csharp/src/semantic.rs:3017— sdkgen_csharp::semantic::render_method_argument_builder has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (13 pts), loops 2, 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.
baml_builtins2_codegen::codegen::receiver_input_type_with_vm_usage (cognitive 28) baml_language/crates/baml_builtins2_codegen/src/codegen.rs:2160— baml_builtins2_codegen::codegen::receiver_input_type_with_vm_usage has cognitive complexity 28 (threshold 15). Drivers by points: if/else 14 (19 pts), boolean chains 5, match/switch 2 (4 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.
baml_builtins2_codegen::codegen::call_arg_list (cognitive 27) baml_language/crates/baml_builtins2_codegen/src/codegen.rs:1696— baml_builtins2_codegen::codegen::call_arg_list has cognitive complexity 27 (threshold 15). Drivers by points: if/else 9 (15 pts), match/switch 3 (8 pts), boolean chains 3, 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.
baml_builtins2_codegen::extract::extract_scoped (cognitive 26) baml_language/crates/baml_builtins2_codegen/src/extract.rs:114— baml_builtins2_codegen::extract::extract_scoped has cognitive complexity 26 (threshold 15). Drivers by points: if/else 7 (14 pts), loops 5 (8 pts), match/switch 1 (3 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.
baml_builtins2_codegen::extract::extract_from_class (cognitive 24) baml_language/crates/baml_builtins2_codegen/src/extract.rs:253— baml_builtins2_codegen::extract::extract_from_class has cognitive complexity 24 (threshold 15). Drivers by points: if/else 10 (16 pts), match/switch 2 (4 pts), loops 2 (3 pts), boolean chains 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
baml_builtins2_codegen::codegen::emit_namespace_trait (cognitive 22) baml_language/crates/baml_builtins2_codegen/src/codegen.rs:859— baml_builtins2_codegen::codegen::emit_namespace_trait has cognitive complexity 22 (threshold 15). Drivers by points: loops 8 (14 pts), if/else 6 (7 pts), boolean chains 1 (nesting depth added 7). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
baml_builtins2_codegen::codegen::extraction_expr (cognitive 21) baml_language/crates/baml_builtins2_codegen/src/codegen.rs:1585— baml_builtins2_codegen::codegen::extraction_expr has cognitive complexity 21 (threshold 15). Drivers by points: if/else 14 (19 pts), boolean chains 1, 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.
baml_builtins2_codegen::codegen::receiver_immut_extraction_expr (cognitive 19) baml_language/crates/baml_builtins2_codegen/src/codegen.rs:1502— baml_builtins2_codegen::codegen::receiver_immut_extraction_expr has cognitive complexity 19 (threshold 15). Drivers by points: if/else 12 (18 pts), match/switch 1 (nesting depth added 6). 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.
baml_builtins2_codegen::codegen::call_arg_for_type (cognitive 18) baml_language/crates/baml_builtins2_codegen/src/codegen.rs:1761— baml_builtins2_codegen::codegen::call_arg_for_type has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (11 pts), match/switch 3 (7 pts) (nesting depth added 9). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
baml_builtins2_codegen::codegen_io::emit_runtime_io_handles (cognitive 18) baml_language/crates/baml_builtins2_codegen/src/codegen_io.rs:2363— baml_builtins2_codegen::codegen_io::emit_runtime_io_handles has cognitive complexity 18 (threshold 15). Drivers by points: if/else 3 (11 pts), loops 3 (7 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.
baml_builtins2_codegen::extract::extract_from_implements_for (cognitive 18) baml_language/crates/baml_builtins2_codegen/src/extract.rs:590— baml_builtins2_codegen::extract::extract_from_implements_for has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (10 pts), match/switch 3 (5 pts), 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.
baml_builtins2_codegen::codegen_io::compute_non_defaultable_classes (cognitive 17) baml_language/crates/baml_builtins2_codegen/src/codegen_io.rs:1152— baml_builtins2_codegen::codegen_io::compute_non_defaultable_classes has cognitive complexity 17 (threshold 15). Drivers by points: if/else 4 (10 pts), loops 3 (4 pts), boolean chains 2, match/switch 1 (nesting depth added 7). Of this number, 15 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.
baml_builtins2_codegen::codegen_io::emit_result_conversion_for_ty (cognitive 17) baml_language/crates/baml_builtins2_codegen/src/codegen_io.rs:2712— baml_builtins2_codegen::codegen_io::emit_result_conversion_for_ty has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (14 pts), match/switch 2 (3 pts) (nesting depth added 9). 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.
BexEngine::run_thread_event_loop_inner (cyclomatic 79) baml_language/crates/bex_engine/src/lib.rs:5882— BexEngine::run_thread_event_loop_inner 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.
BexEngine::materialize_external_node (cyclomatic 60) baml_language/crates/bex_engine/src/conversion.rs:1413— BexEngine::materialize_external_node has cyclomatic complexity 60 (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.
BexEngine::convert_heap_ptr_to_external_with_type (cyclomatic 36) baml_language/crates/bex_engine/src/conversion.rs:597— BexEngine::convert_heap_ptr_to_external_with_type 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.
BexEngine::validate_host_return_schema (cyclomatic 34) baml_language/crates/bex_engine/src/conversion.rs:3865— BexEngine::validate_host_return_schema has cyclomatic complexity 34 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
BexEngine::projected_surface (cyclomatic 29) baml_language/crates/bex_engine/src/lib.rs:7006— BexEngine::projected_surface has cyclomatic complexity 29 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
BexEngine::call_callable_with_outcome_impl (cyclomatic 28) baml_language/crates/bex_engine/src/lib.rs:4049— BexEngine::call_callable_with_outcome_impl has cyclomatic complexity 28 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
BexEngine::shutdown_with_deadline (cyclomatic 26) baml_language/crates/bex_engine/src/lib.rs:2859— BexEngine::shutdown_with_deadline 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.
BexEngine::synth_ty_from_value (cyclomatic 24) baml_language/crates/bex_engine/src/conversion.rs:928— BexEngine::synth_ty_from_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.
BexEngine::landed_kind_admitted (cyclomatic 24) baml_language/crates/bex_engine/src/conversion.rs:4464— BexEngine::landed_kind_admitted 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.
BexEngine::call_resolved_with_trace (cyclomatic 23) baml_language/crates/bex_engine/src/lib.rs:3441— BexEngine::call_resolved_with_trace 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.
BexEngine::new_with_config (cyclomatic 20) baml_language/crates/bex_engine/src/lib.rs:1876— BexEngine::new_with_config has cyclomatic complexity 20 (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.
sdkgen_go::render_functions (cyclomatic 45) baml_language/sdks/go/sdkgen_go/src/lib.rs:1789— sdkgen_go::render_functions has cyclomatic complexity 45 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
sdkgen_go::names::hash_go_ty (cyclomatic 32) baml_language/sdks/go/sdkgen_go/src/names.rs:1048— sdkgen_go::names::hash_go_ty 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.
sdkgen_go::names::project_base (cyclomatic 26) baml_language/sdks/go/sdkgen_go/src/names.rs:1193— sdkgen_go::names::project_base has cyclomatic complexity 26 (threshold 15). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
sdkgen_go::collect_projected_codec_types (cyclomatic 23) baml_language/sdks/go/sdkgen_go/src/lib.rs:1148— sdkgen_go::collect_projected_codec_types has cyclomatic complexity 23 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions. This is NOT this file's highest cyclomatic complexity: sdkgen_go::baml_type_descriptor (cyclomatic 31) 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.
sdkgen_go::add_projected_type_imports (cyclomatic 23) baml_language/sdks/go/sdkgen_go/src/lib.rs:2476— sdkgen_go::add_projected_type_imports 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. This is NOT this file's highest cyclomatic complexity: sdkgen_go::baml_type_descriptor (cyclomatic 31) 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.
sdkgen_go::generated_functions (cyclomatic 20) baml_language/sdks/go/sdkgen_go/src/lib.rs:641— sdkgen_go::generated_functions has cyclomatic complexity 20 (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: sdkgen_go::baml_type_descriptor (cyclomatic 31) 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.
sdkgen_go::render_callback_codecs (cyclomatic 19) baml_language/sdks/go/sdkgen_go/src/lib.rs:3926— sdkgen_go::render_callback_codecs has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This is NOT this file's highest cyclomatic complexity: sdkgen_go::baml_type_descriptor (cyclomatic 31) 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.
sdkgen_go::render_union_codecs (cyclomatic 18) baml_language/sdks/go/sdkgen_go/src/lib.rs:3575— sdkgen_go::render_union_codecs has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This is NOT this file's highest cyclomatic complexity: sdkgen_go::baml_type_descriptor (cyclomatic 31) 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.
sdkgen_go::add_function_surface_imports (cyclomatic 17) baml_language/sdks/go/sdkgen_go/src/lib.rs:2399— sdkgen_go::add_function_surface_imports 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: sdkgen_go::baml_type_descriptor (cyclomatic 31) 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.
sdkgen_go::add_projected_surface_imports (cyclomatic 16) baml_language/sdks/go/sdkgen_go/src/lib.rs:2563— sdkgen_go::add_projected_surface_imports 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. This is NOT this file's highest cyclomatic complexity: sdkgen_go::baml_type_descriptor (cyclomatic 31) 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.
sdkgen_go::render_types (cyclomatic 16) baml_language/sdks/go/sdkgen_go/src/lib.rs:4503— sdkgen_go::render_types has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This is NOT this file's highest cyclomatic complexity: sdkgen_go::baml_type_descriptor (cyclomatic 31) 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.
baml_compiler2_ast::lower_cst::lower_file_with_path_and_test_owner_impl (cognitive 57) baml_language/crates/baml_compiler2_ast/src/lower_cst.rs:103— baml_compiler2_ast::lower_cst::lower_file_with_path_and_test_owner_impl has cognitive complexity 57 (threshold 15). Drivers by points: if/else 20 (48 pts), match/switch 3 (5 pts), boolean chains 2, loops 2 (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.
baml_compiler2_ast::lower_expr_body::synthesize_llm_spec_body (cognitive 33) baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:521— baml_compiler2_ast::lower_expr_body::synthesize_llm_spec_body has cognitive complexity 33 (threshold 15). Drivers by points: if/else 12 (18 pts), match/switch 6 (9 pts), boolean chains 3, loops 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.
baml_compiler2_ast::lower_cst::lower_function (cognitive 20) baml_language/crates/baml_compiler2_ast/src/lower_cst.rs:447— baml_compiler2_ast::lower_cst::lower_function has cognitive complexity 20 (threshold 15). Drivers by points: if/else 11 (16 pts), boolean chains 2, match/switch 1 (2 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
baml_compiler2_ast::lower_cst::test_owner_from_path (cognitive 20) baml_language/crates/baml_compiler2_ast/src/lower_cst.rs:2025— baml_compiler2_ast::lower_cst::test_owner_from_path has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (15 pts), boolean chains 3, 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.
baml_compiler2_ast::lower_cst::lower_params_with_defaults (cognitive 19) baml_language/crates/baml_compiler2_ast/src/lower_cst.rs:725— baml_compiler2_ast::lower_cst::lower_params_with_defaults has cognitive complexity 19 (threshold 15). Drivers by points: if/else 5 (15 pts), loops 2, match/switch 1 (2 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
baml_compiler2_ast::lower_cst::resolve_llm_client (cognitive 19) baml_language/crates/baml_compiler2_ast/src/lower_cst.rs:1131— baml_compiler2_ast::lower_cst::resolve_llm_client has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (18 pts), boolean chains 1 (nesting depth added 11). 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.
baml_compiler2_ast::lower_cst::extract_generic_params_with_bounds (cognitive 19) baml_language/crates/baml_compiler2_ast/src/lower_cst.rs:1326— baml_compiler2_ast::lower_cst::extract_generic_params_with_bounds has cognitive complexity 19 (threshold 15). Drivers by points: if/else 4 (12 pts), loops 3 (6 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.
baml_compiler2_ast::docstring::trace_hook (cognitive 18) baml_language/crates/baml_compiler2_ast/src/docstring.rs:166— baml_compiler2_ast::docstring::trace_hook has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (10 pts), boolean chains 5, match/switch 1 (2 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.
baml_compiler2_ast::docstring::extract_docstring (cognitive 17) baml_language/crates/baml_compiler2_ast/src/docstring.rs:77— baml_compiler2_ast::docstring::extract_docstring has cognitive complexity 17 (threshold 15). Drivers by points: if/else 4 (11 pts), match/switch 2 (5 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.
baml_compiler2_ast::lower_cst::check_string_escapes (cognitive 16) baml_language/crates/baml_compiler2_ast/src/lower_cst.rs:309— baml_compiler2_ast::lower_cst::check_string_escapes has cognitive complexity 16 (threshold 15). Drivers by points: loops 4 (8 pts), if/else 3 (6 pts), match/switch 1 (2 pts) (nesting depth added 8). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
baml_compiler2_ast::lower_type_expr::lower_from_type_name_with_generic_args (cognitive 16) baml_language/crates/baml_compiler2_ast/src/lower_type_expr.rs:250— baml_compiler2_ast::lower_type_expr::lower_from_type_name_with_generic_args has cognitive complexity 16 (threshold 15). Drivers by points: match/switch 4 (11 pts), if/else 3 (4 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.
D4 · Code Duplication· Members sharing a duplicated core (5 members, 50+ identical tokens) · ×11
Members sharing a duplicated core (5 members, 50+ identical tokens) baml_language/crates/baml_compiler2_mir/src/lower.rs:7628— baml_language/crates/baml_compiler2_mir/src/lower.rs:7628-7653 | baml_language/crates/baml_compiler2_mir/src/lower.rs:7789-7833 | baml_language/crates/baml_compiler2_mir/src/lower.rs:7841-7881 | baml_language/crates/baml_compiler2_mir/src/lower.rs:7925-7965 | baml_language/crates/baml_compiler2_mir/src/lower.rs:8176-8216 — 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) baml_language/crates/baml_compiler_parser/src/parser.rs:5578— baml_language/crates/baml_compiler_parser/src/parser.rs:5578-5608 | baml_language/crates/baml_compiler_parser/src/parser.rs:5610-5639 | baml_language/crates/baml_compiler_parser/src/parser.rs:6433-6477 | baml_language/crates/baml_compiler_parser/src/parser.rs:6489-6518 | baml_language/crates/baml_compiler_parser/src/parser.rs:7004-7042 — 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) baml_language/crates/baml_lsp/src/dispatch/requests.rs:407— baml_language/crates/baml_lsp/src/dispatch/requests.rs:407-416 | baml_language/crates/baml_lsp/src/dispatch/requests.rs:585-598 | baml_language/crates/baml_lsp/src/dispatch/requests.rs:678-698 | baml_language/crates/baml_lsp/src/dispatch/requests.rs:780-797 | baml_language/crates/baml_lsp/src/dispatch/requests.rs:802-844 — 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) baml_language/crates/baml_type/src/normalize.rs:745— baml_language/crates/baml_type/src/normalize.rs:745-793 | baml_language/crates/baml_type/src/normalize.rs:881-924 | baml_language/crates/baml_type/src/normalize.rs:1445-1496 | baml_language/crates/baml_type/src/normalize.rs:2442-2497 | baml_language/crates/baml_type/src/normalize.rs:2611-2658 — 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) engine/baml-lib/llm-client/src/clients/helpers.rs:94— engine/baml-lib/llm-client/src/clients/helpers.rs:94-109 | engine/baml-lib/llm-client/src/clients/helpers.rs:115-130 | engine/baml-lib/llm-client/src/clients/helpers.rs:136-151 | engine/baml-lib/llm-client/src/clients/helpers.rs:153-168 | engine/baml-lib/llm-client/src/clients/helpers.rs:170-185 — 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) engine/baml-runtime/src/internal/llm_client/primitive/anthropic/response_handler.rs:109— engine/baml-runtime/src/internal/llm_client/primitive/anthropic/response_handler.rs:109-186 | engine/baml-runtime/src/internal/llm_client/primitive/google/response_handler.rs:131-183 | engine/baml-runtime/src/internal/llm_client/primitive/openai/response_handler.rs:391-431 | engine/baml-runtime/src/internal/llm_client/primitive/openai/response_handler.rs:442-485 | engine/baml-runtime/src/internal/llm_client/primitive/vertex/response_handler.rs:127-192 — 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) engine/baml-schema-wasm/src/runtime_wasm/mod.rs:2040— engine/baml-schema-wasm/src/runtime_wasm/mod.rs:2040-2322 | engine/baml-schema-wasm/src/runtime_wasm/mod.rs:2446-2512 | engine/baml-schema-wasm/src/runtime_wasm/mod.rs:2557-2622 | engine/baml-schema-wasm/src/runtime_wasm/mod.rs:2635-2902 | engine/baml-schema-wasm/src/runtime_wasm/mod.rs:2914-3106 — 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) engine/generators/languages/go/src/ir_to_go/enums.rs:8— engine/generators/languages/go/src/ir_to_go/enums.rs:8-21 | engine/generators/languages/python/src/ir_to_py/enums.rs:5-17 | engine/generators/languages/ruby/src/ir_to_rb/enums.rs:5-17 | engine/generators/languages/rust/src/ir_to_rust/enums.rs:5-17 | engine/generators/languages/typescript/src/ir_to_ts/enums.rs:3-15 — 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) baml_language/sdks/go/baml_go/class.go:19— baml_language/sdks/go/baml_go/class.go:19-72 | baml_language/sdks/go/baml_go/container.go:85-97 | baml_language/sdks/go/baml_go/container.go:164-181 | baml_language/sdks/go/baml_go/container.go:185-198 | baml_language/sdks/go/baml_go/dynamic.go:225-236 — 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) baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:242— baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:242-249 | baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:356-364 | baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:481-490 | baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:617-627 | baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:764-775 — 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) baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:251— baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:251-258 | baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:366-374 | baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:492-501 | baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:629-639 | baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:777-788 — 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.
Duplicated block (19 lines × 2) baml_language/crates/baml_compiler2_visualization/src/control_flow/from_ast.rs:380— baml_language/crates/baml_compiler2_visualization/src/control_flow/from_ast.rs:380-398 | baml_language/crates/baml_compiler2_visualization/src/control_flow/from_ast.rs:416-434 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (19 lines × 2) baml_language/crates/baml_compiler_parser/src/parser.rs:2060— baml_language/crates/baml_compiler_parser/src/parser.rs:2060-2078 | baml_language/crates/baml_compiler_parser/src/parser.rs:2098-2116 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_fmt/src/ast/declarations.rs:3039— baml_language/crates/baml_fmt/src/ast/declarations.rs:3039-3057 | baml_language/crates/baml_fmt/src/ast/declarations.rs:3119-3137 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_fmt/src/ast/pattern.rs:497— baml_language/crates/baml_fmt/src/ast/pattern.rs:497-515 | baml_language/crates/baml_fmt/src/ast/pattern.rs:720-738 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_ide/src/resolve.rs:276— baml_language/crates/baml_ide/src/resolve.rs:276-294 | baml_language/crates/baml_ide/src/resolve.rs:448-466 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_type/src/normalize/mu.rs:695— baml_language/crates/baml_type/src/normalize/mu.rs:695-713 | baml_language/crates/baml_type/src/normalize/mu.rs:1426-1444 — both copies are in the same file, so extract the block into 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) baml_language/crates/bex_sap/src/jsonish/parser/mod.rs:40— baml_language/crates/bex_sap/src/jsonish/parser/mod.rs:40-58 | engine/baml-lib/jsonish/src/jsonish/parser/mod.rs:37-55 — 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 (19 lines × 2) baml_language/crates/bex_vm/src/package_reflect/reflect.rs:487— baml_language/crates/bex_vm/src/package_reflect/reflect.rs:487-505 | baml_language/crates/bex_vm/src/type_context.rs:70-88 — 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 (19 lines × 2) baml_language/crates/sys_ops/src/lib.rs:2961— baml_language/crates/sys_ops/src/lib.rs:2961-2979 | baml_language/crates/sys_ops/src/lib.rs:3057-3075 — both copies are in the same file, so extract the block into 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) engine/baml-lib/jsonish/src/helpers/mod.rs:326— engine/baml-lib/jsonish/src/helpers/mod.rs:326-344 | engine/baml-runtime/src/internal/llm_client/mod.rs:39-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 (19 lines × 2) baml_language/tools/speedtest/workloads/memory/allocation-high-retention/main.py:10— baml_language/tools/speedtest/workloads/memory/allocation-high-retention/main.py:10-28 | baml_language/tools/speedtest/workloads/memory/allocation-low-retention/main.py:10-28 — `baml_language/tools/speedtest/workloads/memory/allocation-high-retention/main.py` and `baml_language/tools/speedtest/workloads/memory/allocation-low-retention/main.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 19 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.
baml_compiler2_emit::stack_carry::simulate_terminator_stack (cyclomatic 46) baml_language/crates/baml_compiler2_emit/src/stack_carry.rs:575— baml_compiler2_emit::stack_carry::simulate_terminator_stack 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.
baml_compiler2_emit::stack_carry::is_stack_carry_use_safe (cyclomatic 38) baml_language/crates/baml_compiler2_emit/src/stack_carry.rs:178— baml_compiler2_emit::stack_carry::is_stack_carry_use_safe 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.
baml_compiler2_emit::pull_semantics::walk_rvalue_pull (cyclomatic 36) baml_language/crates/baml_compiler2_emit/src/pull_semantics.rs:386— baml_compiler2_emit::pull_semantics::walk_rvalue_pull has cyclomatic complexity 36 (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.
baml_compiler2_emit::analysis::collect_uses_in_terminator (cyclomatic 33) baml_language/crates/baml_compiler2_emit/src/analysis.rs:867— baml_compiler2_emit::analysis::collect_uses_in_terminator 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.
baml_compiler2_emit::analysis::classify_locals (cyclomatic 25) baml_language/crates/baml_compiler2_emit/src/analysis.rs:1394— baml_compiler2_emit::analysis::classify_locals 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.
baml_compiler2_emit::analysis::is_return_phi (cyclomatic 19) baml_language/crates/baml_compiler2_emit/src/analysis.rs:1785— baml_compiler2_emit::analysis::is_return_phi 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.
baml_compiler2_emit::analysis::collect_def_use (cyclomatic 18) baml_language/crates/baml_compiler2_emit/src/analysis.rs:606— baml_compiler2_emit::analysis::collect_def_use has cyclomatic complexity 18 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
baml_compiler2_emit::compute_function_metadata (cyclomatic 17) baml_language/crates/baml_compiler2_emit/src/lib.rs:298— baml_compiler2_emit::compute_function_metadata has cyclomatic complexity 17 (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.
baml_compiler2_emit::analysis::rematerializable (cyclomatic 17) baml_language/crates/baml_compiler2_emit/src/analysis.rs:1309— baml_compiler2_emit::analysis::rematerializable has cyclomatic complexity 17 (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.
baml_compiler2_emit::package::type_pass (cyclomatic 16) baml_language/crates/baml_compiler2_emit/src/package/mod.rs:189— baml_compiler2_emit::package::type_pass has cyclomatic complexity 16 (threshold 15). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
jsonish::helpers::relevant_data_models (cognitive 99) engine/baml-lib/jsonish/src/helpers/mod.rs:127— jsonish::helpers::relevant_data_models has cognitive complexity 99 (threshold 15). Drivers by points: if/else 23 (72 pts), loops 7 (25 pts), match/switch 1 (2 pts) (nesting depth added 68). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
jsonish::deserializer::coercer::array_helper::pick_best (cognitive 58) engine/baml-lib/jsonish/src/deserializer/coercer/array_helper.rs:29— jsonish::deserializer::coercer::array_helper::pick_best has cognitive complexity 58 (threshold 15). Drivers by points: if/else 14 (24 pts), match/switch 11 (23 pts), boolean chains 11 (nesting depth added 22). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
jsonish::jsonish::parser::entry::parse_func (cognitive 48) engine/baml-lib/jsonish/src/jsonish/parser/entry.rs:15— jsonish::jsonish::parser::entry::parse_func has cognitive complexity 48 (threshold 15). Drivers by points: match/switch 12 (34 pts), if/else 9 (13 pts), boolean chains 1 (nesting depth added 26). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own 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.
jsonish::jsonish::parser::multi_json_parser::parse (cognitive 36) engine/baml-lib/jsonish/src/jsonish/parser/multi_json_parser.rs:6— jsonish::jsonish::parser::multi_json_parser::parse has cognitive complexity 36 (threshold 15). Drivers by points: if/else 10 (25 pts), match/switch 5 (10 pts), loops 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.
jsonish::deserializer::coercer::match_string::string_match_strategy (cognitive 35) engine/baml-lib/jsonish/src/deserializer/coercer/match_string.rs:192— jsonish::deserializer::coercer::match_string::string_match_strategy has cognitive complexity 35 (threshold 15). Drivers by points: loops 10 (19 pts), if/else 10 (15 pts), match/switch 1 (nesting depth added 14). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
jsonish::jsonish::parser::markdown_parser::parse (cognitive 34) engine/baml-lib/jsonish/src/jsonish/parser/markdown_parser.rs:29— jsonish::jsonish::parser::markdown_parser::parse has cognitive complexity 34 (threshold 15). Drivers by points: if/else 11 (26 pts), loops 2 (4 pts), match/switch 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.
jsonish::deserializer::coercer::coerce_union::try_cast_union (cognitive 24) engine/baml-lib/jsonish/src/deserializer/coercer/coerce_union.rs:10— jsonish::deserializer::coercer::coerce_union::try_cast_union has cognitive complexity 24 (threshold 15). Drivers by points: if/else 9 (18 pts), match/switch 3 (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.
jsonish::deserializer::coercer::coerce_map::coerce_map (cognitive 23) engine/baml-lib/jsonish/src/deserializer/coercer/coerce_map.rs:84— jsonish::deserializer::coercer::coerce_map::coerce_map has cognitive complexity 23 (threshold 15). Drivers by points: match/switch 5 (11 pts), if/else 4 (8 pts), loops 2 (4 pts) (nesting depth added 12). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own 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.
jsonish::deserializer::coercer::coerce_union::coerce_union (cognitive 21) engine/baml-lib/jsonish/src/deserializer/coercer/coerce_union.rs:111— jsonish::deserializer::coercer::coerce_union::coerce_union has cognitive complexity 21 (threshold 15). Drivers by points: if/else 8 (19 pts), loops 1, match/switch 1 (nesting depth added 11). 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.
jsonish::jsonish::parser::fixing_parser::parse (cognitive 19) engine/baml-lib/jsonish/src/jsonish/parser/fixing_parser.rs:11— jsonish::jsonish::parser::fixing_parser::parse has cognitive complexity 19 (threshold 15). Drivers by points: if/else 4 (7 pts), match/switch 3 (6 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.
baml_type::normalize::mu::algebra_pass (cognitive 46) baml_language/crates/baml_type/src/normalize/mu.rs:860— baml_type::normalize::mu::algebra_pass has cognitive complexity 46 (threshold 15). Drivers by points: if/else 11 (33 pts), loops 3 (8 pts), boolean chains 3, match/switch 1 (2 pts) (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.
baml_type::normalize::mu::epsilon_close (cognitive 32) baml_language/crates/baml_type/src/normalize/mu.rs:610— baml_type::normalize::mu::epsilon_close has cognitive complexity 32 (threshold 15). Drivers by points: if/else 8 (20 pts), loops 4 (8 pts), match/switch 1 (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.
baml_type::unify::cover_search (cognitive 22) baml_language/crates/baml_type/src/unify.rs:1144— baml_type::unify::cover_search has cognitive complexity 22 (threshold 15). Drivers by points: if/else 6 (14 pts), loops 3 (4 pts), match/switch 2 (4 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.
baml_type::normalize::mu::minimize (cognitive 21) baml_language/crates/baml_type/src/normalize/mu.rs:743— baml_type::normalize::mu::minimize has cognitive complexity 21 (threshold 15). Drivers by points: loops 9 (14 pts), if/else 2 (4 pts), match/switch 1 (3 pts) (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.
baml_type::pattern_overlap::pattern_bounds_refute (cognitive 19) baml_language/crates/baml_type/src/pattern_overlap.rs:330— baml_type::pattern_overlap::pattern_bounds_refute has cognitive complexity 19 (threshold 15). Drivers by points: if/else 8 (14 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.
baml_type::normalize::mu::cyclic_states (cognitive 18) baml_language/crates/baml_type/src/normalize/mu.rs:1396— baml_type::normalize::mu::cyclic_states has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (14 pts), loops 3 (4 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
baml_type::json_inhabit::has_empty_value_within (cognitive 17) baml_language/crates/baml_type/src/json_inhabit.rs:805— baml_type::json_inhabit::has_empty_value_within 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.
baml_type::normalize::mu::convert (cognitive 17) baml_language/crates/baml_type/src/normalize/mu.rs:1249— baml_type::normalize::mu::convert has cognitive complexity 17 (threshold 15). Drivers by points: match/switch 5 (12 pts), if/else 3 (5 pts) (nesting depth added 9). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own 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.
baml_type::decl_cycles::extract_type_alias_deps::visit (cognitive 16) baml_language/crates/baml_type/src/decl_cycles.rs:116— baml_type::decl_cycles::extract_type_alias_deps::visit has cognitive complexity 16 (threshold 15). Drivers by points: loops 6 (12 pts), if/else 2 (3 pts), match/switch 1 (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.
baml_type::normalize::mu::epsilon_sccs (cognitive 16) baml_language/crates/baml_type/src/normalize/mu.rs:666— baml_type::normalize::mu::epsilon_sccs has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (10 pts), loops 3 (4 pts), boolean chains 2 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Duplicated block (21 lines × 2) baml_language/crates/baml_lsp/src/dispatch/mod.rs:125— baml_language/crates/baml_lsp/src/dispatch/mod.rs:125-145 | baml_language/crates/baml_lsp/src/dispatch/mod.rs:177-197 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_type/src/unify.rs:322— baml_language/crates/baml_type/src/unify.rs:322-342 | baml_language/crates/baml_type/src/unify.rs:1294-1314 — both copies are in the same file, so extract the block into 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) baml_language/crates/bex_vm/src/debug.rs:574— baml_language/crates/bex_vm/src/debug.rs:574-594 | engine/baml-vm/src/debug.rs:295-315 — before extracting anything, compare `baml_language/crates/bex_vm/src/debug.rs` and `engine/baml-vm/src/debug.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 57 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (21 lines × 2) baml_language/crates/bex_vm/src/telemetry.rs:804— baml_language/crates/bex_vm/src/telemetry.rs:804-824 | baml_language/crates/bex_vm/src/telemetry.rs:899-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 (21 lines × 2) engine/baml-lib/jsonish/src/helpers/mod.rs:257— engine/baml-lib/jsonish/src/helpers/mod.rs:257-277 | engine/baml-runtime/src/internal/prompt_renderer/render_output_format.rs:443-463 — before extracting anything, compare `engine/baml-lib/jsonish/src/helpers/mod.rs` and `engine/baml-runtime/src/internal/prompt_renderer/render_output_format.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 48 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (21 lines × 2) engine/baml-rpc/src/runtime_api/baml_value.rs:38— engine/baml-rpc/src/runtime_api/baml_value.rs:38-58 | engine/baml-rpc/src/runtime_api/baml_value.rs:124-144 — both copies are in the same file, so extract the block into 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) engine/generators/languages/python/src/watchers.rs:148— engine/generators/languages/python/src/watchers.rs:148-168 | engine/generators/languages/typescript/src/watchers.rs:144-164 — before extracting anything, compare `engine/generators/languages/python/src/watchers.rs` and `engine/generators/languages/typescript/src/watchers.rs` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 146 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (21 lines × 2) engine/generators/languages/python/src/watchers.rs:199— engine/generators/languages/python/src/watchers.rs:199-219 | engine/generators/languages/typescript/src/watchers.rs:195-215 — before extracting anything, compare `engine/generators/languages/python/src/watchers.rs` and `engine/generators/languages/typescript/src/watchers.rs` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 146 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (21 lines × 2) engine/generators/languages/ruby/src/ir_to_rb/mod.rs:238— engine/generators/languages/ruby/src/ir_to_rb/mod.rs:238-258 | engine/generators/languages/ruby/src/ir_to_rb/mod.rs:264-284 — both copies are in the same file, so extract the block into 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) baml_language/sdks/java/baml_bridge/src/main/java/baml_bridge/BamlCancelledError.java:33— baml_language/sdks/java/baml_bridge/src/main/java/baml_bridge/BamlCancelledError.java:33-53 | baml_language/sdks/java/baml_bridge/src/main/java/baml_bridge/BamlPanic.java:27-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 both call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (5 lines × 3) baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:5230— baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:5230-5243 | baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:5378-5382 | baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:5397-5401 — 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) baml_language/crates/baml_fmt/src/ast/declarations.rs:492— baml_language/crates/baml_fmt/src/ast/declarations.rs:492-496 | baml_language/crates/baml_fmt/src/ast/expressions.rs:845-849 | baml_language/crates/baml_fmt/src/ast/statements.rs:844-849 — before extracting anything, compare `baml_language/crates/baml_fmt/src/ast/declarations.rs` and `baml_language/crates/baml_fmt/src/ast/expressions.rs` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 124 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the 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 × 3) baml_language/crates/baml_fmt/src/ast/declarations.rs:936— baml_language/crates/baml_fmt/src/ast/declarations.rs:936-940 | baml_language/crates/baml_fmt/src/ast/declarations.rs:1027-1031 | baml_language/crates/baml_fmt/src/ast/declarations.rs:1088-1092 — 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) baml_language/sdks/csharp/sdkgen_csharp/src/semantic.rs:944— baml_language/sdks/csharp/sdkgen_csharp/src/semantic.rs:944-948 | baml_language/sdks/csharp/sdkgen_csharp/src/semantic.rs:4213-4217 | baml_language/sdks/csharp/sdkgen_csharp/src/semantic.rs:4452-4456 — 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) engine/baml-lib/baml-types/src/baml_value.rs:548— engine/baml-lib/baml-types/src/baml_value.rs:548-552 | engine/baml-lib/baml-types/src/baml_value.rs:687-691 | engine/baml-lib/baml-types/src/baml_value.rs:823-827 — 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) engine/baml-lib/parser-database/src/names/mod.rs:47— engine/baml-lib/parser-database/src/names/mod.rs:47-51 | engine/baml-lib/parser-database/src/names/mod.rs:68-72 | engine/baml-lib/parser-database/src/names/mod.rs:87-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 (5 lines × 3) engine/baml-runtime/src/internal/llm_client/primitive/openai/response_handler.rs:478— engine/baml-runtime/src/internal/llm_client/primitive/openai/response_handler.rs:478-482 | engine/baml-runtime/src/internal/llm_client/primitive/openai/response_handler.rs:835-839 | engine/baml-runtime/src/internal/llm_client/primitive/openai/response_handler.rs:888-892 — 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) engine/baml-runtime/src/tracingv2/storage/storage.rs:311— engine/baml-runtime/src/tracingv2/storage/storage.rs:311-315 | engine/baml-runtime/src/tracingv2/storage/storage.rs:317-321 | engine/baml-runtime/src/tracingv2/storage/storage.rs:323-328 — 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) engine/baml-runtime/src/tracingv2/storage/storage.rs:771— engine/baml-runtime/src/tracingv2/storage/storage.rs:771-775 | engine/baml-runtime/src/tracingv2/storage/storage.rs:777-781 | engine/baml-runtime/src/tracingv2/storage/storage.rs:783-788 — 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) engine/generators/data/recursive_types/python/main.py:9— engine/generators/data/recursive_types/python/main.py:9-13 | engine/generators/data/sample/python/main.py:9-13 | engine/generators/data/unions/python/main.py:9-13 — before extracting anything, compare `engine/generators/data/recursive_types/python/main.py` and `engine/generators/data/sample/python/main.py` as WHOLE FILES: 100% of the shorter file's lines also appear in the other, so this reads as one file having been copied from the other rather than as a helper waiting to be extracted. The 1 duplicated block(s) this scan matched between them are fragments of that copy, not the extent of it — treat the file pair as the unit. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
baml_query_btel::ingest::reconcile (cognitive 90) baml_language/crates/baml_query_btel/src/ingest.rs:392— baml_query_btel::ingest::reconcile has cognitive complexity 90 (threshold 15). Drivers by points: if/else 18 (42 pts), match/switch 8 (21 pts), boolean chains 16, loops 6 (11 pts) (nesting depth added 42). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
baml_query_btel::query::run (cognitive 44) baml_language/crates/baml_query_btel/src/query.rs:282— baml_query_btel::query::run has cognitive complexity 44 (threshold 15). Drivers by points: if/else 22 (31 pts), match/switch 3 (8 pts), loops 4 (5 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.
baml_query_btel::functions::register (cognitive 31) baml_language/crates/baml_query_btel/src/functions.rs:964— baml_query_btel::functions::register has cognitive complexity 31 (threshold 15). Drivers by points: if/else 18, match/switch 9 (10 pts), boolean chains 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.
baml_query_btel::ingest::resolve_nodes (cognitive 27) baml_language/crates/baml_query_btel/src/ingest.rs:2051— baml_query_btel::ingest::resolve_nodes has cognitive complexity 27 (threshold 15). Drivers by points: if/else 6 (15 pts), loops 5 (7 pts), match/switch 2 (4 pts), boolean chains 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
baml_query_btel::ingest::context::resolve_with (cognitive 25) baml_language/crates/baml_query_btel/src/ingest/context.rs:115— baml_query_btel::ingest::context::resolve_with has cognitive complexity 25 (threshold 15). Drivers by points: if/else 7 (16 pts), loops 3 (5 pts), match/switch 1 (3 pts), boolean chains 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
baml_query_btel::ingest::apply_fresh (cognitive 21) baml_language/crates/baml_query_btel/src/ingest.rs:768— baml_query_btel::ingest::apply_fresh has cognitive complexity 21 (threshold 15). Drivers by points: if/else 8 (13 pts), boolean chains 3, match/switch 2 (3 pts), loops 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.
baml_query_btel::ingest::context::identity (cognitive 21) baml_language/crates/baml_query_btel/src/ingest/context.rs:214— baml_query_btel::ingest::context::identity has cognitive complexity 21 (threshold 15). Drivers by points: if/else 10 (15 pts), match/switch 3 (5 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.
baml_query_btel::ingest::profile::build (cognitive 20) baml_language/crates/baml_query_btel/src/ingest/profile.rs:268— baml_query_btel::ingest::profile::build has cognitive complexity 20 (threshold 15). Drivers by points: if/else 6 (11 pts), loops 5 (6 pts), boolean chains 3 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
baml_query_btel::store::write_statistics (cognitive 18) baml_language/crates/baml_query_btel/src/store.rs:184— baml_query_btel::store::write_statistics has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (10 pts), loops 3 (6 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.
sdkgen_go::render_functions (cognitive 86) baml_language/sdks/go/sdkgen_go/src/lib.rs:1789— sdkgen_go::render_functions has cognitive complexity 86 (threshold 15). Drivers by points: if/else 32 (57 pts), loops 12 (21 pts), boolean chains 8 (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.
sdkgen_go::render_union_codecs (cognitive 49) baml_language/sdks/go/sdkgen_go/src/lib.rs:3575— sdkgen_go::render_union_codecs has cognitive complexity 49 (threshold 15). Drivers by points: if/else 17 (37 pts), loops 4 (9 pts), boolean chains 3 (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.
sdkgen_go::render_callback_codecs (cognitive 39) baml_language/sdks/go/sdkgen_go/src/lib.rs:3926— sdkgen_go::render_callback_codecs has cognitive complexity 39 (threshold 15). Drivers by points: if/else 11 (20 pts), loops 6 (14 pts), match/switch 2 (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.
sdkgen_go::render_types (cognitive 33) baml_language/sdks/go/sdkgen_go/src/lib.rs:4503— sdkgen_go::render_types has cognitive complexity 33 (threshold 15). Drivers by points: if/else 9 (18 pts), loops 8 (15 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.
sdkgen_go::names::project_base (cognitive 29) baml_language/sdks/go/sdkgen_go/src/names.rs:1193— sdkgen_go::names::project_base has cognitive complexity 29 (threshold 15). Drivers by points: loops 13 (25 pts), if/else 3, match/switch 1 (nesting depth added 12). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
sdkgen_go::collect_projected_codec_types (cognitive 27) baml_language/sdks/go/sdkgen_go/src/lib.rs:1148— sdkgen_go::collect_projected_codec_types has cognitive complexity 27 (threshold 15). Drivers by points: loops 6 (15 pts), if/else 5 (10 pts), boolean chains 1, 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.
sdkgen_go::generated_functions (cognitive 24) baml_language/sdks/go/sdkgen_go/src/lib.rs:641— sdkgen_go::generated_functions has cognitive complexity 24 (threshold 15). Drivers by points: boolean chains 13, loops 3 (5 pts), if/else 2 (4 pts), match/switch 2 (nesting depth added 4). 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.
sdkgen_go::add_projected_type_imports (cognitive 18) baml_language/sdks/go/sdkgen_go/src/lib.rs:2476— sdkgen_go::add_projected_type_imports has cognitive complexity 18 (threshold 15). Drivers by points: loops 4 (9 pts), if/else 4 (7 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.
sdkgen_go::names::hash_go_ty (cognitive 17) baml_language/sdks/go/sdkgen_go/src/names.rs:1048— sdkgen_go::names::hash_go_ty has cognitive complexity 17 (threshold 15). Drivers by points: loops 4 (8 pts), if/else 2 (5 pts), match/switch 2 (4 pts) (nesting depth added 9). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
bex_sap::deserializer::coercer::array_helper::pick_best (cognitive 64) baml_language/crates/bex_sap/src/deserializer/coercer/array_helper.rs:42— bex_sap::deserializer::coercer::array_helper::pick_best has cognitive complexity 64 (threshold 15). Drivers by points: if/else 17 (27 pts), match/switch 13 (25 pts), boolean chains 12 (nesting depth added 22). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
bex_sap::jsonish::parser::entry::parse_func (cognitive 56) baml_language/crates/bex_sap/src/jsonish/parser/entry.rs:12— bex_sap::jsonish::parser::entry::parse_func has cognitive complexity 56 (threshold 15). Drivers by points: match/switch 10 (29 pts), if/else 15 (26 pts), boolean chains 1 (nesting depth added 30). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own 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.
bex_sap::jsonish::parser::multi_json_parser::parse (cognitive 36) baml_language/crates/bex_sap/src/jsonish/parser/multi_json_parser.rs:4— bex_sap::jsonish::parser::multi_json_parser::parse has cognitive complexity 36 (threshold 15). Drivers by points: if/else 11 (27 pts), match/switch 4 (8 pts), loops 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.
bex_sap::deserializer::coercer::match_string::string_match_strategy (cognitive 32) baml_language/crates/bex_sap/src/deserializer/coercer/match_string.rs:209— bex_sap::deserializer::coercer::match_string::string_match_strategy has cognitive complexity 32 (threshold 15). Drivers by points: loops 8 (17 pts), if/else 11 (14 pts), match/switch 1 (nesting depth added 12). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
bex_sap::jsonish::parser::markdown_parser::parse (cognitive 32) baml_language/crates/bex_sap/src/jsonish/parser/markdown_parser.rs:24— bex_sap::jsonish::parser::markdown_parser::parse has cognitive complexity 32 (threshold 15). Drivers by points: if/else 10 (24 pts), loops 2 (4 pts), match/switch 2 (4 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.
bex_sap::jsonish::parser::dedent::dedent (cognitive 22) baml_language/crates/bex_sap/src/jsonish/parser/dedent.rs:7— bex_sap::jsonish::parser::dedent::dedent has cognitive complexity 22 (threshold 15). Drivers by points: if/else 7 (13 pts), loops 4 (6 pts), boolean chains 3 (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.
bex_sap::jsonish::parser::fixing_parser::parse (cognitive 19) baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser.rs:8— bex_sap::jsonish::parser::fixing_parser::parse has cognitive complexity 19 (threshold 15). Drivers by points: if/else 4 (7 pts), match/switch 3 (6 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.
bex_sap::deserializer::coercer::coerce_class::class_from_entries (cognitive 17) baml_language/crates/bex_sap/src/deserializer/coercer/coerce_class.rs:343— bex_sap::deserializer::coercer::coerce_class::class_from_entries has cognitive complexity 17 (threshold 15). Drivers by points: match/switch 4 (9 pts), if/else 3 (6 pts), boolean chains 1, 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.
bex_sap::deserializer::coercer::write_shape_key (cognitive 16) baml_language/crates/bex_sap/src/deserializer/coercer/mod.rs:58— bex_sap::deserializer::coercer::write_shape_key has cognitive complexity 16 (threshold 15). Drivers by points: if/else 3 (9 pts), loops 3 (6 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.
Translator::raw (cognitive 59) baml_language/crates/baml_query_btel/src/sql.rs:935— Translator::raw has cognitive complexity 59 (threshold 15). Drivers by points: if/else 20 (39 pts), loops 6 (14 pts), match/switch 3 (5 pts), boolean chains 1 (nesting depth added 29). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
Translator::navigation (cognitive 34) baml_language/crates/baml_query_btel/src/sql.rs:1172— Translator::navigation has cognitive complexity 34 (threshold 15). Drivers by points: match/switch 8 (26 pts), if/else 3 (5 pts), loops 2 (3 pts) (nesting depth added 21). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own 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.
Translator::projection (cognitive 33) baml_language/crates/baml_query_btel/src/sql.rs:806— Translator::projection has cognitive complexity 33 (threshold 15). Drivers by points: if/else 8 (22 pts), match/switch 2 (5 pts), boolean chains 3, 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.
Translator::select (cognitive 26) baml_language/crates/baml_query_btel/src/sql.rs:619— Translator::select has cognitive complexity 26 (threshold 15). Drivers by points: if/else 9 (15 pts), loops 4 (7 pts), boolean chains 3, 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.
Translator::function (cognitive 26) baml_language/crates/baml_query_btel/src/sql.rs:1456— Translator::function has cognitive complexity 26 (threshold 15). Drivers by points: if/else 7 (12 pts), loops 4 (7 pts), match/switch 3 (5 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.
Translator::column (cognitive 24) baml_language/crates/baml_query_btel/src/sql.rs:405— Translator::column has cognitive complexity 24 (threshold 15). Drivers by points: if/else 7 (19 pts), loops 2 (3 pts), boolean chains 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.
Translator::query (cognitive 22) baml_language/crates/baml_query_btel/src/sql.rs:434— Translator::query has cognitive complexity 22 (threshold 15). Drivers by points: if/else 10 (16 pts), match/switch 2 (3 pts), loops 1 (2 pts), boolean chains 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Translator::table_factor (cognitive 16) baml_language/crates/baml_query_btel/src/sql.rs:725— Translator::table_factor has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (10 pts), match/switch 3 (4 pts), boolean chains 2 (nesting depth added 6). 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.
Translator::binary (cognitive 16) baml_language/crates/baml_query_btel/src/sql.rs:1257— Translator::binary has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (10 pts), match/switch 3 (4 pts), boolean chains 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.
Duplicated block (6 lines × 3) baml_language/crates/baml_compiler2_hir/src/item_data/classes.rs:90— baml_language/crates/baml_compiler2_hir/src/item_data/classes.rs:90-95 | baml_language/crates/baml_compiler2_hir/src/item_data/functions.rs:403-408 | baml_language/crates/baml_compiler2_hir/src/item_data/type_aliases.rs:57-62 — 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) baml_language/crates/bex_vm/src/vm.rs:11835— baml_language/crates/bex_vm/src/vm.rs:11835-11840 | baml_language/crates/bex_vm/src/vm.rs:11845-11850 | baml_language/crates/bex_vm/src/vm.rs:11855-11860 — 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) baml_language/sdks/csharp/sdkgen_csharp/src/semantic.rs:865— baml_language/sdks/csharp/sdkgen_csharp/src/semantic.rs:865-870 | baml_language/sdks/csharp/sdkgen_csharp/src/semantic.rs:943-948 | baml_language/sdks/csharp/sdkgen_csharp/src/semantic.rs:4451-4456 — 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) engine/baml-compiler/src/thir/typecheck.rs:66— engine/baml-compiler/src/thir/typecheck.rs:66-71 | engine/baml-compiler/src/thir/typecheck.rs:75-80 | engine/baml-compiler/src/thir/typecheck.rs:545-550 — 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) engine/baml-runtime/src/internal/llm_client/primitive/anthropic/anthropic_client.rs:446— engine/baml-runtime/src/internal/llm_client/primitive/anthropic/anthropic_client.rs:446-451 | engine/baml-runtime/src/internal/llm_client/primitive/google/googleai_client.rs:318-323 | engine/baml-runtime/src/internal/llm_client/primitive/vertex/vertex_client.rs:523-530 — before extracting anything, compare `engine/baml-runtime/src/internal/llm_client/primitive/anthropic/anthropic_client.rs` and `engine/baml-runtime/src/internal/llm_client/primitive/google/googleai_client.rs` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 79 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (6 lines × 3) engine/baml-lib/llm-client/src/clients/aws_bedrock.rs:499— engine/baml-lib/llm-client/src/clients/aws_bedrock.rs:499-504 | engine/baml-lib/llm-client/src/clients/aws_bedrock.rs:506-511 | engine/baml-lib/llm-client/src/clients/aws_bedrock.rs:513-518 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (6 lines × 3) baml_language/sdks/java/baml_bridge/src/main/java/baml_bridge/internal/ProtoReader.java:712— baml_language/sdks/java/baml_bridge/src/main/java/baml_bridge/internal/ProtoReader.java:712-717 | baml_language/sdks/java/baml_bridge/src/main/java/baml_bridge/internal/ProtoReader.java:1207-1212 | baml_language/sdks/java/baml_bridge/src/main/java/baml_bridge/internal/ProtoReader.java:1287-1292 — 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 `baml_language/sdks/java/baml_bridge/src/main/java/baml_bridge/internal/ProtoReader.java:712` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (6 lines × 3) scripts/ffi-debug/analyze_ffi.py:158— scripts/ffi-debug/analyze_ffi.py:158-163 | scripts/ffi-debug/analyze_ffi.py:169-174 | scripts/ffi-debug/analyze_ffi.py:176-181 — 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) baml_language/tools/speedtest/workloads/string/split-long-literal-1k/main.py:2— baml_language/tools/speedtest/workloads/string/split-long-literal-1k/main.py:2-7 | baml_language/tools/speedtest/workloads/string/split-medium-literal-10k/main.py:2-7 | baml_language/tools/speedtest/workloads/string/split-short-literal-100k/main.py:2-7 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. 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.
Swallowed exception (empty catch) baml_language/sdk_tests/crates/csharp/dynamic_values/Program.cs:333— An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
Swallowed exception (empty catch) baml_language/sdks/csharp/bridge_csharp/src/Cffi/HostValueRegistry.cs:559— An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
Swallowed exception (empty catch) baml_language/sdks/csharp/bridge_csharp/src/Cffi/NativeCallbacks.cs:133— An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
Swallowed exception (empty catch) baml_language/sdks/csharp/bridge_csharp/src/Cffi/NativeCallbacks.cs:270— An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
Swallowed exception (empty catch) baml_language/sdks/csharp/bridge_csharp/src/Values/BamlStream.cs:327— An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
Swallowed exception (empty catch) baml_language/sdks/csharp/bridge_csharp/src/Values/BamlStream.cs:342— An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
Swallowed exception (empty catch) baml_language/sdks/csharp/bridge_csharp/src/Values/BamlStream.cs:545— An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
Swallowed exception (empty catch) baml_language/sdks/csharp/bridge_csharp/src/Values/BamlStream.cs:580— An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
Swallowed exception (empty catch) baml_language/sdks/csharp/bridge_csharp/tools/Baml.Union.LayoutProbe/Program.cs:116— An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
No assertions: marks contexts entered by dynamic rules as dynamic typescript2/pkg-grammar/tests/kde-syntax.test.ts:272— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: renders loading state or ExecutionPanel typescript2/app-vscode-webview/src/App.browser.test.tsx:7— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: renders loading state or ExecutionPanel typescript2/app-vscode-webview/src/App.test.tsx:7— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: should derive selectedFunctionObjectAtom from function name typescript/packages/playground-common/src/sdk/__tests__/selection-integration.test.ts:329— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: (unnamed test) typescript/packages/codemirror-lang-baml/test/test.cjs:21— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: (unnamed test) typescript/packages/codemirror-lang-baml/test/test.js:21— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: supports tracing sync integ-tests/typescript/tests/tracing.test.ts:16— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: should support system_instructions in Gemini integ-tests/typescript/tests/providers/gemini.test.ts:23— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
sdkgen_rust::translate_ty::translate_inner (cognitive 72) baml_language/sdks/rust/sdkgen_rust/src/translate_ty.rs:94— sdkgen_rust::translate_ty::translate_inner has cognitive complexity 72 (threshold 15). Drivers by points: if/else 24 (46 pts), match/switch 7 (14 pts), boolean chains 6, loops 2 (6 pts) (nesting depth added 33). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
sdkgen_rust::analyze::analyze (cognitive 61) baml_language/sdks/rust/sdkgen_rust/src/analyze.rs:91— sdkgen_rust::analyze::analyze has cognitive complexity 61 (threshold 15). Drivers by points: if/else 14 (32 pts), loops 13 (19 pts), match/switch 3 (6 pts), boolean chains 4 (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.
sdkgen_rust::analyze::compute_sccs (cognitive 50) baml_language/sdks/rust/sdkgen_rust/src/analyze.rs:573— sdkgen_rust::analyze::compute_sccs has cognitive complexity 50 (threshold 15). Drivers by points: if/else 9 (30 pts), loops 5 (15 pts), match/switch 1 (4 pts), boolean chains 1 (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.
sdkgen_rust::to_source_code_with_optional_metadata (cognitive 37) baml_language/sdks/rust/sdkgen_rust/src/lib.rs:161— sdkgen_rust::to_source_code_with_optional_metadata has cognitive complexity 37 (threshold 15). Drivers by points: if/else 9 (15 pts), match/switch 5 (13 pts), loops 7 (8 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.
sdkgen_rust::unions::collect (cognitive 32) baml_language/sdks/rust/sdkgen_rust/src/unions.rs:101— sdkgen_rust::unions::collect has cognitive complexity 32 (threshold 15). Drivers by points: if/else 5 (16 pts), loops 7 (14 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.
sdkgen_rust::emit::function::emit_binding (cognitive 31) baml_language/sdks/rust/sdkgen_rust/src/emit/function.rs:82— sdkgen_rust::emit::function::emit_binding has cognitive complexity 31 (threshold 15). Drivers by points: if/else 21 (25 pts), match/switch 3, loops 2, boolean chains 1 (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
sdkgen_rust::emit::class::emit (cognitive 19) baml_language/sdks/rust/sdkgen_rust/src/emit/class.rs:27— sdkgen_rust::emit::class::emit has cognitive complexity 19 (threshold 15). Drivers by points: if/else 8, match/switch 2 (5 pts), loops 3 (4 pts), boolean chains 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.
sdkgen_rust::analyze::field_deps (cognitive 16) baml_language/sdks/rust/sdkgen_rust/src/analyze.rs:380— sdkgen_rust::analyze::field_deps has cognitive complexity 16 (threshold 15). Drivers by points: if/else 3 (6 pts), loops 2 (5 pts), match/switch 3 (5 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.
baml_lsp_server::playground_server::handle_ws_in_message (cognitive 60) baml_language/crates/baml_lsp_server/src/playground_server.rs:1735— baml_lsp_server::playground_server::handle_ws_in_message has cognitive complexity 60 (threshold 15). Drivers by points: match/switch 19 (38 pts), if/else 8 (16 pts), boolean chains 3, loops 1 (3 pts) (nesting depth added 29). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own 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.
baml_lsp_server::playground_server::playground_ws_session (cognitive 30) baml_language/crates/baml_lsp_server/src/playground_server.rs:1375— baml_lsp_server::playground_server::playground_ws_session has cognitive complexity 30 (threshold 15). Drivers by points: if/else 9 (14 pts), match/switch 4 (12 pts), boolean chains 3, loops 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
baml_lsp_server::playground_server::lsp_ws_session (cognitive 29) baml_language/crates/baml_lsp_server/src/playground_server.rs:889— baml_lsp_server::playground_server::lsp_ws_session has cognitive complexity 29 (threshold 15). Drivers by points: match/switch 6 (13 pts), if/else 4 (12 pts), boolean chains 3, loops 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.
baml_lsp_server::read_lsp_message (cognitive 25) baml_language/crates/baml_lsp_server/src/lib.rs:270— baml_lsp_server::read_lsp_message has cognitive complexity 25 (threshold 15). Drivers by points: if/else 12 (24 pts), loops 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.
baml_lsp_server::run_stdio_loop (cognitive 22) baml_language/crates/baml_lsp_server/src/lib.rs:793— baml_lsp_server::run_stdio_loop has cognitive complexity 22 (threshold 15). Drivers by points: if/else 4 (8 pts), match/switch 3 (8 pts), loops 3 (4 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.
baml_lsp_server::playground_server::spawn_disk_watcher (cognitive 22) baml_language/crates/baml_lsp_server/src/playground_server.rs:1222— baml_lsp_server::playground_server::spawn_disk_watcher has cognitive complexity 22 (threshold 15). Drivers by points: if/else 8 (15 pts), match/switch 3 (5 pts), 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.
baml_lsp_server::decode_lsp_message (cognitive 17) baml_language/crates/baml_lsp_server/src/lib.rs:232— baml_lsp_server::decode_lsp_message has cognitive complexity 17 (threshold 15). Drivers by points: if/else 9 (14 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.
baml_lsp_server::playground_server::drain_logs_and_broadcast (cognitive 16) baml_language/crates/baml_lsp_server/src/playground_server.rs:476— baml_lsp_server::playground_server::drain_logs_and_broadcast has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (8 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.
cargo_size_gate::output::render_aggregate_markdown (cognitive 53) baml_language/crates/tools_size_gate/src/output.rs:628— cargo_size_gate::output::render_aggregate_markdown has cognitive complexity 53 (threshold 15). Drivers by points: if/else 19 (28 pts), loops 7 (21 pts), boolean chains 2, match/switch 1 (2 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.
cargo_size_gate::compare::check_policy (cognitive 28) baml_language/crates/tools_size_gate/src/compare.rs:19— cargo_size_gate::compare::check_policy has cognitive complexity 28 (threshold 15). Drivers by points: if/else 13 (27 pts), match/switch 1 (nesting depth added 14). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
cargo_size_gate::output::print_fix_hint (cognitive 27) baml_language/crates/tools_size_gate/src/output.rs:477— cargo_size_gate::output::print_fix_hint has cognitive complexity 27 (threshold 15). Drivers by points: loops 7 (18 pts), if/else 5 (8 pts), boolean chains 1 (nesting depth added 14). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
cargo_size_gate::measure::resolve_lib_name (cognitive 22) baml_language/crates/tools_size_gate/src/measure.rs:235— cargo_size_gate::measure::resolve_lib_name has cognitive complexity 22 (threshold 15). Drivers by points: if/else 5 (17 pts), loops 2 (5 pts) (nesting depth added 15). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
cargo_size_gate::output::render_markdown (cognitive 21) baml_language/crates/tools_size_gate/src/output.rs:106— cargo_size_gate::output::render_markdown has cognitive complexity 21 (threshold 15). Drivers by points: loops 4 (11 pts), if/else 5 (10 pts) (nesting depth added 12). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline. This shape REPEATS in the file: one other method here (cargo_size_gate::output::render_markdown_fragment) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
cargo_size_gate::output::render_markdown_fragment (cognitive 21) baml_language/crates/tools_size_gate/src/output.rs:177— cargo_size_gate::output::render_markdown_fragment has cognitive complexity 21 (threshold 15). Drivers by points: loops 4 (11 pts), if/else 5 (10 pts) (nesting depth added 12). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline. This shape REPEATS in the file: one other method here (cargo_size_gate::output::render_markdown) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
cargo_size_gate::cmd_bake (cognitive 19) baml_language/crates/tools_size_gate/src/main.rs:382— cargo_size_gate::cmd_bake has cognitive complexity 19 (threshold 15). Drivers by points: if/else 8 (10 pts), loops 4 (6 pts), match/switch 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.
cargo_size_gate::output::print_fix_hint_md (cognitive 17) baml_language/crates/tools_size_gate/src/output.rs:560— cargo_size_gate::output::print_fix_hint_md has cognitive complexity 17 (threshold 15). Drivers by points: loops 4 (10 pts), if/else 4 (7 pts) (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.
baml_compiler2_rust::admit::recursive_functions (cognitive 35) baml_language/crates/baml_compiler2_rust/src/admit.rs:468— baml_compiler2_rust::admit::recursive_functions has cognitive complexity 35 (threshold 15). Drivers by points: if/else 8 (21 pts), loops 7 (12 pts), boolean chains 2 (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.
baml_compiler2_rust::admit::lower_program (cognitive 29) baml_language/crates/baml_compiler2_rust/src/admit.rs:153— baml_compiler2_rust::admit::lower_program has cognitive complexity 29 (threshold 15). Drivers by points: if/else 6 (18 pts), match/switch 2 (6 pts), loops 3 (5 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.
baml_compiler2_rust::analysis::type_locals (cognitive 28) baml_language/crates/baml_compiler2_rust/src/analysis.rs:218— baml_compiler2_rust::analysis::type_locals has cognitive complexity 28 (threshold 15). Drivers by points: if/else 7 (16 pts), match/switch 2 (9 pts), loops 2 (3 pts) (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
baml_compiler2_rust::init::generate (cognitive 23) baml_language/crates/baml_compiler2_rust/src/init.rs:61— baml_compiler2_rust::init::generate has cognitive complexity 23 (threshold 15). Drivers by points: if/else 12 (17 pts), boolean chains 3, match/switch 1 (2 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.
baml_compiler2_rust::admit::compile_program (cognitive 20) baml_language/crates/baml_compiler2_rust/src/admit.rs:96— baml_compiler2_rust::admit::compile_program has cognitive complexity 20 (threshold 15). Drivers by points: if/else 3 (10 pts), loops 3 (9 pts), boolean chains 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
baml_compiler2_rust::admit::admission_fixpoint (cognitive 18) baml_language/crates/baml_compiler2_rust/src/admit.rs:273— baml_compiler2_rust::admit::admission_fixpoint has cognitive complexity 18 (threshold 15). Drivers by points: loops 4 (7 pts), if/else 2 (6 pts), match/switch 1 (3 pts), boolean chains 2 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
baml_compiler2_rust::analysis::value_reprs (cognitive 18) baml_language/crates/baml_compiler2_rust/src/analysis.rs:428— baml_compiler2_rust::analysis::value_reprs has cognitive complexity 18 (threshold 15). Drivers by points: if/else 3 (10 pts), loops 3 (6 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.
baml_compiler2_rust::analysis::read_only_after_load (cognitive 16) baml_language/crates/baml_compiler2_rust/src/analysis.rs:361— baml_compiler2_rust::analysis::read_only_after_load has cognitive complexity 16 (threshold 15). Drivers by points: boolean chains 5, if/else 2 (5 pts), loops 2 (3 pts), match/switch 1 (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.
Duplicated block (23 lines × 2) baml_language/crates/baml_ide/src/cursor_context.rs:143— baml_language/crates/baml_ide/src/cursor_context.rs:143-165 | baml_language/crates/baml_ide/src/cursor_context.rs:231-253 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (23 lines × 2) baml_language/crates/baml_type/src/template.rs:254— baml_language/crates/baml_type/src/template.rs:254-276 | baml_language/crates/baml_type/src/template.rs:321-343 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (23 lines × 2) baml_language/crates/bex_events/src/history/mod.rs:722— baml_language/crates/bex_events/src/history/mod.rs:722-744 | baml_language/crates/bex_events/src/run.rs:1621-1643 — 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 (23 lines × 2) baml_language/crates/bex_sap/src/deserializer/coercer/match_string.rs:296— baml_language/crates/bex_sap/src/deserializer/coercer/match_string.rs:296-318 | engine/baml-lib/jsonish/src/deserializer/coercer/match_string.rs:267-289 — before extracting anything, compare `baml_language/crates/bex_sap/src/deserializer/coercer/match_string.rs` and `engine/baml-lib/jsonish/src/deserializer/coercer/match_string.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 52 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, 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 (23 lines × 2) baml_language/crates/bex_vm/src/vm.rs:10667— baml_language/crates/bex_vm/src/vm.rs:10667-10689 | baml_language/crates/bex_vm/src/vm/compiled_rt/frame.rs:439-461 — 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 (23 lines × 2) baml_language/sdks/python/rust/sdkgen_python_pydantic2/src/emit/mod.rs:204— baml_language/sdks/python/rust/sdkgen_python_pydantic2/src/emit/mod.rs:204-226 | baml_language/sdks/python/rust/sdkgen_python_pydantic2/src/emit/mod.rs:315-337 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (23 lines × 2) engine/generators/languages/go/src/ir_to_go/mod.rs:114— engine/generators/languages/go/src/ir_to_go/mod.rs:114-136 | engine/generators/languages/go/src/ir_to_go/mod.rs:145-167 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (23 lines × 2) engine/generators/languages/rust/src/ir_to_rust/mod.rs:132— engine/generators/languages/rust/src/ir_to_rust/mod.rs:132-154 | engine/generators/languages/rust/src/ir_to_rust/mod.rs:163-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.
Duplicated block (11 lines × 3) baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs:805— baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs:805-815 | baml_language/crates/baml_type/src/unify.rs:390-400 | baml_language/crates/baml_type_runtime/src/lib.rs:770-780 — before extracting anything, compare `baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs` and `baml_language/crates/baml_type/src/unify.rs` as WHOLE FILES: this scan already matched 21 separate duplicated blocks between them, totalling at least 418 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (11 lines × 3) baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:6970— baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:6970-6980 | baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:7010-7020 | baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:7051-7061 — 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) baml_language/crates/baml_compiler2_mir/src/lower.rs:6732— baml_language/crates/baml_compiler2_mir/src/lower.rs:6732-6742 | baml_language/crates/baml_compiler2_mir/src/lower.rs:6986-6996 | baml_language/crates/baml_compiler2_mir/src/lower.rs:10478-10488 — 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) engine/baml-compiler/src/thir.rs:226— engine/baml-compiler/src/thir.rs:226-236 | engine/baml-compiler/src/thir.rs:247-257 | engine/baml-compiler/src/thir.rs:271-281 — 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) engine/baml-lib/jsonish/src/deserializer/coercer/coerce_union.rs:96— engine/baml-lib/jsonish/src/deserializer/coercer/coerce_union.rs:96-106 | engine/baml-lib/jsonish/src/deserializer/coercer/ir_ref/coerce_alias.rs:35-45 | engine/baml-lib/jsonish/src/deserializer/coercer/ir_ref/coerce_enum.rs:60-70 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times.
Duplicated block (11 lines × 3) baml_language/crates/baml_base/src/qualified_name.rs:334— baml_language/crates/baml_base/src/qualified_name.rs:334-344 | baml_language/crates/baml_base/src/qualified_name.rs:348-358 | baml_language/crates/baml_base/src/qualified_name.rs:375-387 — 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) engine/baml-runtime/src/optimize/tui.rs:641— engine/baml-runtime/src/optimize/tui.rs:641-651 | engine/baml-runtime/src/optimize/tui.rs:1042-1052 | engine/baml-runtime/src/optimize/tui.rs:1188-1198 — 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) baml_language/sdk_tests/crates/csharp/generics/Program.cs:162— baml_language/sdk_tests/crates/csharp/generics/Program.cs:162-172 | baml_language/sdk_tests/crates/csharp/primitive_edges/Program.cs:163-173 | baml_language/sdk_tests/crates/csharp/type_roundtrips/Program.cs:149-159 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
Duplicated block (9 lines × 3) engine/baml-lib/baml-types/src/expr.rs:170— engine/baml-lib/baml-types/src/expr.rs:170-178 | engine/baml-lib/baml-types/src/expr.rs:193-201 | engine/baml-lib/baml-types/src/expr.rs:216-224 — 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) engine/cli/src/commands.rs:149— engine/cli/src/commands.rs:149-157 | engine/cli/src/commands.rs:159-167 | engine/cli/src/commands.rs:186-194 — 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) baml_language/crates/baml_compiler2_visualization/src/control_flow/from_ast.rs:111— baml_language/crates/baml_compiler2_visualization/src/control_flow/from_ast.rs:111-119 | engine/baml-compiler/src/viz_builder.rs:161-169 | engine/baml-runtime/src/control_flow.rs:422-430 — before extracting anything, compare `baml_language/crates/baml_compiler2_visualization/src/control_flow/from_ast.rs` and `engine/baml-runtime/src/control_flow.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 69 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (9 lines × 3) engine/generators/languages/go/src/package.rs:24— engine/generators/languages/go/src/package.rs:24-32 | engine/generators/languages/python/src/package.rs:38-46 | engine/generators/languages/typescript/src/package.rs:24-32 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times.
Duplicated block (9 lines × 3) engine/baml_cffi_macros/src/lib.rs:657— engine/baml_cffi_macros/src/lib.rs:657-665 | engine/baml_cffi_macros/src/lib.rs:739-747 | engine/baml_cffi_macros/src/lib.rs:955-967 — 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) baml_language/crates/baml_compiler2_ast/src/lower_cst.rs:1682— baml_language/crates/baml_compiler2_ast/src/lower_cst.rs:1682-1690 | baml_language/crates/baml_compiler2_ast/src/lower_cst.rs:1750-1759 | baml_language/crates/baml_compiler2_ast/src/lower_cst.rs:1763-1771 — 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) engine/baml-runtime/src/internal/llm_client/primitive/anthropic/anthropic_client.rs:466— engine/baml-runtime/src/internal/llm_client/primitive/anthropic/anthropic_client.rs:466-475 | engine/baml-runtime/src/internal/llm_client/primitive/google/googleai_client.rs:339-347 | engine/baml-runtime/src/internal/llm_client/primitive/vertex/vertex_client.rs:546-554 — before extracting anything, compare `engine/baml-runtime/src/internal/llm_client/primitive/anthropic/anthropic_client.rs` and `engine/baml-runtime/src/internal/llm_client/primitive/google/googleai_client.rs` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 79 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (9 lines × 3) baml_language/crates/baml_fmt/src/ast/expressions.rs:4103— baml_language/crates/baml_fmt/src/ast/expressions.rs:4103-4111 | baml_language/crates/baml_fmt/src/ast/expressions.rs:4352-4360 | baml_language/crates/baml_fmt/src/ast/types.rs:515-523 — before extracting anything, compare `baml_language/crates/baml_fmt/src/ast/expressions.rs` and `baml_language/crates/baml_fmt/src/ast/types.rs` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 89 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the 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 (8–9 lines × 2) baml_language/crates/baml_cli/src/run_command.rs:799— baml_language/crates/baml_cli/src/run_command.rs:799-806 | baml_language/crates/baml_cli/src/run_command.rs:827-835 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler2_hir_ty/src/interfaces/impl_rules.rs:1203— baml_language/crates/baml_compiler2_hir_ty/src/interfaces/impl_rules.rs:1203-1210 | baml_language/crates/baml_compiler2_hir_ty/src/interfaces/impl_rules.rs:1601-1609 — both copies are in the same file, so extract the block into 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) baml_language/crates/bex_sap/src/deserializer/score.rs:35— baml_language/crates/bex_sap/src/deserializer/score.rs:35-43 | engine/baml-lib/jsonish/src/deserializer/score.rs:54-61 — 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–9 lines × 2) baml_language/crates/bex_sap/src/jsonish/parser/entry.rs:113— baml_language/crates/bex_sap/src/jsonish/parser/entry.rs:113-120 | engine/baml-lib/jsonish/src/jsonish/parser/entry.rs:121-129 — before extracting anything, compare `baml_language/crates/bex_sap/src/jsonish/parser/entry.rs` and `engine/baml-lib/jsonish/src/jsonish/parser/entry.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 55 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, 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–9 lines × 2) baml_language/crates/bex_vm/src/reachable.rs:63— baml_language/crates/bex_vm/src/reachable.rs:63-71 | baml_language/crates/bex_vm/src/reachable.rs:135-142 — both copies are in the same file, so extract the block into 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) baml_language/sdks/java/sdkgen_java/src/lib.rs:170— baml_language/sdks/java/sdkgen_java/src/lib.rs:170-177 | baml_language/sdks/java/sdkgen_java/src/lib.rs:594-602 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (8–9 lines × 2) engine/baml-lib/parser-database/src/names/mod.rs:45— engine/baml-lib/parser-database/src/names/mod.rs:45-52 | engine/baml-lib/parser-database/src/names/mod.rs:66-74 — both copies are in the same file, so extract the block into 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) engine/baml-schema-wasm/src/runtime_wasm/mod.rs:1689— engine/baml-schema-wasm/src/runtime_wasm/mod.rs:1689-1697 | engine/baml-schema-wasm/src/runtime_wasm/mod.rs:1710-1717 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
sdkgen_rust::translate_ty::translate_inner (cyclomatic 61) baml_language/sdks/rust/sdkgen_rust/src/translate_ty.rs:94— sdkgen_rust::translate_ty::translate_inner has cyclomatic complexity 61 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
sdkgen_rust::analyze::analyze (cyclomatic 36) baml_language/sdks/rust/sdkgen_rust/src/analyze.rs:91— sdkgen_rust::analyze::analyze 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.
sdkgen_rust::analyze::field_deps (cyclomatic 26) baml_language/sdks/rust/sdkgen_rust/src/analyze.rs:380— sdkgen_rust::analyze::field_deps has cyclomatic complexity 26 (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.
sdkgen_rust::to_source_code_with_optional_metadata (cyclomatic 23) baml_language/sdks/rust/sdkgen_rust/src/lib.rs:161— sdkgen_rust::to_source_code_with_optional_metadata has cyclomatic complexity 23 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
sdkgen_rust::emit::function::emit_binding (cyclomatic 20) baml_language/sdks/rust/sdkgen_rust/src/emit/function.rs:82— sdkgen_rust::emit::function::emit_binding 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.
sdkgen_rust::analyze::compute_sccs (cyclomatic 17) baml_language/sdks/rust/sdkgen_rust/src/analyze.rs:573— sdkgen_rust::analyze::compute_sccs 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.
sdkgen_rust::unions::collect (cyclomatic 16) baml_language/sdks/rust/sdkgen_rust/src/unions.rs:101— sdkgen_rust::unions::collect has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This is NOT this file's highest cyclomatic complexity: sdkgen_rust::unions::variant_name (cyclomatic 17) 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.
Expression::repr (cyclomatic 45) engine/baml-lib/baml-core/src/ir/repr.rs:349— Expression::repr has cyclomatic complexity 45 (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.
Expression::assert_eq_up_to_span (cyclomatic 43) engine/baml-lib/ast/src/ast/expression.rs:507— Expression::assert_eq_up_to_span has cyclomatic complexity 43 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
Expression::from_ast (cyclomatic 41) engine/baml-compiler/src/hir/lowering.rs:743— Expression::from_ast 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.
Expression::single_line_width (cyclomatic 34) baml_language/crates/baml_fmt/src/ast/expressions.rs:243— Expression::single_line_width 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. This is NOT this file's highest cyclomatic complexity: Expression::from_cst (cyclomatic 38) 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.
Expression::to_unresolved_value (cyclomatic 27) engine/baml-lib/ast/src/ast/expression.rs:647— Expression::to_unresolved_value 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.
Expression::fmt (cyclomatic 25) engine/baml-lib/ast/src/ast/expression.rs:235— Expression::fmt 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.
Expression::to_doc (cyclomatic 24) engine/baml-compiler/src/hir/dump.rs:423— Expression::to_doc 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.
jsonish::deserializer::coercer::array_helper::pick_best (cyclomatic 42) engine/baml-lib/jsonish/src/deserializer/coercer/array_helper.rs:29— jsonish::deserializer::coercer::array_helper::pick_best has cyclomatic complexity 42 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
jsonish::helpers::relevant_data_models (cyclomatic 36) engine/baml-lib/jsonish/src/helpers/mod.rs:127— jsonish::helpers::relevant_data_models 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.
jsonish::jsonish::parser::entry::parse_func (cyclomatic 31) engine/baml-lib/jsonish/src/jsonish/parser/entry.rs:15— jsonish::jsonish::parser::entry::parse_func has cyclomatic complexity 31 (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.
jsonish::deserializer::coercer::match_string::string_match_strategy (cyclomatic 21) engine/baml-lib/jsonish/src/deserializer/coercer/match_string.rs:192— jsonish::deserializer::coercer::match_string::string_match_strategy has cyclomatic complexity 21 (threshold 15). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
jsonish::deserializer::semantic_streaming::process_node (cyclomatic 21) engine/baml-lib/jsonish/src/deserializer/semantic_streaming.rs:65— jsonish::deserializer::semantic_streaming::process_node 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.
jsonish::deserializer::semantic_streaming::required_done (cyclomatic 20) engine/baml-lib/jsonish/src/deserializer/semantic_streaming.rs:299— jsonish::deserializer::semantic_streaming::required_done has cyclomatic complexity 20 (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.
jsonish::deserializer::coercer::coerce_union::try_cast_union (cyclomatic 18) engine/baml-lib/jsonish/src/deserializer/coercer/coerce_union.rs:10— jsonish::deserializer::coercer::coerce_union::try_cast_union 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.
internal_baml_ast::parser::parse_value_expression_block::parse_value_expression_block (cyclomatic 41) engine/baml-lib/ast/src/parser/parse_value_expression_block.rs:15— internal_baml_ast::parser::parse_value_expression_block::parse_value_expression_block 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.
internal_baml_ast::parser::parse_expression::parse_expression (cyclomatic 30) engine/baml-lib/ast/src/parser/parse_expression.rs:18— internal_baml_ast::parser::parse_expression::parse_expression has cyclomatic complexity 30 (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.
internal_baml_ast::parser::parse::parse (cyclomatic 29) engine/baml-lib/ast/src/parser/parse.rs:56— internal_baml_ast::parser::parse::parse has cyclomatic complexity 29 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
internal_baml_ast::parser::parse_type_expression_block::parse_type_expression_block (cyclomatic 28) engine/baml-lib/ast/src/parser/parse_type_expression_block.rs:16— internal_baml_ast::parser::parse_type_expression_block::parse_type_expression_block 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.
internal_baml_ast::parser::parse_expr::parse_expr_block (cyclomatic 26) engine/baml-lib/ast/src/parser/parse_expr.rs:731— internal_baml_ast::parser::parse_expr::parse_expr_block 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.
internal_baml_ast::parser::parse_expr::parse_statement_inner_rule (cyclomatic 22) engine/baml-lib/ast/src/parser/parse_expr.rs:478— internal_baml_ast::parser::parse_expr::parse_statement_inner_rule has cyclomatic complexity 22 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
internal_baml_ast::parser::parse_named_args_list::parse_named_argument_list (cyclomatic 17) engine/baml-lib/ast/src/parser/parse_named_args_list.rs:14— internal_baml_ast::parser::parse_named_args_list::parse_named_argument_list 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.
sdkgen_csharp::semantic::generate_program_inner (cyclomatic 36) baml_language/sdks/csharp/sdkgen_csharp/src/semantic.rs:379— sdkgen_csharp::semantic::generate_program_inner has cyclomatic complexity 36 (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.
sdkgen_csharp::semantic::encode_type_metadata (cyclomatic 36) baml_language/sdks/csharp/sdkgen_csharp/src/semantic.rs:4402— sdkgen_csharp::semantic::encode_type_metadata 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.
sdkgen_csharp::semantic::require_supported_type_inner (cyclomatic 32) baml_language/sdks/csharp/sdkgen_csharp/src/semantic.rs:1766— sdkgen_csharp::semantic::require_supported_type_inner has cyclomatic complexity 32 (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.
sdkgen_csharp::semantic::render_program (cyclomatic 30) baml_language/sdks/csharp/sdkgen_csharp/src/semantic.rs:3218— sdkgen_csharp::semantic::render_program has cyclomatic complexity 30 (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.
sdkgen_csharp::semantic::collect_type_closure (cyclomatic 24) baml_language/sdks/csharp/sdkgen_csharp/src/semantic.rs:2240— sdkgen_csharp::semantic::collect_type_closure 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.
sdkgen_csharp::semantic::collect_methods (cyclomatic 20) baml_language/sdks/csharp/sdkgen_csharp/src/semantic.rs:1230— sdkgen_csharp::semantic::collect_methods 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. This is NOT this file's highest cyclomatic complexity: sdkgen_csharp::semantic::render_codec (cyclomatic 24) 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.
sdkgen_csharp::semantic::collect_functions (cyclomatic 16) baml_language/sdks/csharp/sdkgen_csharp/src/semantic.rs:1563— sdkgen_csharp::semantic::collect_functions has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This is NOT this file's highest cyclomatic complexity: sdkgen_csharp::semantic::render_codec (cyclomatic 24) 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.
baml_builtins2_codegen::codegen::receiver_input_type_with_vm_usage (cyclomatic 28) baml_language/crates/baml_builtins2_codegen/src/codegen.rs:2160— baml_builtins2_codegen::codegen::receiver_input_type_with_vm_usage 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.
baml_builtins2_codegen::extract::type_expr_to_baml_type (cyclomatic 27) baml_language/crates/baml_builtins2_codegen/src/extract.rs:980— baml_builtins2_codegen::extract::type_expr_to_baml_type has cyclomatic complexity 27 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
baml_builtins2_codegen::codegen::extraction_expr (cyclomatic 23) baml_language/crates/baml_builtins2_codegen/src/codegen.rs:1585— baml_builtins2_codegen::codegen::extraction_expr 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.
baml_builtins2_codegen::codegen::baml_type_to_input (cyclomatic 18) baml_language/crates/baml_builtins2_codegen/src/codegen.rs:2060— baml_builtins2_codegen::codegen::baml_type_to_input 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.
baml_builtins2_codegen::codegen_io::emit_result_conversion_for_ty (cyclomatic 18) baml_language/crates/baml_builtins2_codegen/src/codegen_io.rs:2712— baml_builtins2_codegen::codegen_io::emit_result_conversion_for_ty 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.
baml_builtins2_codegen::codegen::call_arg_for_type (cyclomatic 16) baml_language/crates/baml_builtins2_codegen/src/codegen.rs:1761— baml_builtins2_codegen::codegen::call_arg_for_type 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.
baml_builtins2_codegen::extract::extract_scoped (cyclomatic 16) baml_language/crates/baml_builtins2_codegen/src/extract.rs:114— baml_builtins2_codegen::extract::extract_scoped 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.
sdkgen_cpp::to_source_code_with_optional_metadata (cognitive 98) baml_language/sdks/cpp/sdkgen_cpp/src/lib.rs:68— sdkgen_cpp::to_source_code_with_optional_metadata has cognitive complexity 98 (threshold 15). Drivers by points: if/else 21 (52 pts), loops 14 (28 pts), match/switch 6 (16 pts), boolean chains 2 (nesting depth added 55). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
sdkgen_cpp::translate_ty (cognitive 70) baml_language/sdks/cpp/sdkgen_cpp/src/lib.rs:1507— sdkgen_cpp::translate_ty has cognitive complexity 70 (threshold 15). Drivers by points: if/else 23 (45 pts), match/switch 9 (18 pts), boolean chains 5, loops 1 (2 pts) (nesting depth added 32). 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.
sdkgen_cpp::render_header (cognitive 38) baml_language/sdks/cpp/sdkgen_cpp/src/lib.rs:2009— sdkgen_cpp::render_header has cognitive complexity 38 (threshold 15). Drivers by points: loops 13 (27 pts), if/else 5 (8 pts), match/switch 2 (3 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.
sdkgen_cpp::collect_requests (cognitive 28) baml_language/sdks/cpp/sdkgen_cpp/src/lib.rs:546— sdkgen_cpp::collect_requests has cognitive complexity 28 (threshold 15). Drivers by points: if/else 6 (16 pts), loops 4 (10 pts), match/switch 1 (2 pts) (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
sdkgen_cpp::emit_callable (cognitive 28) baml_language/sdks/cpp/sdkgen_cpp/src/lib.rs:1185— sdkgen_cpp::emit_callable has cognitive complexity 28 (threshold 15). Drivers by points: if/else 11 (16 pts), match/switch 6 (11 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.
sdkgen_cpp::render_bindings (cognitive 26) baml_language/sdks/cpp/sdkgen_cpp/src/lib.rs:2409— sdkgen_cpp::render_bindings has cognitive complexity 26 (threshold 15). Drivers by points: loops 7 (16 pts), if/else 4 (9 pts), boolean chains 1 (nesting depth added 14). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
sdkgen_cpp::render_codecs (cognitive 23) baml_language/sdks/cpp/sdkgen_cpp/src/lib.rs:2232— sdkgen_cpp::render_codecs has cognitive complexity 23 (threshold 15). Drivers by points: loops 8 (14 pts), if/else 5 (9 pts) (nesting depth added 10). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
sdkgen_python_pydantic2::leaf::render_leaf_body_pyi (cognitive 74) baml_language/sdks/python/rust/sdkgen_python_pydantic2/src/leaf.rs:2574— sdkgen_python_pydantic2::leaf::render_leaf_body_pyi has cognitive complexity 74 (threshold 15). Drivers by points: if/else 27 (41 pts), loops 10 (17 pts), boolean chains 12, match/switch 2 (4 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.
sdkgen_python_pydantic2::leaf::render_leaf_body (cognitive 56) baml_language/sdks/python/rust/sdkgen_python_pydantic2/src/leaf.rs:1671— sdkgen_python_pydantic2::leaf::render_leaf_body has cognitive complexity 56 (threshold 15). Drivers by points: if/else 23 (29 pts), loops 9 (18 pts), boolean chains 7, match/switch 1 (2 pts) (nesting depth added 16). 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.
sdkgen_python_pydantic2::translate_ty::translate_ty (cognitive 28) baml_language/sdks/python/rust/sdkgen_python_pydantic2/src/translate_ty.rs:67— sdkgen_python_pydantic2::translate_ty::translate_ty has cognitive complexity 28 (threshold 15). Drivers by points: if/else 13 (25 pts), boolean chains 2, match/switch 1 (nesting depth added 12). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
sdkgen_python_pydantic2::leaf::split_hoistable_aliases (cognitive 27) baml_language/sdks/python/rust/sdkgen_python_pydantic2/src/leaf.rs:864— sdkgen_python_pydantic2::leaf::split_hoistable_aliases has cognitive complexity 27 (threshold 15). Drivers by points: if/else 8 (18 pts), loops 5 (7 pts), boolean chains 1, match/switch 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.
sdkgen_python_pydantic2::utils::format_class_docstring (cognitive 27) baml_language/sdks/python/rust/sdkgen_python_pydantic2/src/utils.rs:73— sdkgen_python_pydantic2::utils::format_class_docstring has cognitive complexity 27 (threshold 15). Drivers by points: if/else 8 (13 pts), loops 3 (9 pts), match/switch 1 (3 pts), boolean chains 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.
sdkgen_python_pydantic2::to_source_code_internal (cognitive 24) baml_language/sdks/python/rust/sdkgen_python_pydantic2/src/lib.rs:241— sdkgen_python_pydantic2::to_source_code_internal has cognitive complexity 24 (threshold 15). Drivers by points: if/else 9 (16 pts), loops 6 (7 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.
sdkgen_python_pydantic2::render_function_registry (cognitive 23) baml_language/sdks/python/rust/sdkgen_python_pydantic2/src/lib.rs:457— sdkgen_python_pydantic2::render_function_registry has cognitive complexity 23 (threshold 15). Drivers by points: if/else 5 (11 pts), loops 5 (10 pts), boolean chains 1, 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.
internal_baml_jinja_types::evaluate_type::expr::tracker_visit_expr (cognitive 74) engine/baml-lib/jinja/src/evaluate_type/expr.rs:318— internal_baml_jinja_types::evaluate_type::expr::tracker_visit_expr has cognitive complexity 74 (threshold 15). Drivers by points: if/else 14 (36 pts), match/switch 12 (32 pts), loops 1 (5 pts), boolean chains 1 (nesting depth added 46). 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.
internal_baml_jinja_types::evaluate_type::expr::handle_enum_binary_operation (cognitive 46) engine/baml-lib/jinja/src/evaluate_type/expr.rs:134— internal_baml_jinja_types::evaluate_type::expr::handle_enum_binary_operation has cognitive complexity 46 (threshold 15). Drivers by points: if/else 19 (39 pts), match/switch 4 (7 pts) (nesting depth added 23). 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.
internal_baml_jinja_types::evaluate_type::stmt::narrow_attr_access_on_union_var (cognitive 40) engine/baml-lib/jinja/src/evaluate_type/stmt.rs:325— internal_baml_jinja_types::evaluate_type::stmt::narrow_attr_access_on_union_var has cognitive complexity 40 (threshold 15). Drivers by points: if/else 9 (28 pts), match/switch 5 (11 pts), loops 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.
internal_baml_jinja_types::evaluate_type::stmt::track_walk (cognitive 39) engine/baml-lib/jinja/src/evaluate_type/stmt.rs:7— internal_baml_jinja_types::evaluate_type::stmt::track_walk has cognitive complexity 39 (threshold 15). Drivers by points: if/else 8 (24 pts), match/switch 7 (15 pts) (nesting depth added 24). 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.
internal_baml_jinja_types::evaluate_type::stmt::predicate_implications (cognitive 36) engine/baml-lib/jinja/src/evaluate_type/stmt.rs:186— internal_baml_jinja_types::evaluate_type::stmt::predicate_implications has cognitive complexity 36 (threshold 15). Drivers by points: if/else 8 (17 pts), match/switch 5 (11 pts), loops 2 (8 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.
internal_baml_jinja_types::evaluate_type::expr::infer_const_type (cognitive 28) engine/baml-lib/jinja/src/evaluate_type/expr.rs:660— internal_baml_jinja_types::evaluate_type::expr::infer_const_type has cognitive complexity 28 (threshold 15). Drivers by points: if/else 7 (17 pts), match/switch 5 (11 pts) (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.
internal_baml_jinja_types::evaluate_type::expr::typecheck_attr_access_on_union (cognitive 20) engine/baml-lib/jinja/src/evaluate_type/expr.rs:755— internal_baml_jinja_types::evaluate_type::expr::typecheck_attr_access_on_union has cognitive complexity 20 (threshold 15). Drivers by points: match/switch 6 (10 pts), if/else 4 (9 pts), loops 1 (nesting depth added 9). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own 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.
baml_cli::describe_command::write_description (cognitive 70) baml_language/crates/baml_cli/src/describe_command.rs:662— baml_cli::describe_command::write_description has cognitive complexity 70 (threshold 15). Drivers by points: if/else 23 (42 pts), loops 8 (23 pts), match/switch 2 (4 pts), boolean chains 1 (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.
baml_cli::describe_command::write_interface_body (cognitive 29) baml_language/crates/baml_cli/src/describe_command.rs:1101— baml_cli::describe_command::write_interface_body has cognitive complexity 29 (threshold 15). Drivers by points: if/else 16 (22 pts), loops 3 (4 pts), boolean chains 3 (nesting depth added 7). Of this number, 25 points are the body's own statements and 4 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.
baml_cli::describe_command::truncate_body (cognitive 28) baml_language/crates/baml_cli/src/describe_command.rs:1671— baml_cli::describe_command::truncate_body has cognitive complexity 28 (threshold 15). Drivers by points: if/else 7 (17 pts), loops 7 (10 pts), boolean chains 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
baml_cli::colordiff::print_diff (cognitive 26) engine/cli/src/colordiff.rs:17— baml_cli::colordiff::print_diff has cognitive complexity 26 (threshold 15). Drivers by points: if/else 4 (12 pts), loops 4 (10 pts), match/switch 1 (4 pts) (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
baml_cli::generate::discover_generators (cognitive 22) baml_language/crates/baml_cli/src/generate.rs:733— baml_cli::generate::discover_generators has cognitive complexity 22 (threshold 15). Drivers by points: if/else 10 (17 pts), match/switch 1 (3 pts), boolean chains 1, 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.
baml_cli::feedback_command::sync_open_reports (cognitive 20) baml_language/crates/baml_cli/src/feedback_command.rs:693— baml_cli::feedback_command::sync_open_reports has cognitive complexity 20 (threshold 15). Drivers by points: if/else 12 (18 pts), boolean chains 1, 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.
baml_cli::describe_command::minimum_full_output_budget (cognitive 17) baml_language/crates/baml_cli/src/describe_command.rs:1343— baml_cli::describe_command::minimum_full_output_budget has cognitive complexity 17 (threshold 15). Drivers by points: loops 5 (11 pts), if/else 6 (nesting depth added 6). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
TooManyFields: InferenceContext baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:2064— TooManyFields — 52 stored fields beside 308 methods. The bar is 30 stored fields; this is 22 over it, 1.73× 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: BexEngine baml_language/crates/bex_engine/src/lib.rs:1099— TooManyFields — 46 stored fields beside 158 methods. The bar is 30 stored fields; this is 16 over it, 1.53× 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: BexVm baml_language/crates/bex_vm/src/vm.rs:1779— TooManyFields — 40 stored fields beside 416 methods. The bar is 30 stored fields; this is 10 over it, 1.33× the bar. This is width in DATA, not behaviour: every reader that takes the whole type couples to all of its fields, so a change to any one of them is a change every reader has to be checked against. To reduce it, group the fields that are read together by the same callers into a smaller type of their own, and have this one hold that type as a single member — each reader then names only the group it uses.
TooManyFields: LoweringContext baml_language/crates/baml_compiler2_mir/src/lower.rs:1711— TooManyFields — 34 stored fields beside 302 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: BamlApiV1 baml_language/crates/bridge_cffi/src/api.rs:190— TooManyFields — 34 stored fields. 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: BamlApiV1 baml_language/sdks/rust/bridge_rust/src/capi.rs:165— TooManyFields — 34 stored fields. 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: StackifyCodegen baml_language/crates/baml_compiler2_emit/src/emit.rs:213— TooManyFields — 33 stored fields beside 78 methods. The bar is 30 stored fields; this is 3 over it, 1.10× the bar. This is width in DATA, not behaviour: every reader that takes the whole type couples to all of its fields, so a change to any one of them is a change every reader has to be checked against. To reduce it, group the fields that are read together by the same callers into a smaller type of their own, and have this one hold that type as a single member — each reader then names only the group it uses.
Duplicated block (22 lines × 2) baml_language/crates/baml_compiler2_mir/src/lower.rs:4657— baml_language/crates/baml_compiler2_mir/src/lower.rs:4657-4678 | baml_language/crates/baml_compiler2_mir/src/lower.rs:4928-4949 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (22 lines × 2) baml_language/crates/baml_fmt/src/ast/attributes.rs:386— baml_language/crates/baml_fmt/src/ast/attributes.rs:386-407 | baml_language/crates/baml_fmt/src/ast/expressions.rs:3047-3068 — before extracting anything, compare `baml_language/crates/baml_fmt/src/ast/attributes.rs` and `baml_language/crates/baml_fmt/src/ast/expressions.rs` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 143 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the 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 (22 lines × 2) baml_language/crates/baml_fmt/src/ast/expressions.rs:4243— baml_language/crates/baml_fmt/src/ast/expressions.rs:4243-4264 | baml_language/crates/baml_fmt/src/ast/expressions.rs:4549-4570 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (22 lines × 2) baml_language/crates/bex_sap/src/deserializer/deserialize_flags.rs:156— baml_language/crates/bex_sap/src/deserializer/deserialize_flags.rs:156-177 | engine/baml-lib/jsonish/src/deserializer/deserialize_flags.rs:168-189 — before extracting anything, compare `baml_language/crates/bex_sap/src/deserializer/deserialize_flags.rs` and `engine/baml-lib/jsonish/src/deserializer/deserialize_flags.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 127 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (22 lines × 2) baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs:396— baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs:396-417 | engine/baml-lib/jsonish/src/jsonish/parser/fixing_parser/json_parse_state.rs:423-444 — before extracting anything, compare `baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs` and `engine/baml-lib/jsonish/src/jsonish/parser/fixing_parser/json_parse_state.rs` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 575 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (22 lines × 2) baml_language/crates/bridge_wasm/src/wasm_http.rs:242— baml_language/crates/bridge_wasm/src/wasm_http.rs:242-263 | baml_language/crates/bridge_wasm/src/wasm_http.rs:291-312 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (22 lines × 2) engine/baml_cffi_macros/src/lib.rs:923— engine/baml_cffi_macros/src/lib.rs:923-944 | engine/baml_cffi_macros/src/lib.rs:986-1007 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (20 lines × 2) baml_language/crates/bex_sap/src/jsonish/parser/entry.rs:185— baml_language/crates/bex_sap/src/jsonish/parser/entry.rs:185-204 | engine/baml-lib/jsonish/src/jsonish/parser/entry.rs:196-215 — before extracting anything, compare `baml_language/crates/bex_sap/src/jsonish/parser/entry.rs` and `engine/baml-lib/jsonish/src/jsonish/parser/entry.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 55 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (20 lines × 2) baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser.rs:41— baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser.rs:41-60 | engine/baml-lib/jsonish/src/jsonish/parser/fixing_parser.rs:35-54 — 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) engine/baml-lib/ast/src/ast/baml_vis/mermaid_debug.rs:86— engine/baml-lib/ast/src/ast/baml_vis/mermaid_debug.rs:86-105 | engine/baml-lib/ast/src/ast/baml_vis/mermaid_debug.rs:112-131 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (20 lines × 2) engine/baml-lib/baml-core/src/validate/generator_loader/v2.rs:134— engine/baml-lib/baml-core/src/validate/generator_loader/v2.rs:134-153 | engine/baml-lib/baml-core/src/validate/generator_loader/v2.rs:258-277 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (20 lines × 2) engine/generators/languages/go/src/ir_to_go/mod.rs:127— engine/generators/languages/go/src/ir_to_go/mod.rs:127-146 | engine/generators/languages/rust/src/ir_to_rust/mod.rs:145-164 — before extracting anything, compare `engine/generators/languages/go/src/ir_to_go/mod.rs` and `engine/generators/languages/rust/src/ir_to_rust/mod.rs` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 208 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (20 lines × 2) engine/generators/languages/python/src/watchers.rs:297— engine/generators/languages/python/src/watchers.rs:297-316 | engine/generators/languages/typescript/src/watchers.rs:285-304 — before extracting anything, compare `engine/generators/languages/python/src/watchers.rs` and `engine/generators/languages/typescript/src/watchers.rs` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 146 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (20 lines × 2) languages/rust/baml/src/runtime.rs:458— languages/rust/baml/src/runtime.rs:458-477 | languages/rust/baml/src/runtime.rs:504-523 — both copies are in the same file, so extract the block into 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–14 lines × 2) baml_language/crates/baml_fmt/src/ast/declarations.rs:1911— baml_language/crates/baml_fmt/src/ast/declarations.rs:1911-1923 | baml_language/crates/baml_fmt/src/ast/declarations.rs:2116-2129 — both copies are in the same file, so extract the block into 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–14 lines × 2) baml_language/crates/baml_sdkgen_types/src/type_queries.rs:37— baml_language/crates/baml_sdkgen_types/src/type_queries.rs:37-49 | baml_language/sdks/go/sdkgen_go/src/lib.rs:108-121 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (13–14 lines × 2) baml_language/crates/bex_vm_types/src/prompt.rs:59— baml_language/crates/bex_vm_types/src/prompt.rs:59-71 | baml_language/crates/bex_vm_types/src/prompt.rs:186-199 — both copies are in the same file, so extract the block into 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–14 lines × 2) baml_language/crates/bridge_wasm/src/wasm_http.rs:643— baml_language/crates/bridge_wasm/src/wasm_http.rs:643-656 | baml_language/crates/bridge_wasm/src/wasm_http.rs:665-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 (13–14 lines × 2) engine/baml-lib/baml-core/src/ir/ir_hasher/mod.rs:450— engine/baml-lib/baml-core/src/ir/ir_hasher/mod.rs:450-463 | engine/baml-lib/baml-core/src/ir/ir_hasher/mod.rs:465-477 — both copies are in the same file, so extract the block into 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–14 lines × 2) engine/baml-runtime/src/internal/llm_client/orchestrator/mod.rs:250— engine/baml-runtime/src/internal/llm_client/orchestrator/mod.rs:250-262 | engine/baml-runtime/src/internal/llm_client/orchestrator/mod.rs:314-327 — both copies are in the same file, so extract the block into 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–14 lines × 2) engine/language_server/src/server/api/diagnostics.rs:241— engine/language_server/src/server/api/diagnostics.rs:241-253 | engine/language_server/src/server/api/diagnostics.rs:287-300 — both copies are in the same file, so extract the block into 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 × 3) baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:2656— baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:2656-2668 | baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:5360-5372 | baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:6033-6045 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (13 lines × 3) baml_language/crates/baml_compiler2_hir_ty/src/lower.rs:2233— baml_language/crates/baml_compiler2_hir_ty/src/lower.rs:2233-2245 | baml_language/crates/baml_compiler2_hir_ty/src/lower.rs:2258-2270 | baml_language/crates/baml_compiler2_hir_ty/src/lower.rs:2322-2334 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (13 lines × 3) baml_language/crates/baml_compiler2_visualization/src/control_flow/from_ast.rs:316— baml_language/crates/baml_compiler2_visualization/src/control_flow/from_ast.rs:316-328 | baml_language/crates/baml_compiler2_visualization/src/control_flow/from_ast.rs:467-479 | engine/baml-runtime/src/control_flow.rs:611-623 — before extracting anything, compare `baml_language/crates/baml_compiler2_visualization/src/control_flow/from_ast.rs` and `engine/baml-runtime/src/control_flow.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 69 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (13 lines × 3) baml_language/crates/baml_compiler2_visualization/src/control_flow/mod.rs:369— baml_language/crates/baml_compiler2_visualization/src/control_flow/mod.rs:369-381 | engine/baml-compiler/src/viz_builder.rs:540-552 | engine/baml-runtime/src/control_flow.rs:901-913 — before extracting anything, compare `baml_language/crates/baml_compiler2_visualization/src/control_flow/mod.rs` and `engine/baml-runtime/src/control_flow.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 94 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (13 lines × 3) engine/baml_cffi_macros/src/lib.rs:824— engine/baml_cffi_macros/src/lib.rs:824-836 | engine/baml_cffi_macros/src/lib.rs:843-855 | engine/baml_cffi_macros/src/lib.rs:898-910 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (13 lines × 3) engine/language_client_cffi/src/raw_ptr_wrapper/type_builder/objects.rs:281— engine/language_client_cffi/src/raw_ptr_wrapper/type_builder/objects.rs:281-293 | engine/language_client_cffi/src/raw_ptr_wrapper/type_builder/objects.rs:635-647 | engine/language_client_cffi/src/raw_ptr_wrapper/type_builder/objects.rs:833-845 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (13 lines × 3) engine/language_client_cffi/src/raw_ptr_wrapper/type_builder/objects.rs:302— engine/language_client_cffi/src/raw_ptr_wrapper/type_builder/objects.rs:302-314 | engine/language_client_cffi/src/raw_ptr_wrapper/type_builder/objects.rs:653-665 | engine/language_client_cffi/src/raw_ptr_wrapper/type_builder/objects.rs:811-823 — 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.
X2 · Cancellation propagation· Async method without CancellationToken · ×7
Async method without CancellationToken: four_call_forms_async baml_language/sdk_tests/crates/csharp/basic_calls/TestInvocation.cs:16— No CancellationToken parameter — this work can't be stopped early once started.
Async method without CancellationToken: explicit_controls_are_applied_async baml_language/sdk_tests/crates/csharp/basic_calls/TestInvocation.cs:57— No CancellationToken parameter — this work can't be stopped early once started.
Async method without CancellationToken: ExecuteAsync baml_language/sdks/csharp/bridge_csharp/src/Cffi/HostCallDispatcher.cs:11— No CancellationToken parameter — this work can't be stopped early once started.
Async method without CancellationToken: StartPartialOperationAsync baml_language/sdks/csharp/bridge_csharp/src/Values/BamlStream.cs:336— No CancellationToken parameter — this work can't be stopped early once started.
Async method without CancellationToken: EnsureDriverStartedAsync baml_language/sdks/csharp/bridge_csharp/src/Values/BamlStream.cs:370— No CancellationToken parameter — this work can't be stopped early once started.
Async method without CancellationToken: FinalizeTerminalAsync baml_language/sdks/csharp/bridge_csharp/src/Values/BamlStream.cs:531— No CancellationToken parameter — this work can't be stopped early once started.
Async method without CancellationToken: MoveNextCoreAsync baml_language/sdks/csharp/bridge_csharp/src/Values/BamlStream.cs:730— No CancellationToken parameter — this work can't be stopped early once started.
internal_baml_jinja_types::evaluate_type::expr::tracker_visit_expr (cyclomatic 97) engine/baml-lib/jinja/src/evaluate_type/expr.rs:318— internal_baml_jinja_types::evaluate_type::expr::tracker_visit_expr has cyclomatic complexity 97 (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.
internal_baml_jinja_types::evaluate_type::stmt::track_walk (cyclomatic 28) engine/baml-lib/jinja/src/evaluate_type/stmt.rs:7— internal_baml_jinja_types::evaluate_type::stmt::track_walk 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.
internal_baml_jinja_types::evaluate_type::expr::handle_enum_binary_operation (cyclomatic 25) engine/baml-lib/jinja/src/evaluate_type/expr.rs:134— internal_baml_jinja_types::evaluate_type::expr::handle_enum_binary_operation 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.
internal_baml_jinja_types::evaluate_type::expr::infer_const_type (cyclomatic 22) engine/baml-lib/jinja/src/evaluate_type/expr.rs:660— internal_baml_jinja_types::evaluate_type::expr::infer_const_type has cyclomatic complexity 22 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
internal_baml_jinja_types::evaluate_type::stmt::narrow_attr_access_on_union_var (cyclomatic 20) engine/baml-lib/jinja/src/evaluate_type/stmt.rs:325— internal_baml_jinja_types::evaluate_type::stmt::narrow_attr_access_on_union_var 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. This is NOT this file's highest cyclomatic complexity: internal_baml_jinja_types::evaluate_type::stmt::truthy (cyclomatic 27) 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.
internal_baml_jinja_types::evaluate_type::stmt::predicate_implications (cyclomatic 19) engine/baml-lib/jinja/src/evaluate_type/stmt.rs:186— internal_baml_jinja_types::evaluate_type::stmt::predicate_implications 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. This is NOT this file's highest cyclomatic complexity: internal_baml_jinja_types::evaluate_type::stmt::truthy (cyclomatic 27) 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.
baml_lsp_server::playground_server::handle_ws_in_message (cyclomatic 59) baml_language/crates/baml_lsp_server/src/playground_server.rs:1735— baml_lsp_server::playground_server::handle_ws_in_message has cyclomatic complexity 59 (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.
baml_lsp_server::playground_server::lsp_ws_session (cyclomatic 22) baml_language/crates/baml_lsp_server/src/playground_server.rs:889— baml_lsp_server::playground_server::lsp_ws_session has cyclomatic complexity 22 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
baml_lsp_server::run_stdio_loop (cyclomatic 18) baml_language/crates/baml_lsp_server/src/lib.rs:793— baml_lsp_server::run_stdio_loop has cyclomatic complexity 18 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
baml_lsp_server::lsp_ingress::lifecycle_action (cyclomatic 18) baml_language/crates/baml_lsp_server/src/lsp_ingress.rs:1443— baml_lsp_server::lsp_ingress::lifecycle_action 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.
baml_lsp_server::playground_server::playground_ws_session (cyclomatic 18) baml_language/crates/baml_lsp_server/src/playground_server.rs:1375— baml_lsp_server::playground_server::playground_ws_session 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.
baml_lsp_server::playground_server::proxy_ws (cyclomatic 17) baml_language/crates/baml_lsp_server/src/playground_server.rs:2505— baml_lsp_server::playground_server::proxy_ws 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.
baml_query_btel::ingest::reconcile (cyclomatic 52) baml_language/crates/baml_query_btel/src/ingest.rs:392— baml_query_btel::ingest::reconcile has cyclomatic complexity 52 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
baml_query_btel::functions::register (cyclomatic 37) baml_language/crates/baml_query_btel/src/functions.rs:964— baml_query_btel::functions::register 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.
baml_query_btel::query::run (cyclomatic 23) baml_language/crates/baml_query_btel/src/query.rs:282— baml_query_btel::query::run 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.
baml_query_btel::ingest::apply_fresh (cyclomatic 16) baml_language/crates/baml_query_btel/src/ingest.rs:768— baml_query_btel::ingest::apply_fresh 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.
baml_query_btel::ingest::resolve_nodes (cyclomatic 16) baml_language/crates/baml_query_btel/src/ingest.rs:2051— baml_query_btel::ingest::resolve_nodes 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.
baml_query_btel::ingest::context::identity (cyclomatic 16) baml_language/crates/baml_query_btel/src/ingest/context.rs:214— baml_query_btel::ingest::context::identity 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.
Translator::raw (cyclomatic 45) baml_language/crates/baml_query_btel/src/sql.rs:935— Translator::raw has cyclomatic complexity 45 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Translator::binary (cyclomatic 21) baml_language/crates/baml_query_btel/src/sql.rs:1257— Translator::binary 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.
Translator::function (cyclomatic 21) baml_language/crates/baml_query_btel/src/sql.rs:1456— Translator::function has cyclomatic complexity 21 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
Translator::projection (cyclomatic 20) baml_language/crates/baml_query_btel/src/sql.rs:806— Translator::projection 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.
Translator::select (cyclomatic 18) baml_language/crates/baml_query_btel/src/sql.rs:619— Translator::select 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.
Translator::navigation (cyclomatic 18) baml_language/crates/baml_query_btel/src/sql.rs:1172— Translator::navigation 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.
JsonParseState::process_token (cyclomatic 43) engine/baml-lib/jsonish/src/jsonish/parser/fixing_parser/json_parse_state.rs:522— JsonParseState::process_token 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.
JsonParseState::process_token (cyclomatic 41) baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs:492— JsonParseState::process_token has cyclomatic complexity 41 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
JsonParseState::should_close_unescaped_string (cyclomatic 37) baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs:183— JsonParseState::should_close_unescaped_string has cyclomatic complexity 37 (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.
JsonParseState::should_close_unescaped_string (cyclomatic 37) engine/baml-lib/jsonish/src/jsonish/parser/fixing_parser/json_parse_state.rs:211— JsonParseState::should_close_unescaped_string has cyclomatic complexity 37 (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.
JsonParseState::should_close_string (cyclomatic 27) baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs:379— JsonParseState::should_close_string 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.
JsonParseState::should_close_string (cyclomatic 27) engine/baml-lib/jsonish/src/jsonish/parser/fixing_parser/json_parse_state.rs:406— JsonParseState::should_close_string 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.
OutputFormatContent::render_impl (cyclomatic 42) baml_language/crates/sys_ops/src/output_format.rs:360— OutputFormatContent::render_impl has cyclomatic complexity 42 (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.
OutputFormatContent::render_type_hoisted (cyclomatic 40) baml_language/crates/sys_ops/src/output_format.rs:771— OutputFormatContent::render_type_hoisted 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.
OutputFormatContent::render (cyclomatic 38) engine/baml-lib/jinja-runtime/src/output_format/types.rs:823— OutputFormatContent::render 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.
OutputFormatContent::inner_type_render (cyclomatic 27) engine/baml-lib/jinja-runtime/src/output_format/types.rs:685— OutputFormatContent::inner_type_render 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.
OutputFormatContent::auto_prefix (cyclomatic 19) baml_language/crates/sys_ops/src/output_format.rs:711— OutputFormatContent::auto_prefix 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.
OutputFormatContent::prefix::auto_prefix (cyclomatic 19) engine/baml-lib/jinja-runtime/src/output_format/types.rs:458— OutputFormatContent::prefix::auto_prefix 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.
Skipped test: should extract and attempt to run test case typescript/packages/playground-common/src/sdk/__tests__/runtime-integration.test.ts:249— Skipped — switched off by it.skip
Skipped test: should switch to ConditionalWorkflow when clicking CheckCondition, then select header typescript/packages/playground-common/src/sdk/__tests__/selection-integration.test.ts:127— Skipped — switched off by it.skip
Skipped test: updates atoms when toggling between workflow header and root nodes typescript/packages/playground-common/src/sdk/__tests__/selection-integration.test.ts:132— Skipped — switched off by it.skip
Skipped test: hides tabs for non-LLM workflow nodes typescript/packages/playground-common/src/sdk/__tests__/unified-selection-sync.test.ts:101— Skipped — switched off by it.skip
Skipped test: skip_case tools/sdk-parity-lint/test-fixtures/typescript/fixture/customizable/sample.test.ts:6— Skipped — switched off by it.skip
Skipped test: host_callables_release_fires_on_drop_of_callable baml_language/sdk_tests/crates/typescript/function_calls/customizable/host_callables.test.ts:328— Skipped — switched off by it.skip
JsonParseState::process_token (cognitive 90) engine/baml-lib/jsonish/src/jsonish/parser/fixing_parser/json_parse_state.rs:522— JsonParseState::process_token has cognitive complexity 90 (threshold 15). Drivers by points: if/else 18 (44 pts), match/switch 12 (36 pts), loops 2 (10 pts) (nesting depth added 58). 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.
JsonParseState::should_close_unescaped_string (cognitive 89) baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs:183— JsonParseState::should_close_unescaped_string has cognitive complexity 89 (threshold 15). Drivers by points: match/switch 9 (35 pts), if/else 10 (30 pts), loops 6 (20 pts), boolean chains 4 (nesting depth added 60). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
JsonParseState::should_close_unescaped_string (cognitive 89) engine/baml-lib/jsonish/src/jsonish/parser/fixing_parser/json_parse_state.rs:211— JsonParseState::should_close_unescaped_string has cognitive complexity 89 (threshold 15). Drivers by points: match/switch 9 (35 pts), if/else 10 (30 pts), loops 6 (20 pts), boolean chains 4 (nesting depth added 60). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
JsonParseState::process_token (cognitive 86) baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs:492— JsonParseState::process_token has cognitive complexity 86 (threshold 15). Drivers by points: if/else 18 (44 pts), match/switch 11 (32 pts), loops 2 (10 pts) (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.
JsonParseState::should_close_string (cognitive 34) baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs:379— JsonParseState::should_close_string has cognitive complexity 34 (threshold 15). Drivers by points: match/switch 5 (15 pts), if/else 10 (14 pts), loops 1 (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.
JsonParseState::should_close_string (cognitive 34) engine/baml-lib/jsonish/src/jsonish/parser/fixing_parser/json_parse_state.rs:406— JsonParseState::should_close_string has cognitive complexity 34 (threshold 15). Drivers by points: match/switch 5 (15 pts), if/else 10 (14 pts), loops 1 (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.
baml_db::check::check_interfaces (cognitive 76) baml_language/crates/baml_db/src/check.rs:888— baml_db::check::check_interfaces has cognitive complexity 76 (threshold 15). Drivers by points: if/else 16 (41 pts), loops 11 (26 pts), match/switch 2 (5 pts), boolean chains 4 (nesting depth added 43). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
baml_db::check::check_file (cognitive 70) baml_language/crates/baml_db/src/check.rs:434— baml_db::check::check_file has cognitive complexity 70 (threshold 15). Drivers by points: loops 22 (38 pts), if/else 12 (24 pts), boolean chains 6, match/switch 1 (2 pts) (nesting depth added 29). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
baml_db::check::validate_ambiguous_typevar_associated_projection_in_type_expr (cognitive 36) baml_language/crates/baml_db/src/check.rs:1413— baml_db::check::validate_ambiguous_typevar_associated_projection_in_type_expr has cognitive complexity 36 (threshold 15). Drivers by points: if/else 8 (22 pts), loops 4 (8 pts), match/switch 2 (5 pts), boolean chains 1 (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.
baml_db::check::new_tir_diagnostic (cognitive 26) baml_language/crates/baml_db/src/check.rs:1785— baml_db::check::new_tir_diagnostic has cognitive complexity 26 (threshold 15). Drivers by points: if/else 15 (19 pts), match/switch 4 (7 pts) (nesting depth added 7). 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.
baml_db::check::validate_associated_type_bindings_in_items (cognitive 22) baml_language/crates/baml_db/src/check.rs:1162— baml_db::check::validate_associated_type_bindings_in_items has cognitive complexity 22 (threshold 15). Drivers by points: loops 7 (20 pts), match/switch 1 (2 pts) (nesting depth added 14). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
baml_db::manifest::unknown_field_warnings (cognitive 16) baml_language/crates/baml_db/src/manifest.rs:254— baml_db::manifest::unknown_field_warnings has cognitive complexity 16 (threshold 15). Drivers by points: loops 9 (13 pts), if/else 2 (3 pts) (nesting depth added 5). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
internal_baml_ast::parser::parse_type_expression_block::parse_type_expression_block (cognitive 51) engine/baml-lib/ast/src/parser/parse_type_expression_block.rs:16— internal_baml_ast::parser::parse_type_expression_block::parse_type_expression_block has cognitive complexity 51 (threshold 15). Drivers by points: match/switch 9 (37 pts), if/else 4 (9 pts), loops 3 (5 pts) (nesting depth added 35). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own 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.
internal_baml_ast::parser::parse_value_expression_block::parse_value_expression_block (cognitive 48) engine/baml-lib/ast/src/parser/parse_value_expression_block.rs:15— internal_baml_ast::parser::parse_value_expression_block::parse_value_expression_block has cognitive complexity 48 (threshold 15). Drivers by points: match/switch 8 (28 pts), if/else 7 (12 pts), boolean chains 4, loops 2 (4 pts) (nesting depth added 27). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own 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.
internal_baml_ast::parser::parse::parse (cognitive 44) engine/baml-lib/ast/src/parser/parse.rs:56— internal_baml_ast::parser::parse::parse has cognitive complexity 44 (threshold 15). Drivers by points: match/switch 9 (29 pts), if/else 4 (13 pts), loops 1 (2 pts) (nesting depth added 30). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own 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.
internal_baml_ast::parser::parse_expr::parse_expr_block (cognitive 36) engine/baml-lib/ast/src/parser/parse_expr.rs:731— internal_baml_ast::parser::parse_expr::parse_expr_block has cognitive complexity 36 (threshold 15). Drivers by points: if/else 9 (21 pts), match/switch 4 (8 pts), loops 5 (7 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.
internal_baml_ast::parser::parse_named_args_list::parse_named_argument_list (cognitive 27) engine/baml-lib/ast/src/parser/parse_named_args_list.rs:14— internal_baml_ast::parser::parse_named_args_list::parse_named_argument_list has cognitive complexity 27 (threshold 15). Drivers by points: if/else 6 (13 pts), match/switch 3 (9 pts), loops 2 (3 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.
internal_baml_ast::parser::parse_type_builder_block::parse_type_builder_contents (cognitive 23) engine/baml-lib/ast/src/parser/parse_type_builder_block.rs:47— internal_baml_ast::parser::parse_type_builder_block::parse_type_builder_contents has cognitive complexity 23 (threshold 15). Drivers by points: match/switch 4 (14 pts), if/else 1 (5 pts), loops 2 (4 pts) (nesting depth added 16). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
sdkgen_swift::emit::render_callable (cognitive 45) baml_language/sdks/swift/rust/sdkgen_swift/src/emit.rs:263— sdkgen_swift::emit::render_callable has cognitive complexity 45 (threshold 15). Drivers by points: if/else 24 (32 pts), loops 6 (8 pts), match/switch 4, boolean chains 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
sdkgen_swift::to_source_code_with_optional_metadata (cognitive 31) baml_language/sdks/swift/rust/sdkgen_swift/src/lib.rs:66— sdkgen_swift::to_source_code_with_optional_metadata has cognitive complexity 31 (threshold 15). Drivers by points: if/else 10 (22 pts), loops 6 (7 pts), match/switch 1 (2 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.
sdkgen_swift::translate_ty::translate_ty (cognitive 27) baml_language/sdks/swift/rust/sdkgen_swift/src/translate_ty.rs:73— sdkgen_swift::translate_ty::translate_ty has cognitive complexity 27 (threshold 15). Drivers by points: if/else 10 (22 pts), match/switch 3 (5 pts) (nesting depth added 14). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
sdkgen_swift::emit::render_class (cognitive 20) baml_language/sdks/swift/rust/sdkgen_swift/src/emit.rs:101— sdkgen_swift::emit::render_class has cognitive complexity 20 (threshold 15). Drivers by points: if/else 13 (16 pts), loops 3, boolean chains 1 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
sdkgen_swift::build_translate_ctx (cognitive 18) baml_language/sdks/swift/rust/sdkgen_swift/src/lib.rs:227— sdkgen_swift::build_translate_ctx has cognitive complexity 18 (threshold 15). Drivers by points: if/else 2 (6 pts), match/switch 2 (5 pts), loops 3 (4 pts), boolean chains 3 (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.
sdkgen_swift::compute_boxed_fields (cognitive 18) baml_language/sdks/swift/rust/sdkgen_swift/src/lib.rs:328— sdkgen_swift::compute_boxed_fields has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (13 pts), loops 4 (5 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
StackifyCodegen::emit_terminator (cognitive 34) baml_language/crates/baml_compiler2_emit/src/emit.rs:2306— StackifyCodegen::emit_terminator has cognitive complexity 34 (threshold 15). Drivers by points: if/else 11 (23 pts), match/switch 5 (11 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.
StackifyCodegen::emit_statement (cognitive 28) baml_language/crates/baml_compiler2_emit/src/emit.rs:1288— StackifyCodegen::emit_statement has cognitive complexity 28 (threshold 15). Drivers by points: if/else 7 (14 pts), match/switch 6 (14 pts) (nesting depth added 15). 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.
StackifyCodegen::emit_rvalue_pull (cognitive 23) baml_language/crates/baml_compiler2_emit/src/emit.rs:1714— StackifyCodegen::emit_rvalue_pull has cognitive complexity 23 (threshold 15). Drivers by points: loops 5 (11 pts), if/else 8 (10 pts), match/switch 1 (2 pts) (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.
StackifyCodegen::compile (cognitive 21) baml_language/crates/baml_compiler2_emit/src/emit.rs:766— StackifyCodegen::compile has cognitive complexity 21 (threshold 15). Drivers by points: if/else 6 (12 pts), loops 5, boolean chains 2, match/switch 1 (2 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.
StackifyCodegen::patch_jumps (cognitive 17) baml_language/crates/baml_compiler2_emit/src/emit.rs:2699— StackifyCodegen::patch_jumps has cognitive complexity 17 (threshold 15). Drivers by points: if/else 2 (6 pts), match/switch 2 (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.
StackifyCodegen::try_emit_class_aggregate_field_copy_sets (cognitive 16) baml_language/crates/baml_compiler2_emit/src/emit.rs:1608— StackifyCodegen::try_emit_class_aggregate_field_copy_sets has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (11 pts), loops 3 (4 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.
bridge_cffi::baml_to_host::decode_invocation_request (cognitive 28) baml_language/crates/bridge_cffi/src/baml_to_host.rs:425— bridge_cffi::baml_to_host::decode_invocation_request has cognitive complexity 28 (threshold 15). Drivers by points: if/else 11 (18 pts), match/switch 4 (9 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.
bridge_cffi::host_capture::copy (cognitive 21) baml_language/crates/bridge_cffi/src/host_capture.rs:37— bridge_cffi::host_capture::copy has cognitive complexity 21 (threshold 15). Drivers by points: if/else 8 (15 pts), loops 1 (3 pts), 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.
bridge_cffi::invocation_protocol::decode_call (cognitive 20) baml_language/crates/bridge_cffi/src/invocation_protocol.rs:24— bridge_cffi::invocation_protocol::decode_call has cognitive complexity 20 (threshold 15). Drivers by points: match/switch 3 (10 pts), if/else 5 (7 pts), loops 1 (3 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.
bridge_cffi::ffi::host_value::complete_host_call (cognitive 19) baml_language/crates/bridge_cffi/src/ffi/host_value.rs:108— bridge_cffi::ffi::host_value::complete_host_call has cognitive complexity 19 (threshold 15). Drivers by points: if/else 9 (11 pts), match/switch 4 (6 pts), boolean chains 2 (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
bridge_cffi::invocation_protocol::validate_fields (cognitive 17) baml_language/crates/bridge_cffi/src/invocation_protocol.rs:113— bridge_cffi::invocation_protocol::validate_fields has cognitive complexity 17 (threshold 15). Drivers by points: if/else 5 (11 pts), match/switch 2 (4 pts), boolean chains 1, 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.
bridge_cffi::control_projection::clone_outbound::clone_refs (cognitive 16) baml_language/crates/bridge_cffi/src/control_projection.rs:136— bridge_cffi::control_projection::clone_outbound::clone_refs has cognitive complexity 16 (threshold 15). Drivers by points: if/else 3 (8 pts), loops 3 (6 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.
Change coupling: completion.rs ↔ runtime_interface.rs engine/baml-runtime/src/internal/llm_client/traits/completion.rs:1— `engine/baml-runtime/src/internal/llm_client/traits/completion.rs` and `engine/baml-runtime/src/runtime_interface.rs` change together 62% of the time (8 of the 13 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well — 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 8 shared commits counted here, the most recent 3 are `de8996f1` rip out ResponseType; `564a53c2` get the python-facing streaming interface implemented; `2c54e539` commit a bunch — run `git show` on any of them.
Change coupling: mod.rs ↔ async_context_vars.ts engine/baml-runtime/src/tracing/mod.rs:1— `engine/baml-runtime/src/tracing/mod.rs` and `engine/language_client_typescript/typescript_src/async_context_vars.ts` change together 60% of the time (6 of the 10 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well — 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) and are written in DIFFERENT LANGUAGES, so no import can join them and they cannot be co-located into one unit — they compile and ship as separate artifacts. What binds them is a CONTRACT across that boundary — an event or message name, a route, a serialised shape — that each side currently spells out on its own, which is exactly why a change to one drags the other. Declare that contract once where both sides read it (a shared schema, a generated constants file, an interface-definition file) so a change on one side fails the other's build instead of drifting silently; where the surface is too small to be worth that, name the counterpart in a comment on both sides so the next reader finds it. There is nothing here to merge. You can check this without leaving the row: of the 6 shared commits counted here, the most recent 3 are `69e6c29c` Add ability for users to reset env vars to their desire. (#984); `e8c1a61a` Adding various fixes (#806); `28b1f15d` logger callback (#715) — run `git show` on any of them.
Change coupling: mod.rs ↔ async_context_vars.d.ts engine/baml-runtime/src/tracing/mod.rs:1— `engine/baml-runtime/src/tracing/mod.rs` and `engine/language_client_typescript/async_context_vars.d.ts` change together 55% of the time (6 of the 11 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well — 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) and are written in DIFFERENT LANGUAGES, so no import can join them and they cannot be co-located into one unit — they compile and ship as separate artifacts. What binds them is a CONTRACT across that boundary — an event or message name, a route, a serialised shape — that each side currently spells out on its own, which is exactly why a change to one drags the other. Declare that contract once where both sides read it (a shared schema, a generated constants file, an interface-definition file) so a change on one side fails the other's build instead of drifting silently; where the surface is too small to be worth that, name the counterpart in a comment on both sides so the next reader finds it. There is nothing here to merge. You can check this without leaving the row: of the 6 shared commits counted here, the most recent 3 are `69e6c29c` Add ability for users to reset env vars to their desire. (#984); `e8c1a61a` Adding various fixes (#806); `28b1f15d` logger callback (#715) — run `git show` on any of them.
Change coupling: completion.rs ↔ mod.rs engine/baml-runtime/src/internal/llm_client/traits/completion.rs:1— `engine/baml-runtime/src/internal/llm_client/traits/completion.rs` and `engine/baml-runtime/src/runtime/mod.rs` change together 54% of the time (7 of the 13 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well — 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 7 shared commits counted here, the most recent 3 are `80751768` everything compiles in RS; `142c9296` working WASM; `cb825eb8` client compiles again — run `git show` on any of them.
Change coupling: ast.rs ↔ diagnostic.rs baml_language/crates/baml_compiler2_ast/src/ast.rs:1— `baml_language/crates/baml_compiler2_ast/src/ast.rs` and `baml_language/crates/baml_compiler_diagnostics/src/diagnostic.rs` change together 50% of the time (5 of the 10 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well — 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 5 shared commits counted here, the most recent 3 are `a06a1e9c` Diagnose inline unreflect type arguments that escape their call (#4518); `1f8c7306` Improved `implements` rules representation in compiler (#3852); `da4d557d` feat(compiler2): add `defer` statement (BEP-042) (#3785) — run `git show` on any of them.
Change coupling: ctx_manager.py ↔ async_context_vars.ts engine/language_client_python/python_src/baml_py/ctx_manager.py:1— `engine/language_client_python/python_src/baml_py/ctx_manager.py` and `engine/language_client_typescript/typescript_src/async_context_vars.ts` change together 50% of the time (5 of the 10 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well — 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) and are written in DIFFERENT LANGUAGES, so no import can join them and they cannot be co-located into one unit — they compile and ship as separate artifacts. What binds them is a CONTRACT across that boundary — an event or message name, a route, a serialised shape — that each side currently spells out on its own, which is exactly why a change to one drags the other. Declare that contract once where both sides read it (a shared schema, a generated constants file, an interface-definition file) so a change on one side fails the other's build instead of drifting silently; where the surface is too small to be worth that, name the counterpart in a comment on both sides so the next reader finds it. There is nothing here to merge. You can check this without leaving the row: of the 5 shared commits counted here, the most recent 3 are `69e6c29c` Add ability for users to reset env vars to their desire. (#984); `e8c1a61a` Adding various fixes (#806); `be74999d` Fix minor bugs (#728) — run `git show` on any of them.
Duplicated block (26 lines × 2) baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:6292— baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:6292-6317 | baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:6376-6401 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (26 lines × 2) baml_language/crates/baml_fmt/src/ast/expressions.rs:3009— baml_language/crates/baml_fmt/src/ast/expressions.rs:3009-3034 | baml_language/crates/baml_fmt/src/ast/expressions.rs:4486-4511 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (26 lines × 2) baml_language/crates/bridge_wasm/src/runs.rs:644— baml_language/crates/bridge_wasm/src/runs.rs:644-669 | baml_language/crates/bridge_wasm/src/runs.rs:764-789 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (26 lines × 2) engine/baml-runtime/src/optimize/applier.rs:367— engine/baml-runtime/src/optimize/applier.rs:367-392 | engine/baml-runtime/src/optimize/applier.rs:507-532 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (26 lines × 2) engine/generators/languages/go/src/ir_to_go/mod.rs:300— engine/generators/languages/go/src/ir_to_go/mod.rs:300-325 | engine/generators/languages/rust/src/ir_to_rust/mod.rs:330-355 — before extracting anything, compare `engine/generators/languages/go/src/ir_to_go/mod.rs` and `engine/generators/languages/rust/src/ir_to_rust/mod.rs` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 208 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, 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 (26 lines × 2) engine/generators/languages/python/src/ir_to_py/functions.rs:14— engine/generators/languages/python/src/ir_to_py/functions.rs:14-39 | engine/generators/languages/python/src/ir_to_py/functions.rs:54-79 — both copies are in the same file, so extract the block into 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–22 lines × 2) baml_language/crates/baml_compiler2_visualization/src/control_flow/flatten.rs:721— baml_language/crates/baml_compiler2_visualization/src/control_flow/flatten.rs:721-742 | engine/baml-runtime/src/control_flow/flatten/step3_inline_implicit_nodes.rs:187-207 — before extracting anything, compare `baml_language/crates/baml_compiler2_visualization/src/control_flow/flatten.rs` and `engine/baml-runtime/src/control_flow/flatten/step3_inline_implicit_nodes.rs` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 132 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (21–22 lines × 2) baml_language/crates/bex_engine/src/conversion.rs:4931— baml_language/crates/bex_engine/src/conversion.rs:4931-4952 | baml_language/crates/bex_engine/src/conversion.rs:4996-5016 — both copies are in the same file, so extract the block into 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–22 lines × 2) engine/baml-lib/baml-log/src/logger.rs:733— engine/baml-lib/baml-log/src/logger.rs:733-753 | engine/baml-lib/baml-log/src/logger.rs:870-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 (21–22 lines × 2) engine/baml-lib/llm-client/src/clients/anthropic.rs:197— engine/baml-lib/llm-client/src/clients/anthropic.rs:197-217 | engine/baml-lib/llm-client/src/clients/google_ai.rs:187-208 — before extracting anything, compare `engine/baml-lib/llm-client/src/clients/anthropic.rs` and `engine/baml-lib/llm-client/src/clients/google_ai.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 43 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the 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 (21–22 lines × 2) engine/baml-runtime/src/optimize/tui.rs:1119— engine/baml-runtime/src/optimize/tui.rs:1119-1140 | engine/baml-runtime/src/optimize/tui.rs:1518-1538 — both copies are in the same file, so extract the block into 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–22 lines × 2) baml_language/sdks/go/baml_go/runtime.go:388— baml_language/sdks/go/baml_go/runtime.go:388-409 | baml_language/sdks/go/baml_go/runtime.go:441-461 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `baml_language/sdks/go/baml_go/runtime.go: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. The matched lines also register a scope-exit action (a `defer`-style statement) that runs when the function holding them returns: moved into a called unit it would run when THAT unit returns instead — before the caller uses what it releases — so keep the registration at the call site and extract only the work around it, or have the extracted unit hand the resource back for the caller to register.
Duplicated block (16–17 lines × 2) baml_language/crates/baml_builtins2_codegen/src/extract.rs:285— baml_language/crates/baml_builtins2_codegen/src/extract.rs:285-300 | baml_language/crates/baml_builtins2_codegen/src/extract.rs:647-663 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (16–17 lines × 2) baml_language/crates/baml_compiler2_mir/src/lower.rs:6134— baml_language/crates/baml_compiler2_mir/src/lower.rs:6134-6149 | baml_language/crates/baml_compiler2_mir/src/lower.rs:10187-10203 — both copies are in the same file, so extract the block into 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–17 lines × 2) baml_language/crates/baml_ide/src/describe.rs:857— baml_language/crates/baml_ide/src/describe.rs:857-873 | baml_language/crates/baml_ide/src/describe.rs:968-983 — both copies are in the same file, so extract the block into 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–17 lines × 2) engine/baml-lib/diagnostics/src/error.rs:553— engine/baml-lib/diagnostics/src/error.rs:553-568 | engine/baml-lib/diagnostics/src/warning.rs:119-135 — 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 (16–17 lines × 2) engine/baml-runtime/src/async_interpreter_runtime.rs:381— engine/baml-runtime/src/async_interpreter_runtime.rs:381-396 | engine/baml-runtime/src/async_interpreter_runtime.rs:413-429 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (16–17 lines × 2) baml_language/sdk_tests/harness_runner/src/lib.rs:321— baml_language/sdk_tests/harness_runner/src/lib.rs:321-337 | baml_language/sdk_tests/harness_runner/src/lib.rs:389-404 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (12 lines × 4) baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs:747— baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs:747-758 | baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs:775-786 | engine/baml-lib/jsonish/src/jsonish/parser/fixing_parser/json_parse_state.rs:781-792 | engine/baml-lib/jsonish/src/jsonish/parser/fixing_parser/json_parse_state.rs:813-824 — before extracting anything, compare `baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs` and `engine/baml-lib/jsonish/src/jsonish/parser/fixing_parser/json_parse_state.rs` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 575 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (12 lines × 4) engine/baml-lib/llm-client/src/clients/anthropic.rs:86— engine/baml-lib/llm-client/src/clients/anthropic.rs:86-97 | engine/baml-lib/llm-client/src/clients/aws_bedrock.rs:152-163 | engine/baml-lib/llm-client/src/clients/google_ai.rs:85-96 | engine/baml-lib/llm-client/src/clients/vertex.rs:225-236 — before extracting anything, compare `engine/baml-lib/llm-client/src/clients/anthropic.rs` and `engine/baml-lib/llm-client/src/clients/google_ai.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 43 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (12 lines × 4) engine/baml-vm/src/vm.rs:754— engine/baml-vm/src/vm.rs:754-765 | engine/baml-vm/src/vm.rs:833-844 | engine/baml-vm/src/vm.rs:1308-1319 | engine/baml-vm/src/vm.rs:1363-1374 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (12 lines × 4) engine/generators/languages/go/src/ir_to_go/classes.rs:10— engine/generators/languages/go/src/ir_to_go/classes.rs:10-21 | engine/generators/languages/go/src/ir_to_go/classes.rs:29-40 | engine/generators/languages/ruby/src/ir_to_rb/classes.rs:10-21 | engine/generators/languages/ruby/src/ir_to_rb/classes.rs:29-40 — 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.
Duplicated block (12 lines × 4) engine/generators/languages/typescript/src/lib.rs:191— engine/generators/languages/typescript/src/lib.rs:191-202 | engine/generators/languages/typescript/src/lib.rs:218-229 | engine/generators/languages/typescript/src/lib.rs:295-306 | engine/generators/languages/typescript/src/lib.rs:326-337 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (12 lines × 4) engine/language_client_cffi/src/ffi/functions.rs:80— engine/language_client_cffi/src/ffi/functions.rs:80-91 | engine/language_client_cffi/src/ffi/functions.rs:144-155 | engine/language_client_cffi/src/ffi/functions.rs:255-266 | engine/language_client_cffi/src/ffi/functions.rs:359-370 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (12 lines × 3) baml_language/crates/baml_compiler2_visualization/src/control_flow/from_ast.rs:390— baml_language/crates/baml_compiler2_visualization/src/control_flow/from_ast.rs:390-401 | baml_language/crates/baml_compiler2_visualization/src/control_flow/from_ast.rs:426-437 | engine/baml-runtime/src/control_flow.rs:681-692 — before extracting anything, compare `baml_language/crates/baml_compiler2_visualization/src/control_flow/from_ast.rs` and `engine/baml-runtime/src/control_flow.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 69 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (12 lines × 3) baml_language/crates/baml_fmt/src/ast/attributes.rs:416— baml_language/crates/baml_fmt/src/ast/attributes.rs:416-427 | baml_language/crates/baml_fmt/src/ast/declarations.rs:533-544 | baml_language/crates/baml_fmt/src/ast/expressions.rs:3077-3088 — before extracting anything, compare `baml_language/crates/baml_fmt/src/ast/attributes.rs` and `baml_language/crates/baml_fmt/src/ast/declarations.rs` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 70 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (12 lines × 3) baml_language/crates/bex_vm/src/vm.rs:11478— baml_language/crates/bex_vm/src/vm.rs:11478-11489 | baml_language/crates/bex_vm/src/vm.rs:11512-11523 | baml_language/crates/bex_vm/src/vm.rs:11546-11557 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (12 lines × 3) engine/baml-runtime/src/internal/llm_client/primitive/anthropic/anthropic_client.rs:164— engine/baml-runtime/src/internal/llm_client/primitive/anthropic/anthropic_client.rs:164-175 | engine/baml-runtime/src/internal/llm_client/primitive/google/googleai_client.rs:197-208 | engine/baml-runtime/src/internal/llm_client/primitive/vertex/vertex_client.rs:221-232 — before extracting anything, compare `engine/baml-runtime/src/internal/llm_client/primitive/anthropic/anthropic_client.rs` and `engine/baml-runtime/src/internal/llm_client/primitive/google/googleai_client.rs` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 79 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (12 lines × 3) languages/rust/baml-macros/src/shared.rs:61— languages/rust/baml-macros/src/shared.rs:61-72 | languages/rust/baml-macros/src/shared.rs:92-103 | languages/rust/baml-macros/src/shared.rs:127-138 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (12 lines × 3) engine/baml-runtime/src/internal/llm_client/primitive/anthropic/anthropic_client.rs:453— engine/baml-runtime/src/internal/llm_client/primitive/anthropic/anthropic_client.rs:453-464 | engine/baml-runtime/src/internal/llm_client/primitive/google/googleai_client.rs:327-338 | engine/baml-runtime/src/internal/llm_client/primitive/vertex/vertex_client.rs:534-545 — before extracting anything, compare `engine/baml-runtime/src/internal/llm_client/primitive/anthropic/anthropic_client.rs` and `engine/baml-runtime/src/internal/llm_client/primitive/google/googleai_client.rs` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 79 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (11–12 lines × 2) baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:6970— baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:6970-6980 | baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:7050-7061 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler2_hir_ty/src/lower.rs:1234— baml_language/crates/baml_compiler2_hir_ty/src/lower.rs:1234-1245 | baml_language/crates/baml_compiler2_hir_ty/src/lower.rs:1373-1383 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler2_mir/src/lower.rs:14268— baml_language/crates/baml_compiler2_mir/src/lower.rs:14268-14279 | baml_language/crates/baml_compiler2_mir/src/lower.rs:14618-14628 — both copies are in the same file, so extract the block into 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) baml_language/crates/sys_ops/src/output_format.rs:465— baml_language/crates/sys_ops/src/output_format.rs:465-475 | baml_language/crates/sys_ops/src/output_format.rs:993-1004 — both copies are in the same file, so extract the block into 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) engine/baml-runtime/src/cli/repl.rs:1331— engine/baml-runtime/src/cli/repl.rs:1331-1342 | engine/baml-runtime/src/cli/repl.rs:1470-1480 — both copies are in the same file, so extract the block into 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) engine/baml-runtime/src/lib.rs:715— engine/baml-runtime/src/lib.rs:715-726 | engine/baml-runtime/src/lib.rs:928-938 — both copies are in the same file, so extract the block into 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 × 4) baml_language/crates/bex_vm/src/package_baml/csv.rs:2345— baml_language/crates/bex_vm/src/package_baml/csv.rs:2345-2351 | baml_language/crates/bex_vm/src/package_baml/csv.rs:2380-2386 | baml_language/crates/bex_vm/src/package_baml/csv.rs:2627-2633 | baml_language/crates/bex_vm/src/package_baml/csv.rs:2654-2660 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (7 lines × 4) baml_language/sdks/go/sdkgen_go/src/names.rs:1210— baml_language/sdks/go/sdkgen_go/src/names.rs:1210-1216 | baml_language/sdks/go/sdkgen_go/src/names.rs:1226-1232 | baml_language/sdks/go/sdkgen_go/src/names.rs:1245-1251 | baml_language/sdks/go/sdkgen_go/src/names.rs:1254-1260 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (7 lines × 4) engine/baml-lib/ast/src/ast/field.rs:210— engine/baml-lib/ast/src/ast/field.rs:210-216 | engine/baml-lib/ast/src/ast/field.rs:222-228 | engine/baml-lib/ast/src/ast/field.rs:234-240 | engine/baml-lib/ast/src/ast/field.rs:246-252 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (7 lines × 4) engine/language_client_cffi/src/raw_ptr_wrapper/type_builder/objects.rs:258— engine/language_client_cffi/src/raw_ptr_wrapper/type_builder/objects.rs:258-264 | engine/language_client_cffi/src/raw_ptr_wrapper/type_builder/objects.rs:505-511 | engine/language_client_cffi/src/raw_ptr_wrapper/type_builder/objects.rs:623-629 | engine/language_client_cffi/src/raw_ptr_wrapper/type_builder/objects.rs:795-801 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (7 lines × 4) engine/language_client_cffi/src/raw_ptr_wrapper/type_builder/objects.rs:267— engine/language_client_cffi/src/raw_ptr_wrapper/type_builder/objects.rs:267-273 | engine/language_client_cffi/src/raw_ptr_wrapper/type_builder/objects.rs:496-502 | engine/language_client_cffi/src/raw_ptr_wrapper/type_builder/objects.rs:614-620 | engine/language_client_cffi/src/raw_ptr_wrapper/type_builder/objects.rs:786-792 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (7 lines × 4) baml_language/crates/baml_fmt/src/ast/declarations.rs:3397— baml_language/crates/baml_fmt/src/ast/declarations.rs:3397-3403 | baml_language/crates/baml_fmt/src/ast/expressions.rs:2301-2307 | baml_language/crates/baml_fmt/src/ast/expressions.rs:2704-2710 | baml_language/crates/baml_fmt/src/ast/statements.rs:179-185 — before extracting anything, compare `baml_language/crates/baml_fmt/src/ast/declarations.rs` and `baml_language/crates/baml_fmt/src/ast/expressions.rs` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 124 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the 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 × 4) baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:2391— baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:2391-2396 | baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:2843-2848 | baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:2973-2978 | baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:5971-5976 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (6 lines × 4) baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:162— baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:162-168 | baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:212-218 | baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:240-246 | baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:258-263 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (6 lines × 4) baml_language/crates/baml_compiler2_mir/src/lower.rs:8844— baml_language/crates/baml_compiler2_mir/src/lower.rs:8844-8849 | baml_language/crates/baml_compiler2_mir/src/lower.rs:8877-8882 | baml_language/crates/baml_compiler2_mir/src/lower.rs:8925-8930 | baml_language/crates/baml_compiler2_mir/src/lower.rs:8959-8964 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (6 lines × 4) baml_language/crates/baml_fmt/src/ast/declarations.rs:858— baml_language/crates/baml_fmt/src/ast/declarations.rs:858-864 | baml_language/crates/baml_fmt/src/ast/declarations.rs:1921-1926 | baml_language/crates/baml_fmt/src/ast/declarations.rs:2127-2133 | baml_language/crates/baml_fmt/src/ast/declarations.rs:2586-2592 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (6 lines × 4) engine/baml-runtime/src/internal/llm_client/primitive/anthropic/response_handler.rs:14— engine/baml-runtime/src/internal/llm_client/primitive/anthropic/response_handler.rs:14-19 | engine/baml-runtime/src/internal/llm_client/primitive/google/response_handler.rs:13-18 | engine/baml-runtime/src/internal/llm_client/primitive/openai/response_handler.rs:17-22 | engine/baml-runtime/src/internal/llm_client/primitive/vertex/response_handler.rs:13-18 — `engine/baml-runtime/src/internal/llm_client/primitive/anthropic/response_handler.rs` and `engine/baml-runtime/src/internal/llm_client/primitive/openai/response_handler.rs` 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 4 separate duplicated blocks between them, totalling at least 33 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.
Duplicated block (6 lines × 4) scripts/ffi-debug/analyze_ffi.py:183— scripts/ffi-debug/analyze_ffi.py:183-188 | scripts/ffi-debug/analyze_ffi.py:206-211 | scripts/ffi-debug/analyze_ffi.py:221-226 | scripts/ffi-debug/analyze_ffi.py:234-239 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `scripts/ffi-debug/analyze_ffi.py:212` calls `sum`, `values` and `scripts/ffi-debug/analyze_ffi.py:229` 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.
bex_engine::conversion::value_matches_type_with_definitions (cyclomatic 46) baml_language/crates/bex_engine/src/conversion.rs:3410— bex_engine::conversion::value_matches_type_with_definitions has cyclomatic complexity 46 (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.
bex_engine::conversion::coerce_arg_to_declared_type_with_aliases (cyclomatic 31) baml_language/crates/bex_engine/src/conversion.rs:4845— bex_engine::conversion::coerce_arg_to_declared_type_with_aliases has cyclomatic complexity 31 (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.
bex_engine::host_instrumentation::capture_callback_inputs::copy (cyclomatic 26) baml_language/crates/bex_engine/src/host_instrumentation.rs:494— bex_engine::host_instrumentation::capture_callback_inputs::copy 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.
bex_engine::conversion::find_matching_member (cyclomatic 21) baml_language/crates/bex_engine/src/conversion.rs:3078— bex_engine::conversion::find_matching_member has cyclomatic complexity 21 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
bex_engine::conversion::find_matching_union_member (cyclomatic 17) baml_language/crates/bex_engine/src/conversion.rs:4165— bex_engine::conversion::find_matching_union_member 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.
baml_db::check::check_file (cyclomatic 42) baml_language/crates/baml_db/src/check.rs:434— baml_db::check::check_file has cyclomatic complexity 42 (threshold 15). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline. This is NOT this file's highest cyclomatic complexity: baml_db::check::tir_type_error_to_diagnostic_id (cyclomatic 125) 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.
baml_db::check::check_interfaces (cyclomatic 32) baml_language/crates/baml_db/src/check.rs:888— baml_db::check::check_interfaces 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. This is NOT this file's highest cyclomatic complexity: baml_db::check::tir_type_error_to_diagnostic_id (cyclomatic 125) 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.
baml_db::check::source_aware_tir_type_error_message (cyclomatic 22) baml_language/crates/baml_db/src/check.rs:1973— baml_db::check::source_aware_tir_type_error_message has cyclomatic complexity 22 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing. This is NOT this file's highest cyclomatic complexity: baml_db::check::tir_type_error_to_diagnostic_id (cyclomatic 125) 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.
baml_db::check::validate_ambiguous_typevar_associated_projection_in_type_expr (cyclomatic 21) baml_language/crates/baml_db/src/check.rs:1413— baml_db::check::validate_ambiguous_typevar_associated_projection_in_type_expr 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. This is NOT this file's highest cyclomatic complexity: baml_db::check::tir_type_error_to_diagnostic_id (cyclomatic 125) 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.
baml_db::check::new_tir_diagnostic (cyclomatic 18) baml_language/crates/baml_db/src/check.rs:1785— baml_db::check::new_tir_diagnostic has cyclomatic complexity 18 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages. This is NOT this file's highest cyclomatic complexity: baml_db::check::tir_type_error_to_diagnostic_id (cyclomatic 125) 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.
baml_compiler2_visualization::control_flow::from_ast::render_expr_compact_ast (cyclomatic 40) baml_language/crates/baml_compiler2_visualization/src/control_flow/from_ast.rs:1088— baml_compiler2_visualization::control_flow::from_ast::render_expr_compact_ast 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.
baml_compiler2_visualization::control_flow::from_ast::collect_callee_names_expr (cyclomatic 37) baml_language/crates/baml_compiler2_visualization/src/control_flow/from_ast.rs:863— baml_compiler2_visualization::control_flow::from_ast::collect_callee_names_expr 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.
baml_compiler2_visualization::control_flow::flatten::compute_required_nodes (cyclomatic 22) baml_language/crates/baml_compiler2_visualization/src/control_flow/flatten.rs:219— baml_compiler2_visualization::control_flow::flatten::compute_required_nodes 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.
baml_compiler2_visualization::control_flow::flatten::prepare_control_flow_graph_for_visualization (cyclomatic 19) baml_language/crates/baml_compiler2_visualization/src/control_flow/flatten.rs:34— baml_compiler2_visualization::control_flow::flatten::prepare_control_flow_graph_for_visualization 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.
baml_compiler2_visualization::control_flow::from_ast::collect_callee_names_stmt (cyclomatic 16) baml_language/crates/baml_compiler2_visualization/src/control_flow/from_ast.rs:1006— baml_compiler2_visualization::control_flow::from_ast::collect_callee_names_stmt 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.
btel_snapshot::host::add (cyclomatic 34) baml_language/crates/btel_snapshot/src/host.rs:62— btel_snapshot::host::add has cyclomatic complexity 34 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
btel_snapshot::decode::decode (cyclomatic 21) baml_language/crates/btel_snapshot/src/decode.rs:342— btel_snapshot::decode::decode has cyclomatic complexity 21 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
btel_snapshot::walk::value (cyclomatic 18) baml_language/crates/btel_snapshot/src/walk.rs:155— btel_snapshot::walk::value 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.
btel_snapshot::walk::object (cyclomatic 18) baml_language/crates/btel_snapshot/src/walk.rs:338— btel_snapshot::walk::object 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.
btel_snapshot::memory::type_bytes (cyclomatic 16) baml_language/crates/btel_snapshot/src/memory.rs:118— btel_snapshot::memory::type_bytes 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.
internal_baml_core::ir::ir_helpers::get_dummy_value (cyclomatic 34) engine/baml-lib/baml-core/src/ir/ir_helpers/mod.rs:394— internal_baml_core::ir::ir_helpers::get_dummy_value 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.
internal_baml_core::ir::repr::specialize_generics (cyclomatic 26) engine/baml-lib/baml-core/src/ir/repr.rs:3104— internal_baml_core::ir::repr::specialize_generics has cyclomatic complexity 26 (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.
internal_baml_core::validate::generator_loader::v2::parse_generator (cyclomatic 26) engine/baml-lib/baml-core/src/validate/generator_loader/v2.rs:62— internal_baml_core::validate::generator_loader::v2::parse_generator has cyclomatic complexity 26 (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.
internal_baml_core::validate::validation_pipeline::validations::expr_fns::validate_expression (cyclomatic 26) engine/baml-lib/baml-core/src/validate/validation_pipeline/validations/expr_fns.rs:286— internal_baml_core::validate::validation_pipeline::validations::expr_fns::validate_expression has cyclomatic complexity 26 (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.
internal_baml_core::validate::validation_pipeline::validations::expr_fns::validate_stmt (cyclomatic 22) engine/baml-lib/baml-core/src/validate/validation_pipeline/validations/expr_fns.rs:158— internal_baml_core::validate::validation_pipeline::validations::expr_fns::validate_stmt has cyclomatic complexity 22 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
BexHeap::fixup_object_references (cognitive 78) baml_language/crates/bex_heap/src/gc.rs:1007— BexHeap::fixup_object_references has cognitive complexity 78 (threshold 15). Drivers by points: if/else 21 (48 pts), loops 12 (27 pts), boolean chains 2, match/switch 1 (nesting depth added 42). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
BexHeap::add_references_to_worklist (cognitive 45) baml_language/crates/bex_heap/src/gc.rs:776— BexHeap::add_references_to_worklist has cognitive complexity 45 (threshold 15). Drivers by points: if/else 15 (33 pts), loops 5 (10 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.
BexHeap::collect_young_references (cognitive 45) baml_language/crates/bex_heap/src/gc.rs:1329— BexHeap::collect_young_references has cognitive complexity 45 (threshold 15). Drivers by points: if/else 17 (33 pts), boolean chains 11, match/switch 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.
BexHeap::scan_unhandled_spawn_errors (cognitive 23) baml_language/crates/bex_heap/src/gc.rs:400— BexHeap::scan_unhandled_spawn_errors has cognitive complexity 23 (threshold 15). Drivers by points: if/else 4 (16 pts), loops 3 (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.
BexHeap::resolve_function_constants (cognitive 21) baml_language/crates/bex_heap/src/heap.rs:477— BexHeap::resolve_function_constants has cognitive complexity 21 (threshold 15). Drivers by points: if/else 5 (11 pts), loops 3 (7 pts), match/switch 1 (3 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
OutputFormatContent::render_impl (cognitive 67) baml_language/crates/sys_ops/src/output_format.rs:360— OutputFormatContent::render_impl has cognitive complexity 67 (threshold 15). Drivers by points: if/else 32 (40 pts), loops 7 (15 pts), match/switch 3 (7 pts), boolean chains 5 (nesting depth added 20). 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.
OutputFormatContent::render (cognitive 65) engine/baml-lib/jinja-runtime/src/output_format/types.rs:823— OutputFormatContent::render has cognitive complexity 65 (threshold 15). Drivers by points: if/else 31 (47 pts), loops 6 (9 pts), match/switch 4 (6 pts), boolean chains 3 (nesting depth added 21). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
OutputFormatContent::render_type_hoisted (cognitive 31) baml_language/crates/sys_ops/src/output_format.rs:771— OutputFormatContent::render_type_hoisted has cognitive complexity 31 (threshold 15). Drivers by points: if/else 13 (19 pts), match/switch 5 (8 pts), boolean chains 2, loops 1 (2 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
OutputFormatContent::render_class_hoisted (cognitive 19) baml_language/crates/sys_ops/src/output_format.rs:1047— OutputFormatContent::render_class_hoisted has cognitive complexity 19 (threshold 15). Drivers by points: if/else 8 (11 pts), loops 4 (8 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.
OutputFormatContent::inner_type_render (cognitive 19) engine/baml-lib/jinja-runtime/src/output_format/types.rs:685— OutputFormatContent::inner_type_render has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (11 pts), match/switch 4 (7 pts), boolean chains 1 (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.
bex_vm_types::head_walk::visit_object_heads (cognitive 57) baml_language/crates/bex_vm_types/src/head_walk.rs:186— bex_vm_types::head_walk::visit_object_heads has cognitive complexity 57 (threshold 15). Drivers by points: loops 22 (53 pts), if/else 1 (3 pts), match/switch 1 (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. This shape REPEATS in the file: one other method here (bex_vm_types::head_walk::visit_object_heads_mut) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
bex_vm_types::head_walk::visit_object_heads_mut (cognitive 57) baml_language/crates/bex_vm_types/src/head_walk.rs:188— bex_vm_types::head_walk::visit_object_heads_mut has cognitive complexity 57 (threshold 15). Drivers by points: loops 22 (53 pts), if/else 1 (3 pts), match/switch 1 (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. This shape REPEATS in the file: one other method here (bex_vm_types::head_walk::visit_object_heads) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
bex_vm_types::types::box_compile_time_floats (cognitive 24) baml_language/crates/bex_vm_types/src/types.rs:838— bex_vm_types::types::box_compile_time_floats has cognitive complexity 24 (threshold 15). Drivers by points: if/else 5 (14 pts), loops 6 (10 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
bex_vm_types::head_walk::visit_function_heads (cognitive 16) baml_language/crates/bex_vm_types/src/head_walk.rs:62— bex_vm_types::head_walk::visit_function_heads has cognitive complexity 16 (threshold 15). Drivers by points: loops 7 (14 pts), match/switch 1 (2 pts) (nesting depth added 8). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline. This shape REPEATS in the file: one other method here (bex_vm_types::head_walk::visit_function_heads_mut) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
bex_vm_types::head_walk::visit_function_heads_mut (cognitive 16) baml_language/crates/bex_vm_types/src/head_walk.rs:63— bex_vm_types::head_walk::visit_function_heads_mut has cognitive complexity 16 (threshold 15). Drivers by points: loops 7 (14 pts), match/switch 1 (2 pts) (nesting depth added 8). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline. This shape REPEATS in the file: one other method here (bex_vm_types::head_walk::visit_function_heads) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
baml_compiler2_visualization::control_flow::flatten::compute_required_nodes (cognitive 36) baml_language/crates/baml_compiler2_visualization/src/control_flow/flatten.rs:219— baml_compiler2_visualization::control_flow::flatten::compute_required_nodes has cognitive complexity 36 (threshold 15). Drivers by points: if/else 11 (25 pts), loops 7 (8 pts), boolean chains 3 (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.
baml_compiler2_visualization::control_flow::flatten::prepare_control_flow_graph_for_visualization (cognitive 34) baml_language/crates/baml_compiler2_visualization/src/control_flow/flatten.rs:34— baml_compiler2_visualization::control_flow::flatten::prepare_control_flow_graph_for_visualization has cognitive complexity 34 (threshold 15). Drivers by points: if/else 6 (16 pts), loops 10 (16 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.
baml_compiler2_visualization::control_flow::from_ast::collect_callee_names_expr (cognitive 32) baml_language/crates/baml_compiler2_visualization/src/control_flow/from_ast.rs:863— baml_compiler2_visualization::control_flow::from_ast::collect_callee_names_expr has cognitive complexity 32 (threshold 15). Drivers by points: loops 9 (18 pts), if/else 5 (11 pts), match/switch 2 (3 pts) (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.
baml_compiler2_visualization::control_flow::flatten::filter_graph (cognitive 27) baml_language/crates/baml_compiler2_visualization/src/control_flow/flatten.rs:343— baml_compiler2_visualization::control_flow::flatten::filter_graph has cognitive complexity 27 (threshold 15). Drivers by points: if/else 7 (19 pts), loops 4 (8 pts) (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
baml_compiler2_visualization::control_flow::flatten::hoist_branch_arms (cognitive 24) baml_language/crates/baml_compiler2_visualization/src/control_flow/flatten.rs:418— baml_compiler2_visualization::control_flow::flatten::hoist_branch_arms has cognitive complexity 24 (threshold 15). Drivers by points: if/else 5 (12 pts), loops 5 (12 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.
bex_engine::host_instrumentation::capture_callback_inputs::copy (cognitive 34) baml_language/crates/bex_engine/src/host_instrumentation.rs:494— bex_engine::host_instrumentation::capture_callback_inputs::copy has cognitive complexity 34 (threshold 15). Drivers by points: if/else 13 (27 pts), loops 3 (6 pts), match/switch 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.
bex_engine::conversion::coerce_arg_to_declared_type_with_aliases (cognitive 33) baml_language/crates/bex_engine/src/conversion.rs:4845— bex_engine::conversion::coerce_arg_to_declared_type_with_aliases has cognitive complexity 33 (threshold 15). Drivers by points: if/else 12 (19 pts), match/switch 5 (10 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.
bex_engine::conversion::find_matching_member (cognitive 24) baml_language/crates/bex_engine/src/conversion.rs:3078— bex_engine::conversion::find_matching_member has cognitive complexity 24 (threshold 15). Drivers by points: if/else 6 (11 pts), boolean chains 5, loops 5, 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.
bex_engine::conversion::walk_var_positions (cognitive 17) baml_language/crates/bex_engine/src/conversion.rs:2808— bex_engine::conversion::walk_var_positions has cognitive complexity 17 (threshold 15). Drivers by points: loops 4 (9 pts), if/else 3 (5 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.
bex_engine::conversion::portable_type_def (cognitive 16) baml_language/crates/bex_engine/src/conversion.rs:307— bex_engine::conversion::portable_type_def has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (10 pts), loops 3 (5 pts), match/switch 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.
RunArgs::validate_scripts (cognitive 27) baml_language/crates/baml_cli/src/run_command.rs:1276— RunArgs::validate_scripts has cognitive complexity 27 (threshold 15). Drivers by points: if/else 10 (18 pts), loops 2 (5 pts), boolean chains 2, match/switch 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.
RunArgs::print_list_debug (cognitive 25) baml_language/crates/baml_cli/src/run_command.rs:1527— RunArgs::print_list_debug has cognitive complexity 25 (threshold 15). Drivers by points: if/else 12 (18 pts), loops 3 (6 pts), boolean chains 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
RunArgs::run_with_reporter (cognitive 16) baml_language/crates/baml_cli/src/run_command.rs:391— RunArgs::run_with_reporter has cognitive complexity 16 (threshold 15). Drivers by points: if/else 11 (14 pts), boolean chains 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.
RunArgs::run_single_target (cognitive 16) baml_language/crates/baml_cli/src/run_command.rs:486— RunArgs::run_single_target has cognitive complexity 16 (threshold 15). Drivers by points: if/else 10 (12 pts), boolean chains 2, match/switch 1 (2 pts) (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
RunArgs::run_expression (cognitive 16) baml_language/crates/baml_cli/src/run_command.rs:1021— RunArgs::run_expression has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (10 pts), match/switch 5, boolean chains 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.
baml_query_profiles::relations::calls_rows (cognitive 26) baml_language/crates/baml_query_profiles/src/relations.rs:1026— baml_query_profiles::relations::calls_rows has cognitive complexity 26 (threshold 15). Drivers by points: if/else 8 (16 pts), match/switch 2 (7 pts), loops 2 (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.
baml_query_profiles::relations::threads_rows (cognitive 22) baml_language/crates/baml_query_profiles/src/relations.rs:548— baml_query_profiles::relations::threads_rows has cognitive complexity 22 (threshold 15). Drivers by points: if/else 9 (17 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.
baml_query_profiles::relations::segments_rows (cognitive 20) baml_language/crates/baml_query_profiles/src/relations.rs:1531— baml_query_profiles::relations::segments_rows has cognitive complexity 20 (threshold 15). Drivers by points: match/switch 3 (14 pts), loops 3 (6 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.
baml_query_profiles::relations::errors_rows (cognitive 17) baml_language/crates/baml_query_profiles/src/relations.rs:1176— baml_query_profiles::relations::errors_rows has cognitive complexity 17 (threshold 15). Drivers by points: match/switch 3 (9 pts), loops 3 (5 pts), if/else 1 (3 pts) (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.
baml_query_profiles::relations::execution_id_targets (cognitive 16) baml_language/crates/baml_query_profiles/src/relations.rs:90— baml_query_profiles::relations::execution_id_targets has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (8 pts), match/switch 3 (6 pts), loops 1 (2 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.
Duplicated block (12–14 lines × 2) baml_language/crates/baml_compiler2_hir_ty/src/interfaces/impl_rules.rs:792— baml_language/crates/baml_compiler2_hir_ty/src/interfaces/impl_rules.rs:792-805 | baml_language/crates/baml_compiler2_hir_ty/src/interfaces/impl_rules.rs:815-826 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (12–14 lines × 2) baml_language/crates/baml_compiler2_mir/src/lower.rs:7674— baml_language/crates/baml_compiler2_mir/src/lower.rs:7674-7687 | baml_language/crates/baml_compiler2_mir/src/lower.rs:7704-7715 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (12–14 lines × 2) baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs:149— baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs:149-160 | engine/baml-lib/jsonish/src/jsonish/parser/fixing_parser/json_parse_state.rs:155-168 — before extracting anything, compare `baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs` and `engine/baml-lib/jsonish/src/jsonish/parser/fixing_parser/json_parse_state.rs` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 575 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (12–14 lines × 2) engine/language_server/src/server/api/notifications/did_change.rs:38— engine/language_server/src/server/api/notifications/did_change.rs:38-51 | engine/language_server/src/server/api/notifications/did_save_text_document.rs:37-48 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (12–14 lines × 2) baml_language/sdks/java/baml_bridge/src/main/java/baml_bridge/internal/NativeLibraryLoader.java:126— baml_language/sdks/java/baml_bridge/src/main/java/baml_bridge/internal/NativeLibraryLoader.java:126-139 | baml_language/sdks/java/gradle-plugin/src/main/java/com/boundaryml/baml/gradle/BamlPlugin.java:332-343 — 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. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
Duplicated block (10–11 lines × 2) baml_language/crates/baml_compiler2_hir_ty/src/infer/pat.rs:1323— baml_language/crates/baml_compiler2_hir_ty/src/infer/pat.rs:1323-1333 | baml_language/crates/baml_compiler2_hir_ty/src/infer/pat.rs:1366-1375 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (10–11 lines × 2) baml_language/crates/baml_compiler2_visualization/src/control_flow/flatten.rs:99— baml_language/crates/baml_compiler2_visualization/src/control_flow/flatten.rs:99-109 | baml_language/crates/baml_compiler2_visualization/src/control_flow/flatten.rs:481-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 (10–11 lines × 2) baml_language/crates/baml_ide/src/resolve.rs:460— baml_language/crates/baml_ide/src/resolve.rs:460-469 | baml_language/crates/baml_ide/src/usages.rs:404-414 — 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 (10–11 lines × 2) baml_language/crates/bex_vm/src/vm.rs:11589— baml_language/crates/bex_vm/src/vm.rs:11589-11598 | baml_language/crates/bex_vm/src/vm.rs:11652-11662 — both copies are in the same file, so extract the block into 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–11 lines × 2) engine/baml-schema-wasm/src/runtime_wasm/mod.rs:1177— engine/baml-schema-wasm/src/runtime_wasm/mod.rs:1177-1187 | engine/baml-schema-wasm/src/runtime_wasm/mod.rs:1231-1240 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (9–10 lines × 2) baml_language/crates/baml_compiler2_mir/src/lower.rs:11889— baml_language/crates/baml_compiler2_mir/src/lower.rs:11889-11897 | baml_language/crates/baml_compiler2_mir/src/lower.rs:11932-11941 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (9–10 lines × 2) baml_language/crates/baml_fmt/src/ast/declarations.rs:402— baml_language/crates/baml_fmt/src/ast/declarations.rs:402-411 | baml_language/crates/baml_fmt/src/ast/expressions.rs:2794-2802 — before extracting anything, compare `baml_language/crates/baml_fmt/src/ast/declarations.rs` and `baml_language/crates/baml_fmt/src/ast/expressions.rs` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 124 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (9–10 lines × 2) baml_language/crates/bex_heap/src/gc.rs:459— baml_language/crates/bex_heap/src/gc.rs:459-468 | baml_language/crates/bex_heap/src/gc.rs:498-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 (9–10 lines × 2) baml_language/crates/btel_reader/src/value/span.rs:114— baml_language/crates/btel_reader/src/value/span.rs:114-122 | baml_language/crates/btel_snapshot/src/decode.rs:1346-1355 — 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–10 lines × 2) engine/baml-compiler/src/thir/typecheck.rs:1503— engine/baml-compiler/src/thir/typecheck.rs:1503-1511 | engine/baml-compiler/src/thir/typecheck.rs:1517-1526 — both copies are in the same file, so extract the block into 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 × 4) baml_language/crates/baml_compiler2_visualization/src/control_flow/from_ast.rs:321— baml_language/crates/baml_compiler2_visualization/src/control_flow/from_ast.rs:321-329 | baml_language/crates/baml_compiler2_visualization/src/control_flow/from_ast.rs:394-402 | baml_language/crates/baml_compiler2_visualization/src/control_flow/from_ast.rs:472-480 | baml_language/crates/baml_compiler2_visualization/src/control_flow/from_ast.rs:532-540 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (9 lines × 4) baml_language/crates/baml_db/src/check.rs:557— baml_language/crates/baml_db/src/check.rs:557-567 | baml_language/crates/baml_db/src/check.rs:702-710 | baml_language/crates/baml_db/src/check.rs:754-762 | baml_language/crates/baml_db/src/check.rs:778-786 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (9 lines × 4) baml_language/crates/bex_sap/src/deserializer/coercer/coerce_primitive.rs:193— baml_language/crates/bex_sap/src/deserializer/coercer/coerce_primitive.rs:193-201 | baml_language/crates/bex_sap/src/deserializer/coercer/coerce_primitive.rs:374-382 | baml_language/crates/bex_sap/src/deserializer/coercer/coerce_primitive.rs:495-503 | baml_language/crates/bex_sap/src/deserializer/coercer/coerce_primitive.rs:605-613 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (9 lines × 4) engine/baml-lib/llm-client/src/clients/anthropic.rs:75— engine/baml-lib/llm-client/src/clients/anthropic.rs:75-83 | engine/baml-lib/llm-client/src/clients/aws_bedrock.rs:141-149 | engine/baml-lib/llm-client/src/clients/google_ai.rs:74-82 | engine/baml-lib/llm-client/src/clients/vertex.rs:214-222 — before extracting anything, compare `engine/baml-lib/llm-client/src/clients/anthropic.rs` and `engine/baml-lib/llm-client/src/clients/google_ai.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 43 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (9 lines × 4) engine/baml-lib/llm-client/src/clients/helpers.rs:877— engine/baml-lib/llm-client/src/clients/helpers.rs:877-885 | engine/baml-lib/llm-client/src/clients/helpers.rs:894-902 | engine/baml-lib/llm-client/src/clients/helpers.rs:911-919 | engine/baml-lib/llm-client/src/clients/helpers.rs:928-936 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (7–8 lines × 2) baml_language/crates/baml_compiler2_hir/src/item_data/functions.rs:364— baml_language/crates/baml_compiler2_hir/src/item_data/functions.rs:364-370 | baml_language/crates/baml_compiler2_hir/src/item_data/impls.rs:146-153 — 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–8 lines × 2) baml_language/crates/baml_fmt/src/ast/expressions.rs:4447— baml_language/crates/baml_fmt/src/ast/expressions.rs:4447-4453 | baml_language/crates/baml_fmt/src/ast/expressions.rs:4521-4528 — both copies are in the same file, so extract the block into 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–8 lines × 2) baml_language/crates/baml_ide/src/describe.rs:849— baml_language/crates/baml_ide/src/describe.rs:849-856 | baml_language/crates/baml_ide/src/describe.rs:961-967 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (7–8 lines × 2) baml_language/crates/bridge_wasm/src/runs.rs:965— baml_language/crates/bridge_wasm/src/runs.rs:965-972 | baml_language/crates/bridge_wasm/src/runs.rs:1004-1010 — both copies are in the same file, so extract the block into 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–8 lines × 2) engine/baml-runtime/src/optimize/applier.rs:333— engine/baml-runtime/src/optimize/applier.rs:333-340 | engine/baml-runtime/src/optimize/applier.rs:399-405 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Swallowed exception (caught, then discarded) baml_language/sdk_tests/crates/csharp/generics/Program.cs:166— `catch (TException)` does nothing with the exception it caught — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch. Log it through whatever this codebase already uses to report problems, or let it propagate; if one specific failure genuinely cannot matter, catch exactly that exception type and say why in a comment on the catch.
Swallowed exception (caught, then discarded) baml_language/sdk_tests/crates/csharp/primitive_edges/Program.cs:167— `catch (TException)` does nothing with the exception it caught — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch. Log it through whatever this codebase already uses to report problems, or let it propagate; if one specific failure genuinely cannot matter, catch exactly that exception type and say why in a comment on the catch.
Swallowed exception (caught, then discarded) baml_language/sdk_tests/crates/csharp/streaming/Program.cs:418— `catch (SocketException) when (…)` does nothing with the exception it caught — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch. Log it through whatever this codebase already uses to report problems, or let it propagate; if one specific failure genuinely cannot matter, catch exactly that exception type and say why in a comment on the catch.
Swallowed exception (caught, then discarded) baml_language/sdk_tests/crates/csharp/type_roundtrips/Program.cs:153— `catch (TException)` does nothing with the exception it caught — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch. Log it through whatever this codebase already uses to report problems, or let it propagate; if one specific failure genuinely cannot matter, catch exactly that exception type and say why in a comment on the catch.
Swallowed exception (caught, then discarded) baml_language/sdks/csharp/bridge_csharp/tools/Baml.NuGetNormalizer/Program.cs:664— `catch (InvalidDataException)` does nothing with the exception it caught — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch. Log it through whatever this codebase already uses to report problems, or let it propagate; if one specific failure genuinely cannot matter, catch exactly that exception type and say why in a comment on the catch.
sdkgen_cpp::translate_ty (cyclomatic 58) baml_language/sdks/cpp/sdkgen_cpp/src/lib.rs:1507— sdkgen_cpp::translate_ty has cyclomatic complexity 58 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
sdkgen_cpp::to_source_code_with_optional_metadata (cyclomatic 47) baml_language/sdks/cpp/sdkgen_cpp/src/lib.rs:68— sdkgen_cpp::to_source_code_with_optional_metadata 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.
sdkgen_cpp::render_header (cyclomatic 20) baml_language/sdks/cpp/sdkgen_cpp/src/lib.rs:2009— sdkgen_cpp::render_header has cyclomatic complexity 20 (threshold 15). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
sdkgen_cpp::emit_callable (cyclomatic 16) baml_language/sdks/cpp/sdkgen_cpp/src/lib.rs:1185— sdkgen_cpp::emit_callable 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.
BexHeap::fixup_object_references (cyclomatic 55) baml_language/crates/bex_heap/src/gc.rs:1007— BexHeap::fixup_object_references has cyclomatic complexity 55 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
BexHeap::collect_young_references (cyclomatic 48) baml_language/crates/bex_heap/src/gc.rs:1329— BexHeap::collect_young_references 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.
BexHeap::add_references_to_worklist (cyclomatic 41) baml_language/crates/bex_heap/src/gc.rs:776— BexHeap::add_references_to_worklist has cyclomatic complexity 41 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
BexHeap::verify_object_invariants (cyclomatic 17) baml_language/crates/bex_heap/src/heap_debugger/real.rs:275— BexHeap::verify_object_invariants 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.
bex_project::runtime_compile::lower_session_submission (cyclomatic 40) baml_language/crates/bex_project/src/runtime_compile.rs:1282— bex_project::runtime_compile::lower_session_submission 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.
bex_project::runtime_compile::rewrite_identifiers (cyclomatic 29) baml_language/crates/bex_project/src/runtime_compile.rs:1032— bex_project::runtime_compile::rewrite_identifiers has cyclomatic complexity 29 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
bex_project::runtime_compile::projected_interface (cyclomatic 20) baml_language/crates/bex_project/src/runtime_compile.rs:152— bex_project::runtime_compile::projected_interface has cyclomatic complexity 20 (threshold 15). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
bex_project::runtime_compile::owned_diagnostic (cyclomatic 18) baml_language/crates/bex_project/src/runtime_compile.rs:533— bex_project::runtime_compile::owned_diagnostic has cyclomatic complexity 18 (threshold 15). Most of this is not in the body itself: 7 of the 18 points are its own statements and the rest belongs to 2 function items inside it that branch (highlight_kind, owned_text). 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.
NormalTy::from_interned (cyclomatic 34) baml_language/crates/baml_type/src/normalize.rs:3057— NormalTy::from_interned 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.
NormalTy::from_ty (cyclomatic 33) baml_language/crates/baml_type/src/normalize.rs:1299— NormalTy::from_ty has cyclomatic complexity 33 (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.
NormalTy::is_subtype_of_inner (cyclomatic 32) baml_language/crates/baml_type/src/normalize.rs:1963— NormalTy::is_subtype_of_inner 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.
NormalTy::is_disjoint_from (cyclomatic 21) baml_language/crates/baml_type/src/normalize.rs:947— NormalTy::is_disjoint_from 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: NormalTy::legacy_render (cyclomatic 30) 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.
SemanticIndexBuilder::walk_expr_children (cyclomatic 32) baml_language/crates/baml_compiler2_hir/src/builder.rs:601— SemanticIndexBuilder::walk_expr_children 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.
SemanticIndexBuilder::collect_pattern_names (cyclomatic 19) baml_language/crates/baml_compiler2_hir/src/builder.rs:907— SemanticIndexBuilder::collect_pattern_names 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. This is NOT this file's highest cyclomatic complexity: SemanticIndexBuilder::render_type_expr (cyclomatic 23) 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.
SemanticIndexBuilder::walk_stmt (cyclomatic 18) baml_language/crates/baml_compiler2_hir/src/builder.rs:451— SemanticIndexBuilder::walk_stmt has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This is NOT this file's highest cyclomatic complexity: SemanticIndexBuilder::render_type_expr (cyclomatic 23) 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.
SemanticIndexBuilder::collect_invalid_builtin_throw_types (cyclomatic 16) baml_language/crates/baml_compiler2_hir/src/builder.rs:1948— SemanticIndexBuilder::collect_invalid_builtin_throw_types has cyclomatic complexity 16 (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: SemanticIndexBuilder::render_type_expr (cyclomatic 23) 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.
sdkgen_java::translate_ty::translate_ty (cyclomatic 30) baml_language/sdks/java/sdkgen_java/src/translate_ty.rs:111— sdkgen_java::translate_ty::translate_ty has cyclomatic complexity 30 (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.
sdkgen_java::to_source_code_internal (cyclomatic 28) baml_language/sdks/java/sdkgen_java/src/lib.rs:107— sdkgen_java::to_source_code_internal 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.
sdkgen_java::emit::render_callable_pair (cyclomatic 27) baml_language/sdks/java/sdkgen_java/src/emit.rs:775— sdkgen_java::emit::render_callable_pair has cyclomatic complexity 27 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
sdkgen_java::emit::render_class (cyclomatic 19) baml_language/sdks/java/sdkgen_java/src/emit.rs:351— sdkgen_java::emit::render_class has cyclomatic complexity 19 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
baml_type::unify::unify_into_at (cyclomatic 23) baml_language/crates/baml_type/src/unify.rs:549— baml_type::unify::unify_into_at 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.
baml_type::normalize::mu::algebra_pass (cyclomatic 18) baml_language/crates/baml_type/src/normalize/mu.rs:860— baml_type::normalize::mu::algebra_pass 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.
baml_type::normalize::mu::convert (cyclomatic 18) baml_language/crates/baml_type/src/normalize/mu.rs:1249— baml_type::normalize::mu::convert 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.
baml_type::decl_cycles::extract_type_alias_deps::visit (cyclomatic 16) baml_language/crates/baml_type/src/decl_cycles.rs:116— baml_type::decl_cycles::extract_type_alias_deps::visit has cyclomatic complexity 16 (threshold 15). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
LowerCtx::lower_path (cognitive 61) baml_language/crates/baml_compiler2_hir_ty/src/lower.rs:798— LowerCtx::lower_path has cognitive complexity 61 (threshold 15). Drivers by points: if/else 21 (42 pts), match/switch 4 (8 pts), boolean chains 6, loops 2 (5 pts) (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.
LowerCtx::lower_definition (cognitive 32) baml_language/crates/baml_compiler2_hir_ty/src/lower.rs:1137— LowerCtx::lower_definition has cognitive complexity 32 (threshold 15). Drivers by points: if/else 7 (21 pts), loops 3 (9 pts), boolean chains 1, match/switch 1 (nesting depth added 20). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
LowerCtx::lower_exported_type (cognitive 27) baml_language/crates/baml_compiler2_hir_ty/src/lower.rs:1285— LowerCtx::lower_exported_type has cognitive complexity 27 (threshold 15). Drivers by points: if/else 7 (21 pts), loops 2 (5 pts), match/switch 1 (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.
LowerCtx::lower_type_ref_inner (cognitive 17) baml_language/crates/baml_compiler2_hir_ty/src/lower.rs:441— LowerCtx::lower_type_ref_inner has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (11 pts), match/switch 3 (5 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.
btel_bcs::delivery::run_worker (cognitive 57) baml_language/crates/btel_bcs/src/delivery.rs:1777— btel_bcs::delivery::run_worker has cognitive complexity 57 (threshold 15). Drivers by points: if/else 11 (31 pts), match/switch 6 (17 pts), loops 4 (7 pts), boolean chains 2 (nesting depth added 34). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
btel_bcs::plan::validate_response (cognitive 34) baml_language/crates/btel_bcs/src/plan.rs:85— btel_bcs::plan::validate_response has cognitive complexity 34 (threshold 15). Drivers by points: if/else 10 (21 pts), loops 5 (7 pts), boolean chains 6 (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.
btel_bcs::delivery::assemble (cognitive 23) baml_language/crates/btel_bcs/src/delivery.rs:1473— btel_bcs::delivery::assemble has cognitive complexity 23 (threshold 15). Drivers by points: if/else 6 (10 pts), loops 5 (7 pts), match/switch 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.
btel_bcs::plan::validate_proposal (cognitive 17) baml_language/crates/btel_bcs/src/plan.rs:13— btel_bcs::plan::validate_proposal has cognitive complexity 17 (threshold 15). Drivers by points: if/else 5 (10 pts), loops 2 (3 pts), boolean chains 2, match/switch 1 (2 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.
btel_snapshot::host::add (cognitive 52) baml_language/crates/btel_snapshot/src/host.rs:62— btel_snapshot::host::add has cognitive complexity 52 (threshold 15). Drivers by points: if/else 19 (42 pts), match/switch 3 (6 pts), loops 2 (4 pts) (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.
btel_snapshot::decode::decode (cognitive 23) baml_language/crates/btel_snapshot/src/decode.rs:342— btel_snapshot::decode::decode has cognitive complexity 23 (threshold 15). Drivers by points: if/else 14 (18 pts), loops 3, match/switch 2 (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
btel_snapshot::definition::encode (cognitive 21) baml_language/crates/btel_snapshot/src/definition.rs:516— btel_snapshot::definition::encode has cognitive complexity 21 (threshold 15). Drivers by points: match/switch 4 (8 pts), if/else 3 (7 pts), loops 3 (5 pts), boolean chains 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
btel_snapshot::memory::type_bytes (cognitive 16) baml_language/crates/btel_snapshot/src/memory.rs:118— btel_snapshot::memory::type_bytes has cognitive complexity 16 (threshold 15). Drivers by points: loops 3 (7 pts), match/switch 2 (5 pts), if/else 1 (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.
WasmRuntime::run_tests (cognitive 47) engine/baml-schema-wasm/src/runtime_wasm/mod.rs:2027— WasmRuntime::run_tests has cognitive complexity 47 (threshold 15). Drivers by points: if/else 9 (24 pts), match/switch 3 (12 pts), loops 4 (11 pts) (nesting depth added 31). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
WasmRuntime::list_testcases (cognitive 21) engine/baml-schema-wasm/src/runtime_wasm/mod.rs:1823— WasmRuntime::list_testcases has cognitive complexity 21 (threshold 15). Drivers by points: match/switch 12 (17 pts), boolean chains 2, if/else 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.
WasmRuntime::get_entity_at_position (cognitive 20) engine/baml-schema-wasm/src/runtime_wasm/mod.rs:1731— WasmRuntime::get_entity_at_position has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (15 pts), loops 2 (4 pts), boolean chains 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
WasmRuntime::get_function_at_position (cognitive 17) engine/baml-schema-wasm/src/runtime_wasm/mod.rs:1667— WasmRuntime::get_function_at_position has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (14 pts), 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.
baml_compiler_syntax::ast::apply_block_tag_whitespace_rule::alone_on_line_strips (cognitive 40) baml_language/crates/baml_compiler_syntax/src/ast.rs:1204— baml_compiler_syntax::ast::apply_block_tag_whitespace_rule::alone_on_line_strips has cognitive complexity 40 (threshold 15). Drivers by points: if/else 9 (30 pts), boolean chains 4, match/switch 2 (4 pts), loops 2 (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. This shape REPEATS in the file: one other method here (baml_compiler_syntax::ast::apply_block_tag_whitespace_rule) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
baml_compiler_syntax::traversal::boundary_token (cognitive 20) baml_language/crates/baml_compiler_syntax/src/traversal.rs:89— baml_compiler_syntax::traversal::boundary_token has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (15 pts), loops 2 (3 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.
baml_compiler_syntax::ast::validate_block_structure (cognitive 18) baml_language/crates/baml_compiler_syntax/src/ast.rs:1436— baml_compiler_syntax::ast::validate_block_structure has cognitive complexity 18 (threshold 15). Drivers by points: match/switch 6 (16 pts), loops 2 (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.
baml_compiler_syntax::ast::apply_block_tag_whitespace_rule (cognitive 16) baml_language/crates/baml_compiler_syntax/src/ast.rs:1180— baml_compiler_syntax::ast::apply_block_tag_whitespace_rule has cognitive complexity 16 (threshold 15). Drivers by points: if/else 15 (44 pts), boolean chains 4, loops 4, match/switch 2 (4 pts) (nesting depth added 31). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: one other method here (baml_compiler_syntax::ast::apply_block_tag_whitespace_rule::alone_on_line_strips) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
sdkgen_java::to_source_code_internal (cognitive 39) baml_language/sdks/java/sdkgen_java/src/lib.rs:107— sdkgen_java::to_source_code_internal has cognitive complexity 39 (threshold 15). Drivers by points: if/else 13 (20 pts), loops 13 (15 pts), match/switch 2 (4 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.
sdkgen_java::emit::render_callable_pair (cognitive 35) baml_language/sdks/java/sdkgen_java/src/emit.rs:775— sdkgen_java::emit::render_callable_pair has cognitive complexity 35 (threshold 15). Drivers by points: if/else 18 (21 pts), match/switch 6 (9 pts), boolean chains 3, loops 2 (nesting depth added 6). 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.
sdkgen_java::emit::render_class (cognitive 20) baml_language/sdks/java/sdkgen_java/src/emit.rs:351— sdkgen_java::emit::render_class has cognitive complexity 20 (threshold 15). Drivers by points: if/else 11, loops 5, match/switch 2 (3 pts), boolean chains 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.
sdkgen_java::emit::typed_callable_expr (cognitive 19) baml_language/sdks/java/sdkgen_java/src/emit.rs:1448— sdkgen_java::emit::typed_callable_expr has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (9 pts), match/switch 4 (8 pts), loops 2 (nesting depth added 6). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
language_server::server::api::diagnostics::project_diagnostics (cognitive 38) engine/language_server/src/server/api/diagnostics.rs:130— language_server::server::api::diagnostics::project_diagnostics has cognitive complexity 38 (threshold 15). Drivers by points: if/else 9 (20 pts), match/switch 6 (11 pts), loops 4 (7 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.
language_server::baml_project::file_utils::gather_files (cognitive 35) engine/language_server/src/baml_project/file_utils.rs:67— language_server::baml_project::file_utils::gather_files has cognitive complexity 35 (threshold 15). Drivers by points: if/else 8 (29 pts), loops 2 (4 pts), match/switch 1 (2 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.
language_server::baml_project::get_dummy_value (cognitive 19) engine/language_server/src/baml_project/mod.rs:1551— language_server::baml_project::get_dummy_value has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (12 pts), match/switch 4 (7 pts) (nesting depth added 9). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
language_server::baml_project::common_version_up_to_patch (cognitive 17) engine/language_server/src/baml_project/mod.rs:1487— language_server::baml_project::common_version_up_to_patch has cognitive complexity 17 (threshold 15). Drivers by points: if/else 10 (16 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.
Generator::rvalue (cognitive 32) baml_language/crates/baml_compiler2_rust/src/codegen/expr.rs:18— Generator::rvalue has cognitive complexity 32 (threshold 15). Drivers by points: if/else 16 (31 pts), match/switch 1 (nesting depth added 15). 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.
Generator::compiled_call (cognitive 19) baml_language/crates/baml_compiler2_rust/src/codegen/call.rs:76— Generator::compiled_call has cognitive complexity 19 (threshold 15). Drivers by points: if/else 10 (11 pts), match/switch 3 (4 pts), boolean chains 2, loops 2 (nesting depth added 2). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
Generator::constant (cognitive 17) baml_language/crates/baml_compiler2_rust/src/codegen/constant.rs:13— Generator::constant has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (12 pts), match/switch 3 (5 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.
Generator::request (cognitive 17) baml_language/crates/baml_compiler2_rust/src/codegen/mod.rs:542— Generator::request has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (15 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.
internal_baml_parser_database::names::resolve_names (cognitive 32) engine/baml-lib/parser-database/src/names/mod.rs:110— internal_baml_parser_database::names::resolve_names has cognitive complexity 32 (threshold 15). Drivers by points: if/else 3 (12 pts), loops 4 (10 pts), match/switch 4 (10 pts) (nesting depth added 21). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
internal_baml_parser_database::types::prompt::process_prompt_ast (cognitive 32) engine/baml-lib/parser-database/src/types/prompt.rs:75— internal_baml_parser_database::types::prompt::process_prompt_ast has cognitive complexity 32 (threshold 15). Drivers by points: if/else 7 (18 pts), match/switch 4 (13 pts), loops 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.
internal_baml_parser_database::types::visit_client (cognitive 23) engine/baml-lib/parser-database/src/types/mod.rs:717— internal_baml_parser_database::types::visit_client has cognitive complexity 23 (threshold 15). Drivers by points: match/switch 10 (20 pts), loops 1 (3 pts) (nesting depth added 12). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own 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.
internal_baml_parser_database::types::resolve_type_alias (cognitive 22) engine/baml-lib/parser-database/src/types/mod.rs:471— internal_baml_parser_database::types::resolve_type_alias has cognitive complexity 22 (threshold 15). Drivers by points: if/else 6 (13 pts), match/switch 4 (8 pts), boolean chains 1 (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.
LeafBody::root_imports_py (cognitive 31) baml_language/sdks/python/rust/sdkgen_python_pydantic2/src/leaf.rs:305— LeafBody::root_imports_py has cognitive complexity 31 (threshold 15). Drivers by points: loops 9 (29 pts), match/switch 1 (2 pts) (nesting depth added 21). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline. This shape REPEATS in the file: one other method here (LeafBody::all_rel_imports_from) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
LeafBody::all_rel_imports_from (cognitive 31) baml_language/sdks/python/rust/sdkgen_python_pydantic2/src/leaf.rs:402— LeafBody::all_rel_imports_from has cognitive complexity 31 (threshold 15). Drivers by points: loops 9 (29 pts), match/switch 1 (2 pts) (nesting depth added 21). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline. This shape REPEATS in the file: one other method here (LeafBody::root_imports_py) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
LeafBody::callback_protocols (cognitive 20) baml_language/sdks/python/rust/sdkgen_python_pydantic2/src/leaf.rs:196— LeafBody::callback_protocols has cognitive complexity 20 (threshold 15). Drivers by points: loops 6 (18 pts), match/switch 1 (2 pts) (nesting depth added 13). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
LeafBody::generic_typevars (cognitive 16) baml_language/sdks/python/rust/sdkgen_python_pydantic2/src/leaf.rs:482— LeafBody::generic_typevars has cognitive complexity 16 (threshold 15). Drivers by points: loops 5 (14 pts), match/switch 1 (2 pts) (nesting depth added 10). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
baml_compiler2_hir::resolve::names_in_scope_at (cognitive 28) baml_language/crates/baml_compiler2_hir/src/resolve.rs:156— baml_compiler2_hir::resolve::names_in_scope_at has cognitive complexity 28 (threshold 15). Drivers by points: loops 6 (16 pts), if/else 5 (11 pts), boolean chains 1 (nesting depth added 16). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
baml_compiler2_hir::resolve::type_names_in_scope_at (cognitive 27) baml_language/crates/baml_compiler2_hir/src/resolve.rs:245— baml_compiler2_hir::resolve::type_names_in_scope_at has cognitive complexity 27 (threshold 15). Drivers by points: loops 5 (16 pts), if/else 4 (8 pts), match/switch 1 (3 pts) (nesting depth added 17). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
baml_compiler2_hir::resolve::resolve_name_at_in_scope (cognitive 23) baml_language/crates/baml_compiler2_hir/src/resolve.rs:58— baml_compiler2_hir::resolve::resolve_name_at_in_scope has cognitive complexity 23 (threshold 15). Drivers by points: if/else 6 (16 pts), loops 3 (5 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.
baml_compiler2_hir::body_type_refs::collect_body_type_refs (cognitive 17) baml_language/crates/baml_compiler2_hir/src/body_type_refs.rs:114— baml_compiler2_hir::body_type_refs::collect_body_type_refs has cognitive complexity 17 (threshold 15). Drivers by points: if/else 3 (8 pts), match/switch 2 (4 pts), loops 3, 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.
sdkgen_typescript_shared::translate_ty::translate_ty (cognitive 24) baml_language/sdks/typescript/sdkgen_typescript_shared/src/translate_ty.rs:49— sdkgen_typescript_shared::translate_ty::translate_ty has cognitive complexity 24 (threshold 15). Drivers by points: if/else 11 (19 pts), loops 2 (4 pts), match/switch 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.
sdkgen_typescript_shared::leaf::write_class_doc (cognitive 21) baml_language/sdks/typescript/sdkgen_typescript_shared/src/leaf.rs:236— sdkgen_typescript_shared::leaf::write_class_doc has cognitive complexity 21 (threshold 15). Drivers by points: if/else 5 (9 pts), loops 3 (8 pts), match/switch 1 (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. This shape REPEATS in the file: one other method here (sdkgen_typescript_shared::leaf::write_enum_doc) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
sdkgen_typescript_shared::leaf::write_enum_doc (cognitive 21) baml_language/sdks/typescript/sdkgen_typescript_shared/src/leaf.rs:274— sdkgen_typescript_shared::leaf::write_enum_doc has cognitive complexity 21 (threshold 15). Drivers by points: if/else 5 (9 pts), loops 3 (8 pts), match/switch 1 (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. This shape REPEATS in the file: one other method here (sdkgen_typescript_shared::leaf::write_class_doc) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
sdkgen_typescript_shared::leaf::render_class_ts (cognitive 19) baml_language/sdks/typescript/sdkgen_typescript_shared/src/leaf.rs:698— sdkgen_typescript_shared::leaf::render_class_ts has cognitive complexity 19 (threshold 15). Drivers by points: if/else 9 (13 pts), loops 4 (5 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.
Duplicated block (28 lines × 2) baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:4104— baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:4104-4131 | baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:4190-4217 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (28 lines × 2) baml_language/crates/bex_sap/src/jsonish/value.rs:130— baml_language/crates/bex_sap/src/jsonish/value.rs:130-157 | engine/baml-lib/jsonish/src/jsonish/value.rs:120-147 — before extracting anything, compare `baml_language/crates/bex_sap/src/jsonish/value.rs` and `engine/baml-lib/jsonish/src/jsonish/value.rs` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 160 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, 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 (28 lines × 2) engine/baml-lib/baml-core/src/validate/validation_pipeline/validations/classes.rs:41— engine/baml-lib/baml-core/src/validate/validation_pipeline/validations/classes.rs:41-68 | engine/baml-lib/baml-core/src/validate/validation_pipeline/validations/enums.rs:17-44 — 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 (28 lines × 2) baml_language/sdks/go/baml_go/media.go:114— baml_language/sdks/go/baml_go/media.go:114-141 | baml_language/sdks/go/baml_go/media.go:162-189 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `baml_language/sdks/go/baml_go/media.go:114` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (25 lines × 2) baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs:134— baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs:134-158 | baml_language/crates/baml_type/src/unify.rs:295-319 — before extracting anything, compare `baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs` and `baml_language/crates/baml_type/src/unify.rs` as WHOLE FILES: this scan already matched 21 separate duplicated blocks between them, totalling at least 418 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, 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 (25 lines × 2) baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs:738— baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs:738-762 | baml_language/crates/baml_type/src/unify.rs:1267-1291 — before extracting anything, compare `baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs` and `baml_language/crates/baml_type/src/unify.rs` as WHOLE FILES: this scan already matched 21 separate duplicated blocks between them, totalling at least 418 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, 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 (25 lines × 2) baml_language/crates/bex_sap/src/jsonish/value.rs:52— baml_language/crates/bex_sap/src/jsonish/value.rs:52-76 | engine/baml-lib/jsonish/src/jsonish/value.rs:44-68 — before extracting anything, compare `baml_language/crates/bex_sap/src/jsonish/value.rs` and `engine/baml-lib/jsonish/src/jsonish/value.rs` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 160 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, 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 (25 lines × 2) engine/baml-runtime/src/internal/llm_client/orchestrator/call.rs:166— engine/baml-runtime/src/internal/llm_client/orchestrator/call.rs:166-190 | engine/baml-runtime/src/internal/llm_client/orchestrator/stream.rs:522-546 — before extracting anything, compare `engine/baml-runtime/src/internal/llm_client/orchestrator/call.rs` and `engine/baml-runtime/src/internal/llm_client/orchestrator/stream.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 90 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (19–20 lines × 2) baml_language/crates/baml_cli/src/pack_command.rs:593— baml_language/crates/baml_cli/src/pack_command.rs:593-611 | baml_language/crates/baml_cli/src/run_command.rs:887-906 — before extracting anything, compare `baml_language/crates/baml_cli/src/pack_command.rs` and `baml_language/crates/baml_cli/src/run_command.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 50 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (19–20 lines × 2) baml_language/crates/baml_compiler2_mir/src/pretty.rs:392— baml_language/crates/baml_compiler2_mir/src/pretty.rs:392-410 | baml_language/crates/baml_compiler2_mir/src/pretty.rs:432-451 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (19–20 lines × 2) baml_language/sdks/python/rust/sdkgen_python_pydantic2/src/leaf.rs:1824— baml_language/sdks/python/rust/sdkgen_python_pydantic2/src/leaf.rs:1824-1842 | baml_language/sdks/python/rust/sdkgen_python_pydantic2/src/leaf.rs:2805-2824 — both copies are in the same file, so extract the block into 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–20 lines × 2) engine/baml-runtime/src/internal/llm_client/primitive/openai/response_handler.rs:822— engine/baml-runtime/src/internal/llm_client/primitive/openai/response_handler.rs:822-840 | engine/baml-runtime/src/internal/llm_client/primitive/openai/response_handler.rs:874-893 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (17 lines × 3) baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:4406— baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:4406-4422 | baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:4583-4599 | baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:4666-4682 — 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) engine/baml-lib/baml-types/src/baml_value.rs:500— engine/baml-lib/baml-types/src/baml_value.rs:500-516 | engine/baml-lib/baml-types/src/baml_value.rs:637-653 | engine/baml-lib/baml-types/src/baml_value.rs:774-790 — 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) engine/generators/languages/python/src/ir_to_py/functions.rs:22— engine/generators/languages/python/src/ir_to_py/functions.rs:22-38 | engine/generators/languages/python/src/ir_to_py/functions.rs:62-78 | engine/generators/languages/ruby/src/ir_to_rb/functions.rs:22-38 — 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 (17 lines × 3) engine/baml-runtime/src/async_interpreter_runtime.rs:634— engine/baml-runtime/src/async_interpreter_runtime.rs:634-650 | engine/baml-runtime/src/async_vm_runtime.rs:938-954 | engine/baml-runtime/src/lib.rs:678-694 — before extracting anything, compare `engine/baml-runtime/src/async_interpreter_runtime.rs` and `engine/baml-runtime/src/async_vm_runtime.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 92 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (15–16 lines × 2) baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:7003— baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:7003-7018 | baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:10032-10046 — both copies are in the same file, so extract the block into 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–16 lines × 2) baml_language/crates/bex_vm/src/package_reflect/runtime_class_builder.rs:958— baml_language/crates/bex_vm/src/package_reflect/runtime_class_builder.rs:958-972 | baml_language/crates/bex_vm/src/package_reflect/type_kinds.rs:542-557 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (15–16 lines × 2) engine/baml-runtime/src/cli/serve/ping.rs:19— engine/baml-runtime/src/cli/serve/ping.rs:19-33 | engine/playground-server/src/handlers/ping.rs:19-34 — 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 (15–16 lines × 2) engine/baml-runtime/src/optimize/applier.rs:224— engine/baml-runtime/src/optimize/applier.rs:224-239 | engine/baml-runtime/src/optimize/applier.rs:458-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 (14–15 lines × 2) baml_language/sdks/python/rust/sdkgen_python_pydantic2/src/leaf.rs:1876— baml_language/sdks/python/rust/sdkgen_python_pydantic2/src/leaf.rs:1876-1890 | baml_language/sdks/python/rust/sdkgen_python_pydantic2/src/leaf.rs:2826-2839 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (14–15 lines × 2) engine/baml-runtime/src/internal/prompt_renderer/render_output_format.rs:148— engine/baml-runtime/src/internal/prompt_renderer/render_output_format.rs:148-162 | engine/baml-runtime/src/internal/prompt_renderer/render_output_format.rs:210-223 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (14–15 lines × 2) engine/generators/languages/ruby/src/ir_to_rb/mod.rs:91— engine/generators/languages/ruby/src/ir_to_rb/mod.rs:91-104 | engine/generators/languages/ruby/src/ir_to_rb/mod.rs:194-208 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (14–15 lines × 2) engine/generators/languages/typescript/src/ir_to_ts/type_aliases.rs:58— engine/generators/languages/typescript/src/ir_to_ts/type_aliases.rs:58-72 | engine/generators/languages/typescript/src/ir_to_ts/type_aliases.rs:104-117 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (12–13 lines × 2) baml_language/crates/baml_compiler2_emit/src/items.rs:1091— baml_language/crates/baml_compiler2_emit/src/items.rs:1091-1102 | baml_language/crates/baml_compiler2_emit/src/package/bodies.rs:97-109 — 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 (12–13 lines × 2) baml_language/sdks/rust/bridge_rust/src/runtime.rs:267— baml_language/sdks/rust/bridge_rust/src/runtime.rs:267-278 | baml_language/sdks/rust/bridge_rust/src/runtime.rs:303-315 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (12–13 lines × 2) engine/baml-runtime/src/internal/llm_client/primitive/aws/aws_client.rs:920— engine/baml-runtime/src/internal/llm_client/primitive/aws/aws_client.rs:920-931 | engine/baml-runtime/src/internal/llm_client/primitive/aws/aws_client.rs:937-949 — both copies are in the same file, so extract the block into 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–13 lines × 2) engine/baml-runtime/src/internal/prompt_renderer/render_output_format.rs:130— engine/baml-runtime/src/internal/prompt_renderer/render_output_format.rs:130-142 | engine/baml-runtime/src/internal/prompt_renderer/render_output_format.rs:194-205 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_compiler2_hir/src/builder.rs:1402— baml_language/crates/baml_compiler2_hir/src/builder.rs:1402-1411 | baml_language/crates/baml_compiler2_hir/src/builder.rs:1627-1639 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_fmt/src/ast/expressions.rs:3416— baml_language/crates/baml_fmt/src/ast/expressions.rs:3416-3428 | baml_language/crates/baml_fmt/src/ast/expressions.rs:3465-3474 — both copies are in the same file, so extract the block into 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) baml_language/crates/baml_query_btel/src/ingest.rs:1113— baml_language/crates/baml_query_btel/src/ingest.rs:1113-1122 | baml_language/crates/baml_query_btel/src/ingest/bulk.rs:593-605 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (10–13 lines × 2) baml_language/sdks/csharp/sdkgen_csharp/src/semantic.rs:3758— baml_language/sdks/csharp/sdkgen_csharp/src/semantic.rs:3758-3767 | baml_language/sdks/csharp/sdkgen_csharp/src/semantic.rs:3873-3885 — both copies are in the same file, so extract the block into 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 × 4) engine/baml-lib/baml-core/src/ir/repr.rs:2555— engine/baml-lib/baml-core/src/ir/repr.rs:2555-2564 | engine/baml-lib/baml-core/src/ir/repr.rs:2585-2594 | engine/baml-lib/baml-core/src/ir/repr.rs:2603-2612 | engine/baml-lib/baml-core/src/ir/repr.rs:2637-2646 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (10 lines × 4) engine/baml-lib/baml-types/src/baml_value.rs:144— engine/baml-lib/baml-types/src/baml_value.rs:144-153 | engine/baml-lib/baml-types/src/baml_value.rs:168-177 | engine/baml-lib/baml-types/src/baml_value.rs:941-950 | engine/baml-lib/baml-types/src/baml_value.rs:967-976 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (10 lines × 4) engine/generators/languages/go/src/ir_to_go/mod.rs:109— engine/generators/languages/go/src/ir_to_go/mod.rs:109-118 | engine/generators/languages/go/src/ir_to_go/mod.rs:270-279 | engine/generators/languages/rust/src/ir_to_rust/mod.rs:127-136 | engine/generators/languages/rust/src/ir_to_rust/mod.rs:300-309 — before extracting anything, compare `engine/generators/languages/go/src/ir_to_go/mod.rs` and `engine/generators/languages/rust/src/ir_to_rust/mod.rs` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 208 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (10 lines × 4) engine/generators/languages/go/src/ir_to_go/mod.rs:140— engine/generators/languages/go/src/ir_to_go/mod.rs:140-149 | engine/generators/languages/go/src/ir_to_go/mod.rs:288-297 | engine/generators/languages/rust/src/ir_to_rust/mod.rs:158-167 | engine/generators/languages/rust/src/ir_to_rust/mod.rs:318-327 — before extracting anything, compare `engine/generators/languages/go/src/ir_to_go/mod.rs` and `engine/generators/languages/rust/src/ir_to_rust/mod.rs` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 208 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (8 lines × 4) baml_language/crates/baml_compiler2_mir/src/lower.rs:7811— baml_language/crates/baml_compiler2_mir/src/lower.rs:7811-7819 | baml_language/crates/baml_compiler2_mir/src/lower.rs:7860-7867 | baml_language/crates/baml_compiler2_mir/src/lower.rs:7944-7951 | baml_language/crates/baml_compiler2_mir/src/lower.rs:8195-8202 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (8 lines × 4) baml_language/crates/bex_vm/src/package_baml/array.rs:1064— baml_language/crates/bex_vm/src/package_baml/array.rs:1064-1071 | baml_language/crates/bex_vm/src/package_baml/array.rs:1087-1094 | baml_language/crates/bex_vm/src/package_baml/array.rs:1110-1117 | baml_language/crates/bex_vm/src/package_baml/array.rs:1138-1145 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (8 lines × 4) baml_language/crates/bex_vm/src/vm.rs:8097— baml_language/crates/bex_vm/src/vm.rs:8097-8104 | baml_language/crates/bex_vm/src/vm.rs:9767-9774 | baml_language/crates/bex_vm/src/vm.rs:9839-9846 | baml_language/crates/bex_vm/src/vm.rs:9864-9871 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (8 lines × 4) baml_language/crates/bex_vm/src/vm.rs:11437— baml_language/crates/bex_vm/src/vm.rs:11437-11444 | baml_language/crates/bex_vm/src/vm.rs:11464-11471 | baml_language/crates/bex_vm/src/vm.rs:11498-11505 | baml_language/crates/bex_vm/src/vm.rs:11533-11540 — 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.
Sync-over-async (deadlock risk) baml_language/sdks/csharp/bridge_csharp/src/Generated/V1/BamlGeneratedProgram.cs:32— Blocking on a Task with `.Wait()`/`.GetAwaiter().GetResult()` can deadlock (and wastes a thread). Prefer awaiting it: make the caller `async` and `await` instead. Where a synchronous entry point must stay — a public sync API you cannot break, or a process entry point that must not return until the work finishes — the block belongs in ONE documented bridge and never inside code that is already async; and where it already is that bridge, give the wait a TIMEOUT so a hung task fails the call instead of hanging the process.
Sync-over-async (deadlock risk) baml_language/sdks/csharp/bridge_csharp/src/Generated/V1/BamlGeneratedProgram.cs:160— Blocking on a Task with `.Wait()`/`.GetAwaiter().GetResult()` can deadlock (and wastes a thread). Prefer awaiting it: make the caller `async` and `await` instead. Where a synchronous entry point must stay — a public sync API you cannot break, or a process entry point that must not return until the work finishes — the block belongs in ONE documented bridge and never inside code that is already async; and where it already is that bridge, give the wait a TIMEOUT so a hung task fails the call instead of hanging the process.
Sync-over-async (deadlock risk) baml_language/sdks/csharp/bridge_csharp/src/Values/BamlPrompt.cs:37— Blocking on a Task with `.Wait()`/`.GetAwaiter().GetResult()` can deadlock (and wastes a thread). Prefer awaiting it: make the caller `async` and `await` instead. Where a synchronous entry point must stay — a public sync API you cannot break, or a process entry point that must not return until the work finishes — the block belongs in ONE documented bridge and never inside code that is already async; and where it already is that bridge, give the wait a TIMEOUT so a hung task fails the call instead of hanging the process.
Sync-over-async (deadlock risk) baml_language/sdks/csharp/bridge_csharp/src/Values/BamlPrompt.cs:53— Blocking on a Task with `.Wait()`/`.GetAwaiter().GetResult()` can deadlock (and wastes a thread). Prefer awaiting it: make the caller `async` and `await` instead. Where a synchronous entry point must stay — a public sync API you cannot break, or a process entry point that must not return until the work finishes — the block belongs in ONE documented bridge and never inside code that is already async; and where it already is that bridge, give the wait a TIMEOUT so a hung task fails the call instead of hanging the process.
sdkgen_python_pydantic2::leaf::render_leaf_body_pyi (cyclomatic 53) baml_language/sdks/python/rust/sdkgen_python_pydantic2/src/leaf.rs:2574— sdkgen_python_pydantic2::leaf::render_leaf_body_pyi has cyclomatic complexity 53 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
sdkgen_python_pydantic2::leaf::render_leaf_body (cyclomatic 42) baml_language/sdks/python/rust/sdkgen_python_pydantic2/src/leaf.rs:1671— sdkgen_python_pydantic2::leaf::render_leaf_body has cyclomatic complexity 42 (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.
sdkgen_python_pydantic2::translate_ty::translate_ty (cyclomatic 39) baml_language/sdks/python/rust/sdkgen_python_pydantic2/src/translate_ty.rs:67— sdkgen_python_pydantic2::translate_ty::translate_ty 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.
bex_sap::deserializer::coercer::array_helper::pick_best (cyclomatic 50) baml_language/crates/bex_sap/src/deserializer/coercer/array_helper.rs:42— bex_sap::deserializer::coercer::array_helper::pick_best has cyclomatic complexity 50 (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.
bex_sap::jsonish::parser::entry::parse_func (cyclomatic 33) baml_language/crates/bex_sap/src/jsonish/parser/entry.rs:12— bex_sap::jsonish::parser::entry::parse_func has cyclomatic complexity 33 (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.
bex_sap::deserializer::coercer::match_string::string_match_strategy (cyclomatic 20) baml_language/crates/bex_sap/src/deserializer/coercer/match_string.rs:209— bex_sap::deserializer::coercer::match_string::string_match_strategy has cyclomatic complexity 20 (threshold 15). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
Renderer::object (cyclomatic 45) baml_language/crates/btel_reader/src/value.rs:1197— Renderer::object has cyclomatic complexity 45 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Renderer::structural (cyclomatic 29) baml_language/crates/baml_type/src/normalize/mu.rs:1620— Renderer::structural has cyclomatic complexity 29 (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.
Renderer::value (cyclomatic 19) baml_language/crates/btel_reader/src/value.rs:1135— Renderer::value 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.
Generator::rvalue (cyclomatic 40) baml_language/crates/baml_compiler2_rust/src/codegen/expr.rs:18— Generator::rvalue 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.
Generator::constant (cyclomatic 19) baml_language/crates/baml_compiler2_rust/src/codegen/constant.rs:13— Generator::constant 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.
Generator::compiled_call (cyclomatic 16) baml_language/crates/baml_compiler2_rust/src/codegen/call.rs:76— Generator::compiled_call 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.
baml_compiler2_ast::lower_cst::lower_file_with_path_and_test_owner_impl (cyclomatic 38) baml_language/crates/baml_compiler2_ast/src/lower_cst.rs:103— baml_compiler2_ast::lower_cst::lower_file_with_path_and_test_owner_impl 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.
baml_compiler2_ast::lower_type_expr::lower_from_type_name_with_generic_args (cyclomatic 25) baml_language/crates/baml_compiler2_ast/src/lower_type_expr.rs:250— baml_compiler2_ast::lower_type_expr::lower_from_type_name_with_generic_args 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.
baml_compiler2_ast::lower_expr_body::synthesize_llm_spec_body (cyclomatic 24) baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:521— baml_compiler2_ast::lower_expr_body::synthesize_llm_spec_body 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.
btel_reader::value::ty::level (cyclomatic 36) baml_language/crates/btel_reader/src/value/ty.rs:148— btel_reader::value::ty::level 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.
btel_reader::value::span::reach (cyclomatic 21) baml_language/crates/btel_reader/src/value/span.rs:170— btel_reader::value::span::reach 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.
btel_reader::value::step (cyclomatic 19) baml_language/crates/btel_reader/src/value.rs:156— btel_reader::value::step 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.
sdkgen_swift::translate_ty::translate_ty (cyclomatic 36) baml_language/sdks/swift/rust/sdkgen_swift/src/translate_ty.rs:73— sdkgen_swift::translate_ty::translate_ty 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.
sdkgen_swift::emit::render_callable (cyclomatic 33) baml_language/sdks/swift/rust/sdkgen_swift/src/emit.rs:263— sdkgen_swift::emit::render_callable 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.
sdkgen_swift::to_source_code_with_optional_metadata (cyclomatic 18) baml_language/sdks/swift/rust/sdkgen_swift/src/lib.rs:66— sdkgen_swift::to_source_code_with_optional_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.
LowerCtx::lower_path (cyclomatic 35) baml_language/crates/baml_compiler2_hir_ty/src/lower.rs:798— LowerCtx::lower_path has cyclomatic complexity 35 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
LowerCtx::lower_type_ref_inner (cyclomatic 30) baml_language/crates/baml_compiler2_hir_ty/src/lower.rs:441— LowerCtx::lower_type_ref_inner has cyclomatic complexity 30 (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.
LowerCtx::lower_definition (cyclomatic 16) baml_language/crates/baml_compiler2_hir_ty/src/lower.rs:1137— LowerCtx::lower_definition has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
baml_vm::native::deep_equals_recursive (cyclomatic 31) engine/baml-vm/src/native.rs:502— baml_vm::native::deep_equals_recursive has cyclomatic complexity 31 (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.
baml_vm::debug::display_bytecode (cyclomatic 17) engine/baml-vm/src/debug.rs:257— baml_vm::debug::display_bytecode 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.
baml_vm::native::deep_copy_value_recursive (cyclomatic 16) engine/baml-vm/src/native.rs:402— baml_vm::native::deep_copy_value_recursive 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.
BamlValueWithMeta::is_type (cyclomatic 30) engine/baml-lib/baml-types/src/baml_value.rs:534— BamlValueWithMeta::is_type has cyclomatic complexity 30 (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 shape REPEATS in the file: 2 other methods here (BamlValueWithMeta::is_type, BamlValueWithMeta::is_type) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 3 times rather than 3 independent problems. Splitting this body alone leaves the other 2 exactly as they are. Where these are variations on one operation, the change that clears all 3 is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
BamlValueWithMeta::is_type (cyclomatic 30) engine/baml-lib/baml-types/src/baml_value.rs:671— BamlValueWithMeta::is_type has cyclomatic complexity 30 (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 shape REPEATS in the file: 2 other methods here (BamlValueWithMeta::is_type, BamlValueWithMeta::is_type) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 3 times rather than 3 independent problems. Splitting this body alone leaves the other 2 exactly as they are. Where these are variations on one operation, the change that clears all 3 is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
BamlValueWithMeta::is_type (cyclomatic 30) engine/baml-lib/baml-types/src/baml_value.rs:808— BamlValueWithMeta::is_type has cyclomatic complexity 30 (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 shape REPEATS in the file: 2 other methods here (BamlValueWithMeta::is_type, BamlValueWithMeta::is_type) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 3 times rather than 3 independent problems. Splitting this body alone leaves the other 2 exactly as they are. Where these are variations on one operation, the change that clears all 3 is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
WithIr::encode (cyclomatic 27) engine/language_client_cffi/src/ctypes/baml_value_with_meta_encode.rs:32— WithIr::encode 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.
WithIr::encode (cyclomatic 19) engine/language_client_cffi/src/ctypes/baml_type_encode.rs:33— WithIr::encode 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.
WithIr::encode (cyclomatic 16) engine/language_client_cffi/src/ctypes/object_response_encode.rs:40— WithIr::encode has cyclomatic complexity 16 (threshold 15). Most of this is not in the body itself: 4 of the 16 points are its own statements and the rest belongs to one function item inside it that branches (get_type_ir). 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.
language_server::baml_project::get_dummy_value (cyclomatic 24) engine/language_server/src/baml_project/mod.rs:1551— language_server::baml_project::get_dummy_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.
language_server::server::api::diagnostics::project_diagnostics (cyclomatic 19) engine/language_server/src/server/api/diagnostics.rs:130— language_server::server::api::diagnostics::project_diagnostics 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.
language_server::server::api::request (cyclomatic 18) engine/language_server/src/server/api.rs:55— language_server::server::api::request 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.
baml_compiler2_rust::codegen::types::build_type (cyclomatic 22) baml_language/crates/baml_compiler2_rust/src/codegen/types.rs:23— baml_compiler2_rust::codegen::types::build_type has cyclomatic complexity 22 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
baml_compiler2_rust::init::generate (cyclomatic 18) baml_language/crates/baml_compiler2_rust/src/init.rs:61— baml_compiler2_rust::init::generate 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.
baml_compiler2_rust::admit::recursive_functions (cyclomatic 17) baml_language/crates/baml_compiler2_rust/src/admit.rs:468— baml_compiler2_rust::admit::recursive_functions 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.
JsonInhabitance::solve (cyclomatic 22) baml_language/crates/baml_type/src/json_inhabit.rs:523— JsonInhabitance::solve 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.
JsonInhabitance::discover (cyclomatic 20) baml_language/crates/baml_type/src/json_inhabit.rs:400— JsonInhabitance::discover 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.
JsonInhabitance::node (cyclomatic 17) baml_language/crates/baml_type/src/json_inhabit.rs:594— JsonInhabitance::node 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.
bridge_cffi::baml_to_host::decode_invocation_request (cyclomatic 22) baml_language/crates/bridge_cffi/src/baml_to_host.rs:425— bridge_cffi::baml_to_host::decode_invocation_request 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.
bridge_cffi::host_capture::copy (cyclomatic 22) baml_language/crates/bridge_cffi/src/host_capture.rs:37— bridge_cffi::host_capture::copy 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.
bridge_cffi::invocation_protocol::validate_fields (cyclomatic 16) baml_language/crates/bridge_cffi/src/invocation_protocol.rs:113— bridge_cffi::invocation_protocol::validate_fields 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.
generators_typescript::ir_to_ts::type_to_ts (cyclomatic 22) engine/generators/languages/typescript/src/ir_to_ts/mod.rs:118— generators_typescript::ir_to_ts::type_to_ts has cyclomatic complexity 22 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
generators_typescript::ir_to_ts::stream_type_to_ts (cyclomatic 20) engine/generators/languages/typescript/src/ir_to_ts/mod.rs:18— generators_typescript::ir_to_ts::stream_type_to_ts has cyclomatic complexity 20 (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.
generators_typescript::watchers::build_event_collectors (cyclomatic 17) engine/generators/languages/typescript/src/watchers.rs:139— generators_typescript::watchers::build_event_collectors 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.
CandidateApplier::update_field_attributes (cognitive 91) engine/baml-runtime/src/optimize/applier.rs:315— CandidateApplier::update_field_attributes has cognitive complexity 91 (threshold 15). Drivers by points: if/else 19 (91 pts) (nesting depth added 72). 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.
CandidateApplier::update_class_attributes (cognitive 33) engine/baml-runtime/src/optimize/applier.rs:251— CandidateApplier::update_class_attributes has cognitive complexity 33 (threshold 15). Drivers by points: if/else 9 (29 pts), loops 1 (3 pts), boolean chains 1 (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.
CandidateApplier::update_enum_attributes (cognitive 29) engine/baml-runtime/src/optimize/applier.rs:484— CandidateApplier::update_enum_attributes has cognitive complexity 29 (threshold 15). Drivers by points: if/else 7 (27 pts), loops 1 (2 pts) (nesting depth added 21). 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.
bex_project::runtime_compile::lower_session_submission (cognitive 77) baml_language/crates/bex_project/src/runtime_compile.rs:1282— bex_project::runtime_compile::lower_session_submission has cognitive complexity 77 (threshold 15). Drivers by points: if/else 31 (59 pts), boolean chains 8, loops 5 (8 pts), match/switch 1 (2 pts) (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.
bex_project::runtime_compile::rewrite_identifiers (cognitive 63) baml_language/crates/bex_project/src/runtime_compile.rs:1032— bex_project::runtime_compile::rewrite_identifiers has cognitive complexity 63 (threshold 15). Drivers by points: if/else 17 (38 pts), loops 7 (17 pts), boolean chains 8 (nesting depth added 31). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
bex_project::runtime_compile::projected_interface (cognitive 34) baml_language/crates/bex_project/src/runtime_compile.rs:152— bex_project::runtime_compile::projected_interface has cognitive complexity 34 (threshold 15). Drivers by points: loops 12 (21 pts), match/switch 4 (8 pts), if/else 3 (4 pts), boolean chains 1 (nesting depth added 14). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
Renderer::object (cognitive 73) baml_language/crates/btel_reader/src/value.rs:1197— Renderer::object has cognitive complexity 73 (threshold 15). Drivers by points: if/else 27 (54 pts), match/switch 5 (9 pts), loops 3 (7 pts), boolean chains 3 (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.
Renderer::structural (cognitive 39) baml_language/crates/baml_type/src/normalize/mu.rs:1620— Renderer::structural has cognitive complexity 39 (threshold 15). Drivers by points: loops 8 (20 pts), match/switch 5 (10 pts), if/else 3 (8 pts), boolean chains 1 (nesting depth added 22). 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.
Renderer::definition (cognitive 25) baml_language/crates/btel_reader/src/value.rs:1025— Renderer::definition has cognitive complexity 25 (threshold 15). Drivers by points: if/else 6 (13 pts), loops 3 (7 pts), match/switch 3 (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.
GlobalState::dispatch_request (cognitive 66) baml_language/crates/baml_lsp/src/dispatch/mod.rs:91— GlobalState::dispatch_request has cognitive complexity 66 (threshold 15). Drivers by points: match/switch 37 (59 pts), if/else 3 (7 pts) (nesting depth added 26). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own 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.
GlobalState::apply_one (cognitive 20) baml_language/crates/baml_lsp/src/state.rs:848— GlobalState::apply_one has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (15 pts), match/switch 2 (3 pts), loops 1 (2 pts) (nesting depth added 10). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
GlobalState::on_roots_loaded (cognitive 19) baml_language/crates/baml_lsp/src/dispatch/events.rs:136— GlobalState::on_roots_loaded has cognitive complexity 19 (threshold 15). Drivers by points: if/else 4 (8 pts), match/switch 2 (6 pts), loops 4 (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.
btel_file::reader::check_references (cognitive 66) baml_language/crates/btel_file/src/reader.rs:289— btel_file::reader::check_references has cognitive complexity 66 (threshold 15). Drivers by points: if/else 10 (32 pts), loops 10 (27 pts), match/switch 2 (7 pts) (nesting depth added 44). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
btel_file::reader::validate_file (cognitive 50) baml_language/crates/btel_file/src/reader.rs:138— btel_file::reader::validate_file has cognitive complexity 50 (threshold 15). Drivers by points: if/else 13 (25 pts), boolean chains 12, loops 4 (9 pts), match/switch 1 (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.
btel_file::reader::read_directory (cognitive 19) baml_language/crates/btel_file/src/reader.rs:36— btel_file::reader::read_directory has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (15 pts), loops 2, match/switch 1 (2 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Facts::project (cognitive 48) baml_language/crates/baml_compiler2_hir_ty/src/facts.rs:246— Facts::project has cognitive complexity 48 (threshold 15). Drivers by points: if/else 12 (25 pts), match/switch 6 (13 pts), loops 3 (7 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.
Facts::statement (cognitive 21) baml_language/crates/baml_compiler2_mir/src/optimize/effects.rs:279— Facts::statement has cognitive complexity 21 (threshold 15). Drivers by points: if/else 7 (11 pts), match/switch 4 (7 pts), boolean chains 3 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Facts::branch (cognitive 16) baml_language/crates/baml_compiler2_mir/src/optimize/effects.rs:391— Facts::branch has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (13 pts), loops 1 (2 pts), match/switch 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.
JsonInhabitance::solve (cognitive 45) baml_language/crates/baml_type/src/json_inhabit.rs:523— JsonInhabitance::solve has cognitive complexity 45 (threshold 15). Drivers by points: if/else 9 (24 pts), loops 9 (17 pts), boolean chains 4 (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.
JsonInhabitance::discover (cognitive 28) baml_language/crates/baml_type/src/json_inhabit.rs:400— JsonInhabitance::discover has cognitive complexity 28 (threshold 15). Drivers by points: if/else 10 (22 pts), loops 2 (4 pts), boolean chains 1, 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.
JsonInhabitance::witness_walk (cognitive 20) baml_language/crates/baml_type/src/json_inhabit.rs:330— JsonInhabitance::witness_walk has cognitive complexity 20 (threshold 15). Drivers by points: if/else 5 (11 pts), match/switch 4 (8 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.
GoNames::for_pool (cognitive 42) baml_language/sdks/go/sdkgen_go/src/names.rs:395— GoNames::for_pool has cognitive complexity 42 (threshold 15). Drivers by points: if/else 9 (28 pts), loops 4 (8 pts), boolean chains 4, match/switch 1 (2 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.
GoNames::allocate_unions (cognitive 26) baml_language/sdks/go/sdkgen_go/src/names.rs:720— GoNames::allocate_unions has cognitive complexity 26 (threshold 15). Drivers by points: if/else 6 (15 pts), loops 5 (11 pts) (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
GoNames::allocate_callback_options (cognitive 22) baml_language/sdks/go/sdkgen_go/src/names.rs:844— GoNames::allocate_callback_options has cognitive complexity 22 (threshold 15). Drivers by points: loops 8 (17 pts), if/else 1 (4 pts), boolean chains 1 (nesting depth added 12). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
SemanticIndexBuilder::collect_pattern_names (cognitive 36) baml_language/crates/baml_compiler2_hir/src/builder.rs:907— SemanticIndexBuilder::collect_pattern_names has cognitive complexity 36 (threshold 15). Drivers by points: if/else 7 (15 pts), loops 6 (15 pts), match/switch 2 (5 pts), boolean chains 1 (nesting depth added 20). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
SemanticIndexBuilder::walk_expr_children (cognitive 26) baml_language/crates/baml_compiler2_hir/src/builder.rs:601— SemanticIndexBuilder::walk_expr_children has cognitive complexity 26 (threshold 15). Drivers by points: loops 6 (12 pts), if/else 5 (11 pts), match/switch 2 (3 pts) (nesting depth added 13). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
SemanticIndexBuilder::validate_function_phase1 (cognitive 18) baml_language/crates/baml_compiler2_hir/src/builder.rs:1796— SemanticIndexBuilder::validate_function_phase1 has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (13 pts), match/switch 1 (3 pts), boolean chains 1, 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.
NativeSysOps::_send_sse (cognitive 35) baml_language/crates/sys_native/src/io_impls.rs:3175— NativeSysOps::_send_sse has cognitive complexity 35 (threshold 15). Drivers by points: if/else 12 (23 pts), match/switch 4 (8 pts), loops 3 (4 pts) (nesting depth added 16). Of this number, 32 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.
NativeSysOps::scan (cognitive 25) baml_language/crates/sys_native/src/io_impls.rs:1159— NativeSysOps::scan has cognitive complexity 25 (threshold 15). Drivers by points: if/else 9 (18 pts), boolean chains 3, match/switch 2 (3 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.
NativeSysOps::call_host_value (cognitive 16) baml_language/crates/sys_native/src/host_impls.rs:47— NativeSysOps::call_host_value has cognitive complexity 16 (threshold 15). Drivers by points: match/switch 8 (10 pts), if/else 5 (6 pts) (nesting depth added 3). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own 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.
baml_linker::space::relocate (cognitive 30) baml_language/crates/baml_linker/src/space.rs:255— baml_linker::space::relocate has cognitive complexity 30 (threshold 15). Drivers by points: if/else 9 (18 pts), loops 4 (9 pts), match/switch 3 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
baml_linker::order::init_order (cognitive 20) baml_language/crates/baml_linker/src/order.rs:123— baml_linker::order::init_order has cognitive complexity 20 (threshold 15). Drivers by points: loops 7 (10 pts), if/else 3 (8 pts), boolean chains 2 (nesting depth added 8). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
baml_linker::resolve::export_objects (cognitive 19) baml_language/crates/baml_linker/src/resolve.rs:42— baml_linker::resolve::export_objects has cognitive complexity 19 (threshold 15). Drivers by points: if/else 4 (12 pts), loops 2 (3 pts), match/switch 1 (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.
Watch::track_dependencies (cognitive 28) engine/baml-vm/src/watch.rs:448— Watch::track_dependencies has cognitive complexity 28 (threshold 15). Drivers by points: if/else 5 (16 pts), loops 4 (10 pts), 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.
Watch::link_edge (cognitive 16) engine/baml-vm/src/watch.rs:322— Watch::link_edge has cognitive complexity 16 (threshold 15). Drivers by points: if/else 3 (8 pts), loops 3 (8 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.
Watch::unlink_edge (cognitive 16) engine/baml-vm/src/watch.rs:364— Watch::unlink_edge has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (13 pts), loops 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.
BamlValueWithMeta::is_type (cognitive 27) engine/baml-lib/baml-types/src/baml_value.rs:534— BamlValueWithMeta::is_type has cognitive complexity 27 (threshold 15). Drivers by points: match/switch 14 (25 pts), boolean chains 2 (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. This shape REPEATS in the file: 2 other methods here (BamlValueWithMeta::is_type, BamlValueWithMeta::is_type) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 3 times rather than 3 independent problems. Splitting this body alone leaves the other 2 exactly as they are. Where these are variations on one operation, the change that clears all 3 is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
BamlValueWithMeta::is_type (cognitive 27) engine/baml-lib/baml-types/src/baml_value.rs:671— BamlValueWithMeta::is_type has cognitive complexity 27 (threshold 15). Drivers by points: match/switch 14 (25 pts), boolean chains 2 (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. This shape REPEATS in the file: 2 other methods here (BamlValueWithMeta::is_type, BamlValueWithMeta::is_type) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 3 times rather than 3 independent problems. Splitting this body alone leaves the other 2 exactly as they are. Where these are variations on one operation, the change that clears all 3 is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
BamlValueWithMeta::is_type (cognitive 27) engine/baml-lib/baml-types/src/baml_value.rs:808— BamlValueWithMeta::is_type has cognitive complexity 27 (threshold 15). Drivers by points: match/switch 14 (25 pts), boolean chains 2 (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. This shape REPEATS in the file: 2 other methods here (BamlValueWithMeta::is_type, BamlValueWithMeta::is_type) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 3 times rather than 3 independent problems. Splitting this body alone leaves the other 2 exactly as they are. Where these are variations on one operation, the change that clears all 3 is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
AwsClient::client_anyhow (cognitive 27) engine/baml-runtime/src/internal/llm_client/primitive/aws/aws_client.rs:576— AwsClient::client_anyhow has cognitive complexity 27 (threshold 15). Drivers by points: if/else 11 (20 pts), match/switch 4 (7 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.
AwsClient::stream_chat (cognitive 22) engine/baml-runtime/src/internal/llm_client/primitive/aws/aws_client.rs:902— AwsClient::stream_chat has cognitive complexity 22 (threshold 15). Drivers by points: if/else 4 (11 pts), match/switch 7 (11 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.
AwsClient::build_converse_body_json (cognitive 18) engine/baml-runtime/src/internal/llm_client/primitive/aws/aws_client.rs:354— AwsClient::build_converse_body_json has cognitive complexity 18 (threshold 15). Drivers by points: if/else 10 (12 pts), loops 3 (6 pts) (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.
PackageReflectImpl::_with_types (cognitive 23) baml_language/crates/bex_vm/src/package_reflect/reflect.rs:1274— PackageReflectImpl::_with_types has cognitive complexity 23 (threshold 15). Drivers by points: if/else 6 (12 pts), loops 4 (6 pts), match/switch 2 (5 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.
PackageReflectImpl::functions (cognitive 18) baml_language/crates/bex_vm/src/package_reflect/reflect.rs:1452— PackageReflectImpl::functions has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (15 pts), loops 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.
PackageReflectImpl::_field (cognitive 18) baml_language/crates/bex_vm/src/package_reflect/runtime_class_builder.rs:341— PackageReflectImpl::_field has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (8 pts), match/switch 3 (6 pts), loops 2 (4 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
baml_type_macros::convert::emit_conversions (cognitive 19) baml_language/crates/baml_type_macros/src/convert.rs:63— baml_type_macros::convert::emit_conversions has cognitive complexity 19 (threshold 15). Drivers by points: if/else 5 (9 pts), loops 4 (6 pts), boolean chains 4 (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.
baml_type_macros::emit::head_arm (cognitive 19) baml_language/crates/baml_type_macros/src/emit.rs:288— baml_type_macros::emit::head_arm has cognitive complexity 19 (threshold 15). Drivers by points: if/else 4 (10 pts), match/switch 3 (5 pts), loops 2 (4 pts) (nesting depth added 10). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
baml_type_macros::interned_member::interned_ty (cognitive 17) baml_language/crates/baml_type_macros/src/interned_member.rs:182— baml_type_macros::interned_member::interned_ty has cognitive complexity 17 (threshold 15). Drivers by points: if/else 12 (16 pts), boolean chains 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.
TooManyFunctions: baml baml_language/crates/baml/src/main.rs:158— TooManyFunctions — 79 free functions, declared across 2 files: src/main.rs (77), src/lib.rs (2). The bar is 30 free functions; this is 49 over it, 2.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.
TooManyFunctions: baml_vm::native engine/baml-vm/src/native.rs:20— TooManyFunctions — 36 free functions. The bar is 30 free functions; this is 6 over it, 1.20× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyFunctions: bex_prof_store::prof::backend::evidence_codec baml_language/crates/bex_prof_store/src/prof/backend/evidence_codec.rs:51— TooManyFunctions — 33 free functions. The bar is 30 free functions; this is 3 over it, 1.10× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
D4 · Code Duplication· Members sharing a duplicated core (7 members, 50+ identical tokens) · ×3
Members sharing a duplicated core (7 members, 50+ identical tokens) baml_language/crates/bex_events/src/run.rs:1074— baml_language/crates/bex_events/src/run.rs:1074-1103 | baml_language/crates/bex_events/src/run.rs:1113-1137 | baml_language/crates/bex_events/src/run.rs:1149-1174 | baml_language/crates/bex_events/src/run.rs:1181-1204 | baml_language/crates/bex_events/src/run.rs:1211-1231 | baml_language/crates/bex_events/src/run.rs:1238-1262 | baml_language/crates/bex_events/src/run.rs:1271-1305 — These 7 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 7 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 7 times.
Members sharing a duplicated core (7 members, 50+ identical tokens) languages/rust/baml/src/runtime.rs:82— languages/rust/baml/src/runtime.rs:82-135 | languages/rust/baml/src/runtime.rs:150-198 | languages/rust/baml/src/runtime.rs:205-257 | languages/rust/baml/src/runtime.rs:272-322 | languages/rust/baml/src/runtime.rs:344-404 | languages/rust/baml/src/runtime.rs:451-490 | languages/rust/baml/src/runtime.rs:497-536 — These 7 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 7 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 7 times.
Members sharing a duplicated core (7 members, 50+ identical tokens) baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:82— baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:82-103 | baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:177-202 | baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:283-312 | baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:400-433 | baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:528-565 | baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:667-708 | baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:817-862 — These 7 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 7 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 7 times.
D4 · Code Duplication· Members sharing a duplicated core (6 members, 50+ identical tokens) · ×3
Members sharing a duplicated core (6 members, 50+ identical tokens) baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:2347— baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:2347-2410 | baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:2798-2868 | baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:2870-2992 | baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:5653-5692 | baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:5694-5732 | baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:5931-5985 — These 6 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
Members sharing a duplicated core (6 members, 50+ identical tokens) engine/baml-schema-wasm/src/runtime_wasm/mod.rs:1607— engine/baml-schema-wasm/src/runtime_wasm/mod.rs:1607-1624 | engine/baml-schema-wasm/src/runtime_wasm/mod.rs:1627-1644 | engine/baml-schema-wasm/src/runtime_wasm/mod.rs:1647-1664 | engine/language_server/src/baml_project/mod.rs:519-535 | engine/language_server/src/baml_project/mod.rs:537-553 | engine/language_server/src/baml_project/mod.rs:555-571 — These 6 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
Members sharing a duplicated core (6 members, 50+ identical tokens) baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:167— baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:167-173 | baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:272-279 | baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:388-396 | baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:515-524 | baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:653-663 | baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:802-813 — These 6 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
Duplicated block (41 lines × 2) baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:4591— baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:4591-4631 | baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:4674-4714 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (41 lines × 2) baml_language/crates/baml_db/src/check.rs:1319— baml_language/crates/baml_db/src/check.rs:1319-1359 | baml_language/crates/baml_db/src/check.rs:1370-1410 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (41 lines × 2) baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs:537— baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs:537-577 | engine/baml-lib/jsonish/src/jsonish/parser/fixing_parser/json_parse_state.rs:572-612 — before extracting anything, compare `baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs` and `engine/baml-lib/jsonish/src/jsonish/parser/fixing_parser/json_parse_state.rs` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 575 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, 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 (40 lines × 2) baml_language/crates/baml_compiler2_ast/src/lower_cst.rs:1688— baml_language/crates/baml_compiler2_ast/src/lower_cst.rs:1688-1727 | baml_language/crates/baml_compiler2_ast/src/lower_cst.rs:1769-1808 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (40 lines × 2) baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs:437— baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs:437-476 | engine/baml-lib/jsonish/src/jsonish/parser/fixing_parser/json_parse_state.rs:465-504 — before extracting anything, compare `baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs` and `engine/baml-lib/jsonish/src/jsonish/parser/fixing_parser/json_parse_state.rs` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 575 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, 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 (40 lines × 2) baml_language/crates/bex_sap/src/jsonish/parser/markdown_parser.rs:46— baml_language/crates/bex_sap/src/jsonish/parser/markdown_parser.rs:46-85 | engine/baml-lib/jsonish/src/jsonish/parser/markdown_parser.rs:49-88 — 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 (32 lines × 2) baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:2704— baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:2704-2735 | baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:2754-2785 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (32 lines × 2) baml_language/crates/baml_ide/src/symbol_pool.rs:305— baml_language/crates/baml_ide/src/symbol_pool.rs:305-336 | baml_language/crates/baml_ide/src/symbol_pool.rs:527-558 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (32 lines × 2) baml_language/crates/bex_sap/src/jsonish/value.rs:259— baml_language/crates/bex_sap/src/jsonish/value.rs:259-290 | engine/baml-lib/jsonish/src/jsonish/value.rs:201-232 — before extracting anything, compare `baml_language/crates/bex_sap/src/jsonish/value.rs` and `engine/baml-lib/jsonish/src/jsonish/value.rs` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 160 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, 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 (18–19 lines × 2) baml_language/crates/sys_ops/src/output_format.rs:528— baml_language/crates/sys_ops/src/output_format.rs:528-545 | engine/baml-lib/jinja-runtime/src/output_format/types.rs:1009-1027 — 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 (18–19 lines × 2) engine/baml-vm/src/vm.rs:852— engine/baml-vm/src/vm.rs:852-870 | engine/baml-vm/src/vm.rs:889-906 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (18–19 lines × 2) engine/generators/languages/ruby/src/ir_to_rb/mod.rs:109— engine/generators/languages/ruby/src/ir_to_rb/mod.rs:109-127 | engine/generators/languages/ruby/src/ir_to_rb/mod.rs:208-225 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (17–18 lines × 2) baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:2660— baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:2660-2677 | baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:6037-6053 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (17–18 lines × 2) baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs:461— baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs:461-477 | baml_language/crates/baml_type/src/unify.rs:824-841 — before extracting anything, compare `baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs` and `baml_language/crates/baml_type/src/unify.rs` as WHOLE FILES: this scan already matched 21 separate duplicated blocks between them, totalling at least 418 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (17–18 lines × 2) baml_language/tools/speedtest/src/speedtest/compare.py:85— baml_language/tools/speedtest/src/speedtest/compare.py:85-102 | baml_language/tools/speedtest/src/speedtest/compare.py:211-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. 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, `baml_language/tools/speedtest/src/speedtest/compare.py:103` calls `fmt_delta_pct` and `baml_language/tools/speedtest/src/speedtest/compare.py:229` 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–16 lines × 2) baml_language/crates/baml_compiler2_visualization/src/control_flow/flatten.rs:697— baml_language/crates/baml_compiler2_visualization/src/control_flow/flatten.rs:697-712 | engine/baml-runtime/src/control_flow/flatten/step3_inline_implicit_nodes.rs:165-178 — before extracting anything, compare `baml_language/crates/baml_compiler2_visualization/src/control_flow/flatten.rs` and `engine/baml-runtime/src/control_flow/flatten/step3_inline_implicit_nodes.rs` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 132 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, 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–16 lines × 2) baml_language/crates/baml_fmt/src/ast/declarations.rs:1217— baml_language/crates/baml_fmt/src/ast/declarations.rs:1217-1232 | baml_language/crates/baml_fmt/src/ast/declarations.rs:1856-1869 — both copies are in the same file, so extract the block into 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–16 lines × 2) baml_language/crates/tools_size_gate/src/main.rs:310— baml_language/crates/tools_size_gate/src/main.rs:310-325 | baml_language/crates/tools_size_gate/src/main.rs:505-518 — both copies are in the same file, so extract the block into 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 × 4) baml_language/crates/baml_compiler2_mir/src/lower.rs:7821— baml_language/crates/baml_compiler2_mir/src/lower.rs:7821-7833 | baml_language/crates/baml_compiler2_mir/src/lower.rs:7869-7881 | baml_language/crates/baml_compiler2_mir/src/lower.rs:7953-7965 | baml_language/crates/baml_compiler2_mir/src/lower.rs:8204-8216 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (13 lines × 4) baml_language/crates/baml_fmt/src/ast/expressions.rs:864— baml_language/crates/baml_fmt/src/ast/expressions.rs:864-876 | baml_language/crates/baml_fmt/src/ast/expressions.rs:1977-1989 | baml_language/crates/baml_fmt/src/ast/statements.rs:890-902 | baml_language/crates/baml_fmt/src/ast/types.rs:219-231 — before extracting anything, compare `baml_language/crates/baml_fmt/src/ast/expressions.rs` and `baml_language/crates/baml_fmt/src/ast/statements.rs` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 65 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (13 lines × 4) engine/baml_cffi_macros/src/lib.rs:980— engine/baml_cffi_macros/src/lib.rs:980-992 | engine/baml_cffi_macros/src/lib.rs:1014-1026 | engine/baml_cffi_macros/src/lib.rs:1048-1060 | engine/baml_cffi_macros/src/lib.rs:1099-1111 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (9–12 lines × 2) baml_language/crates/baml_builtins2_codegen/src/codegen_io.rs:1612— baml_language/crates/baml_builtins2_codegen/src/codegen_io.rs:1612-1623 | baml_language/crates/baml_builtins2_codegen/src/codegen_io.rs:1944-1952 — both copies are in the same file, so extract the block into 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–12 lines × 2) baml_language/crates/baml_compiler2_ast/src/lower_cst.rs:483— baml_language/crates/baml_compiler2_ast/src/lower_cst.rs:483-494 | baml_language/crates/baml_compiler2_ast/src/lower_cst.rs:1640-1648 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (9–12 lines × 2) engine/generators/languages/python/src/ir_to_py/mod.rs:97— engine/generators/languages/python/src/ir_to_py/mod.rs:97-108 | engine/generators/languages/python/src/ir_to_py/mod.rs:182-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 (11 lines × 4) baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:1130— baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:1130-1140 | baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:1183-1193 | baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:1268-1278 | baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:1379-1389 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (11 lines × 4) engine/baml-lib/baml-core/src/ir/ir_hasher/mod.rs:449— engine/baml-lib/baml-core/src/ir/ir_hasher/mod.rs:449-460 | engine/baml-lib/baml-core/src/ir/ir_hasher/mod.rs:464-474 | engine/baml-lib/baml-core/src/ir/ir_hasher/mod.rs:478-488 | engine/baml-lib/baml-core/src/ir/ir_hasher/mod.rs:492-504 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (11 lines × 4) engine/generators/languages/rust/src/ir_to_rust/classes.rs:21— engine/generators/languages/rust/src/ir_to_rust/classes.rs:21-31 | engine/generators/languages/rust/src/ir_to_rust/classes.rs:47-57 | engine/generators/languages/typescript/src/ir_to_ts/classes.rs:10-20 | engine/generators/languages/typescript/src/ir_to_ts/classes.rs:28-38 — 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.
Duplicated block (9–11 lines × 2) baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:2672— baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:2672-2682 | baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:2731-2739 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (9–11 lines × 2) baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:5079— baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:5079-5089 | baml_language/crates/baml_compiler2_hir_ty/src/infer/pat.rs:1018-1026 — 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–11 lines × 2) baml_language/crates/baml_fmt/src/ast/expressions.rs:3737— baml_language/crates/baml_fmt/src/ast/expressions.rs:3737-3747 | baml_language/crates/baml_fmt/src/ast/pattern.rs:385-393 — before extracting anything, compare `baml_language/crates/baml_fmt/src/ast/expressions.rs` and `baml_language/crates/baml_fmt/src/ast/pattern.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 39 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (10 lines × 5) engine/baml-runtime/src/internal/llm_client/primitive/anthropic/response_handler.rs:45— engine/baml-runtime/src/internal/llm_client/primitive/anthropic/response_handler.rs:45-54 | engine/baml-runtime/src/internal/llm_client/primitive/google/response_handler.rs:39-48 | engine/baml-runtime/src/internal/llm_client/primitive/openai/response_handler.rs:251-260 | engine/baml-runtime/src/internal/llm_client/primitive/openai/response_handler.rs:327-336 | engine/baml-runtime/src/internal/llm_client/primitive/vertex/response_handler.rs:38-47 — `engine/baml-runtime/src/internal/llm_client/primitive/anthropic/response_handler.rs` and `engine/baml-runtime/src/internal/llm_client/primitive/openai/response_handler.rs` 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 4 separate duplicated blocks between them, totalling at least 33 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.
Duplicated block (10 lines × 5) engine/baml_cffi_macros/src/lib.rs:922— engine/baml_cffi_macros/src/lib.rs:922-931 | engine/baml_cffi_macros/src/lib.rs:985-994 | engine/baml_cffi_macros/src/lib.rs:1019-1028 | engine/baml_cffi_macros/src/lib.rs:1053-1062 | engine/baml_cffi_macros/src/lib.rs:1104-1113 — 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 (10 lines × 5) engine/generators/languages/go/src/package.rs:93— engine/generators/languages/go/src/package.rs:93-102 | engine/generators/languages/python/src/package.rs:115-124 | engine/generators/languages/ruby/src/package.rs:117-126 | engine/generators/languages/rust/src/package.rs:94-103 | engine/generators/languages/typescript/src/package.rs:85-94 — before extracting anything, compare `engine/generators/languages/go/src/package.rs` and `engine/generators/languages/rust/src/package.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 30 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, 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–10 lines × 2) baml_language/crates/baml_fmt/src/ast/statements.rs:257— baml_language/crates/baml_fmt/src/ast/statements.rs:257-266 | baml_language/crates/baml_fmt/src/ast/statements.rs:599-606 — both copies are in the same file, so extract the block into 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–10 lines × 2) engine/generators/languages/typescript/src/ir_to_ts/mod.rs:127— engine/generators/languages/typescript/src/ir_to_ts/mod.rs:127-134 | engine/generators/languages/typescript/src/ir_to_ts/mod.rs:241-250 — both copies are in the same file, so extract the block into 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–10 lines × 2) engine/language_server/src/baml_project/mod.rs:1170— engine/language_server/src/baml_project/mod.rs:1170-1179 | engine/language_server/src/baml_project/mod.rs:1233-1240 — both copies are in the same file, so extract the block into 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 × 5) baml_language/crates/baml_compiler2_emit/src/emit.rs:1349— baml_language/crates/baml_compiler2_emit/src/emit.rs:1349-1355 | baml_language/crates/baml_compiler2_emit/src/emit.rs:1811-1817 | baml_language/crates/baml_compiler2_emit/src/emit.rs:1845-1851 | baml_language/crates/baml_compiler2_emit/src/emit.rs:1869-1875 | baml_language/crates/baml_compiler2_emit/src/emit.rs:2501-2507 — 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 (7 lines × 5) engine/generators/languages/go/src/ir_to_go/enums.rs:10— engine/generators/languages/go/src/ir_to_go/enums.rs:10-16 | engine/generators/languages/python/src/ir_to_py/enums.rs:7-13 | engine/generators/languages/ruby/src/ir_to_rb/enums.rs:7-13 | engine/generators/languages/rust/src/ir_to_rust/enums.rs:7-13 | engine/generators/languages/typescript/src/ir_to_ts/enums.rs:5-11 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 5 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 5 times.
Duplicated block (7 lines × 5) baml_language/sdks/go/baml_go/class.go:21— baml_language/sdks/go/baml_go/class.go:21-27 | baml_language/sdks/go/baml_go/container.go:86-93 | baml_language/sdks/go/baml_go/container.go:166-172 | baml_language/sdks/go/baml_go/container.go:187-193 | baml_language/sdks/go/baml_go/dynamic.go:226-232 — there are 5 copies across 3 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 5 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `baml_language/sdks/go/baml_go/class.go:21` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (6 lines × 5) baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:2388— baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:2388-2393 | baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:2840-2845 | baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:5659-5664 | baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:5720-5725 | baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:5968-5973 — 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 (6 lines × 5) engine/baml-lib/ast/src/ast/baml_vis/mermaid_debug.rs:189— engine/baml-lib/ast/src/ast/baml_vis/mermaid_debug.rs:189-194 | engine/baml-lib/ast/src/ast/baml_vis/mermaid_debug.rs:203-208 | engine/baml-lib/ast/src/ast/baml_vis/mermaid_debug.rs:217-222 | engine/baml-lib/ast/src/ast/baml_vis/mermaid_debug.rs:224-229 | engine/baml-lib/ast/src/ast/baml_vis/mermaid_debug.rs:231-236 — 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 (6 lines × 5) baml_language/sdk_tests/codegen/src/cpp.rs:28— baml_language/sdk_tests/codegen/src/cpp.rs:28-33 | baml_language/sdk_tests/codegen/src/java.rs:48-53 | baml_language/sdk_tests/codegen/src/python_pydantic2.rs:40-45 | baml_language/sdk_tests/codegen/src/rust.rs:179-184 | baml_language/sdk_tests/codegen/src/swift.rs:32-37 — 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 5 call sites, so a change lands once.
Duplicated block (5 lines × 5) baml_language/crates/baml_lsp/src/dispatch/requests.rs:409— baml_language/crates/baml_lsp/src/dispatch/requests.rs:409-413 | baml_language/crates/baml_lsp/src/dispatch/requests.rs:588-592 | baml_language/crates/baml_lsp/src/dispatch/requests.rs:680-684 | baml_language/crates/baml_lsp/src/dispatch/requests.rs:783-787 | baml_language/crates/baml_lsp/src/dispatch/requests.rs:805-809 — 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 (5 lines × 5) baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:243— baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:243-247 | baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:357-361 | baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:482-486 | baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:618-622 | baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:765-769 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:243` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. 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, `baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:362` calls `t4`, `onT4` and `baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:248` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (5 lines × 5) baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:252— baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:252-256 | baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:367-371 | baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:493-497 | baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:630-634 | baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:778-782 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:252` it does not close everything it opens, so those 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, `baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:372` calls `t4`, `onT4` and `baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:257` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (5 lines × 4) baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs:188— baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs:188-192 | baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs:386-390 | engine/baml-lib/jsonish/src/jsonish/parser/fixing_parser/json_parse_state.rs:216-220 | engine/baml-lib/jsonish/src/jsonish/parser/fixing_parser/json_parse_state.rs:413-417 — before extracting anything, compare `baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs` and `engine/baml-lib/jsonish/src/jsonish/parser/fixing_parser/json_parse_state.rs` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 575 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, 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 × 4) languages/rust/baml/src/async_stream.rs:120— languages/rust/baml/src/async_stream.rs:120-124 | languages/rust/baml/src/async_stream.rs:126-130 | languages/rust/baml/src/stream.rs:100-104 | languages/rust/baml/src/stream.rs:106-110 — 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.
Duplicated block (5 lines × 4) engine/language_client_go/pkg/rawobjects_class_builder.go:21— engine/language_client_go/pkg/rawobjects_class_builder.go:21-25 | engine/language_client_go/pkg/rawobjects_class_property_builder.go:21-25 | engine/language_client_go/pkg/rawobjects_enum_builder.go:21-25 | engine/language_client_go/pkg/rawobjects_enum_value_builder.go:20-24 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 4 call sites, so a change lands once.
P12 · CI test-gate honesty· Test failure does not fail the CI gate · ×3
Test failure does not fail the CI gate REDACTED:1664— `continue-on-error: true` lets the step or job that runs `dotnet run --project baml_language/sdks/csharp/bridge_csharp/tools/Baml.NuGetNormalizer/Baml.NuGetNormalizer.csproj -- --self-test` fail without failing the pipeline — the suite can go red and the change still merges. Remove it from the test step, or quarantine the specific failing tests instead.
Test failure does not fail the CI gate REDACTED:2572— `continue-on-error: true` lets the step or job that runs `pnpm --filter app-vscode-webview test:unit:run` fail without failing the pipeline — the suite can go red and the change still merges. Remove it from the test step, or quarantine the specific failing tests instead.
Test failure does not fail the CI gate REDACTED:2637— `continue-on-error: true` lets the step or job that runs `pnpm --filter app-vscode-webview test:browser:run` fail without failing the pipeline — the suite can go red and the change still merges. Remove it from the test step, or quarantine the specific failing tests instead.
R10 · Code Duplication· Duplicated block with local edits (96 matched lines × 2 locations) · ×3
Duplicated block with local edits (96 matched lines × 2 locations) typescript/packages/playground-common/src/shared/baml-project-panel/codemirror-panel/code-mirror-viewer.tsx:175— typescript/packages/playground-common/src/shared/baml-project-panel/codemirror-panel/code-mirror-viewer.tsx:175 · typescript2/app-website/lib/mdx/baml-block/baml-project-panel/codemirror-panel/code-mirror-viewer.tsx:105 — the two spans are one implementation copied and then locally edited — 505 tokens are still identical, in the same order in both files, with only local edits between them. The copies have already begun to drift, which is this row's finding: an edit made to one and not the other changes behaviour silently. Diff the two spans first to learn what genuinely differs, then extract the shared core into one module both sites use, passing the differences in as parameters — or, if one copy exists only because the other could not be imported from its context, make one of them the single source the other is generated or re-exported from. If one copy is no longer reachable, delete it rather than letting it shadow the live one.
Duplicated block with local edits (96 matched lines × 2 locations) typescript2/app-beps/src/components/decisions/decision-card.tsx:47— typescript2/app-beps/src/components/decisions/decision-card.tsx:47 · typescript2/app-beps/src/components/issues/issue-card.tsx:52 — the two spans are one implementation copied and then locally edited — 555 tokens are still identical, in the same order in both files, with only local edits between them. The copies have already begun to drift, which is this row's finding: an edit made to one and not the other changes behaviour silently. Diff the two spans first to learn what genuinely differs, then extract the shared core into one module both sites use, passing the differences in as parameters — or, if one copy exists only because the other could not be imported from its context, make one of them the single source the other is generated or re-exported from. If one copy is no longer reachable, delete it rather than letting it shadow the live one.
Duplicated block with local edits (96 matched lines × 2 locations) typescript2/app-beps/src/lib/export-all-utils.ts:48— typescript2/app-beps/src/lib/export-all-utils.ts:48 · typescript2/app-beps/src/lib/export-utils.ts:39 — the two spans are one implementation copied and then locally edited — 647 tokens are still identical, in the same order in both files, 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.
Vm::exec (cyclomatic 149) engine/baml-vm/src/vm.rs:623— Vm::exec has cyclomatic complexity 149 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Vm::process_notifications (cyclomatic 16) engine/baml-vm/src/vm.rs:489— Vm::process_notifications 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.
Bytecode::instruction_to_opcode (cyclomatic 137) baml_language/crates/bex_vm_types/src/bytecode.rs:2985— Bytecode::instruction_to_opcode has cyclomatic complexity 137 (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: OpCode::try_from (cyclomatic 140) 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.
Bytecode::lower (cyclomatic 24) baml_language/crates/bex_vm_types/src/bytecode.rs:2534— Bytecode::lower 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. This is NOT this file's highest cyclomatic complexity: OpCode::try_from (cyclomatic 140) 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.
cargo_stow::generate_dependency_graph_svg (cyclomatic 110) baml_language/crates/tools_stow/src/main.rs:1626— cargo_stow::generate_dependency_graph_svg has cyclomatic complexity 110 (threshold 15). Of this number, 103 points are the body's own statements and 7 belong to 2 function items inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
cargo_stow::main (cyclomatic 31) baml_language/crates/tools_stow/src/main.rs:2577— cargo_stow::main 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.
HirCompiler::compile_expression (cyclomatic 86) engine/baml-compiler/src/codegen.rs:1082— HirCompiler::compile_expression has cyclomatic complexity 86 (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.
HirCompiler::compile_statement (cyclomatic 58) engine/baml-compiler/src/codegen.rs:574— HirCompiler::compile_statement has cyclomatic complexity 58 (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.
baml_cffi_macros::export_baml_fn (cyclomatic 69) engine/baml_cffi_macros/src/lib.rs:6— baml_cffi_macros::export_baml_fn has cyclomatic complexity 69 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
baml_cffi_macros::generate_param_extraction (cyclomatic 22) engine/baml_cffi_macros/src/lib.rs:1167— baml_cffi_macros::generate_param_extraction 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.
Flag::fmt (cyclomatic 41) baml_language/crates/bex_sap/src/deserializer/deserialize_flags.rs:142— Flag::fmt 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.
Flag::fmt (cyclomatic 39) engine/baml-lib/jsonish/src/deserializer/deserialize_flags.rs:157— Flag::fmt 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.
bex_vm_types::head_walk::visit_object_heads (cyclomatic 39) baml_language/crates/bex_vm_types/src/head_walk.rs:186— bex_vm_types::head_walk::visit_object_heads has cyclomatic complexity 39 (threshold 15). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline. This shape REPEATS in the file: one other method here (bex_vm_types::head_walk::visit_object_heads_mut) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
bex_vm_types::head_walk::visit_object_heads_mut (cyclomatic 39) baml_language/crates/bex_vm_types/src/head_walk.rs:188— bex_vm_types::head_walk::visit_object_heads_mut has cyclomatic complexity 39 (threshold 15). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline. This shape REPEATS in the file: one other method here (bex_vm_types::head_walk::visit_object_heads) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
bex_external_types::host_return::value_satisfies_ty (cyclomatic 38) baml_language/crates/bex_external_types/src/host_return.rs:166— bex_external_types::host_return::value_satisfies_ty 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.
bex_external_types::bex_external_value::measure_external_value (cyclomatic 17) baml_language/crates/bex_external_types/src/bex_external_value.rs:865— bex_external_types::bex_external_value::measure_external_value 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: BexExternalValue::eq (cyclomatic 25) 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.
Analysis::new (cyclomatic 35) baml_language/crates/baml_compiler2_rust/src/structure.rs:211— Analysis::new has cyclomatic complexity 35 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Analysis::new (cyclomatic 18) baml_language/crates/baml_compiler2_mir/src/optimize/effects.rs:557— Analysis::new has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
btel_file::reader::validate_file (cyclomatic 35) baml_language/crates/btel_file/src/reader.rs:138— btel_file::reader::validate_file has cyclomatic complexity 35 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
btel_file::reader::check_references (cyclomatic 30) baml_language/crates/btel_file/src/reader.rs:289— btel_file::reader::check_references 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.
btel_bcs::delivery::run_worker (cyclomatic 33) baml_language/crates/btel_bcs/src/delivery.rs:1777— btel_bcs::delivery::run_worker 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.
btel_bcs::plan::validate_response (cyclomatic 22) baml_language/crates/btel_bcs/src/plan.rs:85— btel_bcs::plan::validate_response 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.
FunctionMetadata::analyze_statement (cyclomatic 33) engine/baml-compiler/src/watch.rs:246— FunctionMetadata::analyze_statement 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.
FunctionMetadata::analyze_expression (cyclomatic 26) engine/baml-compiler/src/watch.rs:405— FunctionMetadata::analyze_expression has cyclomatic complexity 26 (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.
generators_rust::ir_to_rust::stream_type_to_rust (cyclomatic 33) engine/generators/languages/rust/src/ir_to_rust/mod.rs:24— generators_rust::ir_to_rust::stream_type_to_rust 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.
generators_rust::ir_to_rust::type_to_rust (cyclomatic 23) engine/generators/languages/rust/src/ir_to_rust/mod.rs:220— generators_rust::ir_to_rust::type_to_rust 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.
bex_heap::accessor::convert_object (cyclomatic 32) baml_language/crates/bex_heap/src/accessor.rs:609— bex_heap::accessor::convert_object 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.
bex_heap::accessor::owned_inner (cyclomatic 27) baml_language/crates/bex_heap/src/accessor.rs:480— bex_heap::accessor::owned_inner 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.
generators_go::ir_to_go::stream_type_to_go (cyclomatic 32) engine/generators/languages/go/src/ir_to_go/mod.rs:18— generators_go::ir_to_go::stream_type_to_go 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.
generators_go::ir_to_go::type_to_go (cyclomatic 22) engine/generators/languages/go/src/ir_to_go/mod.rs:202— generators_go::ir_to_go::type_to_go has cyclomatic complexity 22 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
TelemetryState::complete_invocation_at (cyclomatic 31) baml_language/crates/bex_vm/src/telemetry.rs:971— TelemetryState::complete_invocation_at has cyclomatic complexity 31 (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.
TelemetryState::enter_bytecode_with_trace (cyclomatic 29) baml_language/crates/bex_vm/src/telemetry.rs:746— TelemetryState::enter_bytecode_with_trace has cyclomatic complexity 29 (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.
internal_baml_jinja::render_minijinja (cyclomatic 31) engine/baml-lib/jinja-runtime/src/lib.rs:217— internal_baml_jinja::render_minijinja 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.
internal_baml_jinja::minijinja_value_to_json (cyclomatic 21) engine/baml-lib/jinja-runtime/src/lib.rs:35— internal_baml_jinja::minijinja_value_to_json 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.
baml_cli::describe_command::write_description (cyclomatic 30) baml_language/crates/baml_cli/src/describe_command.rs:662— baml_cli::describe_command::write_description 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.
baml_cli::describe_command::write_interface_body (cyclomatic 18) baml_language/crates/baml_cli/src/describe_command.rs:1101— baml_cli::describe_command::write_interface_body has cyclomatic complexity 18 (threshold 15). Of this number, 16 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.
StackifyCodegen::emit_terminator (cyclomatic 29) baml_language/crates/baml_compiler2_emit/src/emit.rs:2306— StackifyCodegen::emit_terminator has cyclomatic complexity 29 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing. This is NOT this file's highest cyclomatic complexity: StackifyCodegen::try_specialize_binary_op (cyclomatic 41) 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.
StackifyCodegen::emit_statement (cyclomatic 26) baml_language/crates/baml_compiler2_emit/src/emit.rs:1288— StackifyCodegen::emit_statement has cyclomatic complexity 26 (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: StackifyCodegen::try_specialize_binary_op (cyclomatic 41) 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.
Scratch::capture (cyclomatic 28) baml_language/crates/bex_vm/src/telemetry/snapshot.rs:132— Scratch::capture 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.
Scratch::add (cyclomatic 22) baml_language/crates/bex_vm/src/telemetry/snapshot.rs:54— Scratch::add has cyclomatic complexity 22 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
RenderDefinitionEquivalence::types_equivalent (cyclomatic 27) baml_language/crates/bex_vm/src/package_reflect/type_class.rs:710— RenderDefinitionEquivalence::types_equivalent has cyclomatic complexity 27 (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.
RenderDefinitionEquivalence::definitions_equivalent (cyclomatic 17) baml_language/crates/bex_vm/src/package_reflect/type_class.rs:614— RenderDefinitionEquivalence::definitions_equivalent 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.
Facts::project (cyclomatic 26) baml_language/crates/baml_compiler2_hir_ty/src/facts.rs:246— Facts::project 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.
Facts::statement (cyclomatic 20) baml_language/crates/baml_compiler2_mir/src/optimize/effects.rs:279— Facts::statement has cyclomatic complexity 20 (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.
baml_type_runtime::collect (cyclomatic 26) baml_language/crates/baml_type_runtime/src/lib.rs:352— baml_type_runtime::collect has cyclomatic complexity 26 (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.
baml_type_runtime::solve_var (cyclomatic 16) baml_language/crates/baml_type_runtime/src/lib.rs:200— baml_type_runtime::solve_var 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.
ImplResolver::match_template (cyclomatic 26) baml_language/crates/bex_vm/src/package_baml/resolve.rs:1072— ImplResolver::match_template has cyclomatic complexity 26 (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.
ImplResolver::hash_eligible (cyclomatic 17) baml_language/crates/bex_vm/src/package_baml/resolve.rs:479— ImplResolver::hash_eligible 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.
bridge_ctypes::value_encode::external_to_outbound (cyclomatic 25) baml_language/crates/bridge_ctypes/src/value_encode.rs:23— bridge_ctypes::value_encode::external_to_outbound 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.
bridge_ctypes::value_decode::decode_inbound (cyclomatic 24) baml_language/crates/bridge_ctypes/src/value_decode.rs:101— bridge_ctypes::value_decode::decode_inbound 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.
AwsClient::stream_chat (cyclomatic 25) engine/baml-runtime/src/internal/llm_client/primitive/aws/aws_client.rs:902— AwsClient::stream_chat 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.
AwsClient::chat (cyclomatic 16) engine/baml-runtime/src/internal/llm_client/primitive/aws/aws_client.rs:1350— AwsClient::chat 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.
ExprBody::expr_children (cyclomatic 24) baml_language/crates/baml_compiler2_ast/src/traverse.rs:38— ExprBody::expr_children 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.
ExprBody::display_expr_inner (cyclomatic 22) baml_language/crates/baml_compiler2_ast/src/ast.rs:490— ExprBody::display_expr_inner has cyclomatic complexity 22 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
ExprIterator::next (cyclomatic 24) engine/baml-lib/baml-types/src/expr.rs:887— ExprIterator::next 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.
ExprIterator::next (cyclomatic 21) engine/baml-compiler/src/thir.rs:546— ExprIterator::next 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.
BamlValueWithFlags::explanation_impl (cyclomatic 24) engine/baml-lib/jsonish/src/deserializer/types.rs:292— BamlValueWithFlags::explanation_impl 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.
BamlValueWithFlags::fmt (cyclomatic 22) engine/baml-lib/jsonish/src/deserializer/types.rs:589— BamlValueWithFlags::fmt 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.
MermaidDiagramGenerator::visit_expression (cyclomatic 23) engine/baml-lib/ast/src/ast/baml_vis/mermaid_debug.rs:421— MermaidDiagramGenerator::visit_expression 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.
MermaidDiagramGenerator::visit_stmt (cyclomatic 20) engine/baml-lib/ast/src/ast/baml_vis/mermaid_debug.rs:645— MermaidDiagramGenerator::visit_stmt has cyclomatic complexity 20 (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.
UnresolvedAwsBedrock::resolve (cyclomatic 22) engine/baml-lib/llm-client/src/clients/aws_bedrock.rs:249— UnresolvedAwsBedrock::resolve 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.
UnresolvedAwsBedrock::create_from (cyclomatic 16) engine/baml-lib/llm-client/src/clients/aws_bedrock.rs:430— UnresolvedAwsBedrock::create_from 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.
FieldType::repr (cyclomatic 21) engine/baml-lib/baml-core/src/ir/repr.rs:1885— FieldType::repr 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.
FieldType::attributes (cyclomatic 16) engine/baml-lib/baml-core/src/ir/repr.rs:1784— FieldType::attributes 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. This is NOT this file's highest cyclomatic complexity: internal_baml_core::ir::repr::annotate_variable (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.
generators_ruby::ir_to_rb::stream_type_to_rb (cyclomatic 21) engine/generators/languages/ruby/src/ir_to_rb/mod.rs:18— generators_ruby::ir_to_rb::stream_type_to_rb 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.
generators_ruby::ir_to_rb::type_to_rb (cyclomatic 18) engine/generators/languages/ruby/src/ir_to_rb/mod.rs:138— generators_ruby::ir_to_rb::type_to_rb 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.
bex_prof_store::prof::backend::function_table::decode_function_table (cyclomatic 19) baml_language/crates/bex_prof_store/src/prof/backend/function_table.rs:160— bex_prof_store::prof::backend::function_table::decode_function_table 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.
bex_prof_store::prof::backend::reader::merge_evidence (cyclomatic 17) baml_language/crates/bex_prof_store/src/prof/backend/reader.rs:875— bex_prof_store::prof::backend::reader::merge_evidence 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.
WasmRuntime::run_tests (cyclomatic 19) engine/baml-schema-wasm/src/runtime_wasm/mod.rs:2027— WasmRuntime::run_tests 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.
WasmRuntime::list_testcases (cyclomatic 17) engine/baml-schema-wasm/src/runtime_wasm/mod.rs:1823— WasmRuntime::list_testcases 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.
generators_python::ir_to_py::stream_type_to_py (cyclomatic 19) engine/generators/languages/python/src/ir_to_py/mod.rs:17— generators_python::ir_to_py::stream_type_to_py 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.
generators_python::watchers::build_notification_collectors (cyclomatic 19) engine/generators/languages/python/src/watchers.rs:143— generators_python::watchers::build_notification_collectors 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.
baml_compiler_syntax::ast::apply_block_tag_whitespace_rule::alone_on_line_strips (cyclomatic 18) baml_language/crates/baml_compiler_syntax/src/ast.rs:1204— baml_compiler_syntax::ast::apply_block_tag_whitespace_rule::alone_on_line_strips 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.
baml_compiler_syntax::ast::validate_block_structure (cyclomatic 18) baml_language/crates/baml_compiler_syntax/src/ast.rs:1436— baml_compiler_syntax::ast::validate_block_structure 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.
bex_events::history::history_run_matches_filter (cyclomatic 18) baml_language/crates/bex_events/src/history/mod.rs:746— bex_events::history::history_run_matches_filter 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.
bex_events::run::run_matches_filter (cyclomatic 18) baml_language/crates/bex_events/src/run.rs:1569— bex_events::run::run_matches_filter 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.
route.GET (cyclomatic 16) REDACTED:519— route.GET 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.
route.GET (cyclomatic 16) typescript2/app-beps/src/app/api/auth/github/callback/route.ts:53— route.GET has cyclomatic complexity 16 (threshold 15). Of this number, 15 points are the body's own statements and 1 belongs to one function literal inside it that branches. 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.
Vm::exec (cognitive 242) engine/baml-vm/src/vm.rs:623— Vm::exec has cognitive complexity 242 (threshold 15). Drivers by points: if/else 49 (164 pts), match/switch 22 (66 pts), loops 4 (10 pts), boolean chains 2 (nesting depth added 165). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Vm::process_notifications (cognitive 28) engine/baml-vm/src/vm.rs:489— Vm::process_notifications has cognitive complexity 28 (threshold 15). Drivers by points: if/else 4 (14 pts), match/switch 4 (10 pts), loops 2 (4 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.
HirCompiler::compile_expression (cognitive 111) engine/baml-compiler/src/codegen.rs:1082— HirCompiler::compile_expression has cognitive complexity 111 (threshold 15). Drivers by points: if/else 26 (65 pts), match/switch 12 (27 pts), loops 8 (18 pts), boolean chains 1 (nesting depth added 64). 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.
HirCompiler::compile_statement (cognitive 58) engine/baml-compiler/src/codegen.rs:574— HirCompiler::compile_statement has cognitive complexity 58 (threshold 15). Drivers by points: if/else 13 (33 pts), match/switch 11 (22 pts), loops 1 (3 pts) (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.
HashDriver::drive (cognitive 89) baml_language/crates/bex_vm/src/package_baml/hashing.rs:40— HashDriver::drive has cognitive complexity 89 (threshold 15). Drivers by points: if/else 17 (58 pts), match/switch 6 (22 pts), loops 3 (9 pts) (nesting depth added 63). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
HashDriver::apply_forwarding (cognitive 17) baml_language/crates/bex_vm/src/package_baml/hashing.rs:236— HashDriver::apply_forwarding has cognitive complexity 17 (threshold 15). Drivers by points: if/else 4 (11 pts), loops 2 (4 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.
baml_derive::derive_baml_hash (cognitive 88) engine/baml-lib/baml-derive/src/lib.rs:47— baml_derive::derive_baml_hash has cognitive complexity 88 (threshold 15). Drivers by points: if/else 40 (81 pts), boolean chains 3, match/switch 2 (3 pts), loops 1 (nesting depth added 42). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
baml_derive::is_option_of_float (cognitive 29) engine/baml-lib/baml-derive/src/lib.rs:19— baml_derive::is_option_of_float has cognitive complexity 29 (threshold 15). Drivers by points: if/else 7 (28 pts), boolean chains 1 (nesting depth added 21). 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.
Bulk::apply (cognitive 85) baml_language/crates/baml_query_btel/src/ingest/bulk.rs:546— Bulk::apply has cognitive complexity 85 (threshold 15). Drivers by points: if/else 15 (38 pts), match/switch 5 (24 pts), loops 9 (19 pts), boolean chains 4 (nesting depth added 52). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Bulk::resolve_nodes (cognitive 20) baml_language/crates/baml_query_btel/src/ingest/bulk.rs:1290— Bulk::resolve_nodes has cognitive complexity 20 (threshold 15). Drivers by points: if/else 4 (12 pts), loops 3 (5 pts), match/switch 1 (3 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Analysis::new (cognitive 66) baml_language/crates/baml_compiler2_rust/src/structure.rs:211— Analysis::new has cognitive complexity 66 (threshold 15). Drivers by points: if/else 14 (34 pts), loops 19 (27 pts), match/switch 1 (4 pts), boolean chains 1 (nesting depth added 31). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Analysis::new (cognitive 30) baml_language/crates/baml_compiler2_mir/src/optimize/effects.rs:557— Analysis::new has cognitive complexity 30 (threshold 15). Drivers by points: if/else 8 (19 pts), loops 4 (6 pts), match/switch 2 (3 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.
internal_baml_jinja::render_minijinja (cognitive 60) engine/baml-lib/jinja-runtime/src/lib.rs:217— internal_baml_jinja::render_minijinja has cognitive complexity 60 (threshold 15). Drivers by points: if/else 16 (37 pts), match/switch 6 (14 pts), loops 3 (5 pts), boolean chains 4 (nesting depth added 31). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
internal_baml_jinja::minijinja_value_to_json (cognitive 47) engine/baml-lib/jinja-runtime/src/lib.rs:35— internal_baml_jinja::minijinja_value_to_json has cognitive complexity 47 (threshold 15). Drivers by points: if/else 16 (38 pts), loops 2 (8 pts), match/switch 1 (nesting depth added 28). 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.
Class::coerce (cognitive 57) engine/baml-lib/jsonish/src/deserializer/coercer/ir_ref/coerce_class.rs:136— Class::coerce has cognitive complexity 57 (threshold 15). Drivers by points: if/else 19 (33 pts), match/switch 10 (18 pts), loops 3 (4 pts), boolean chains 2 (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.
Class::try_cast (cognitive 22) engine/baml-lib/jsonish/src/deserializer/coercer/ir_ref/coerce_class.rs:24— Class::try_cast has cognitive complexity 22 (threshold 15). Drivers by points: if/else 11 (18 pts), boolean chains 2, 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.
Applier::apply (cognitive 56) baml_language/crates/baml_query_btel/src/ingest.rs:1068— Applier::apply has cognitive complexity 56 (threshold 15). Drivers by points: if/else 10 (25 pts), loops 9 (19 pts), match/switch 2 (10 pts), boolean chains 2 (nesting depth added 33). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Applier::function (cognitive 17) baml_language/crates/baml_query_btel/src/ingest.rs:1523— Applier::function has cognitive complexity 17 (threshold 15). Drivers by points: if/else 5 (11 pts), loops 1 (3 pts), match/switch 2 (3 pts) (nesting depth added 9). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
UnresolvedAwsBedrock::resolve (cognitive 45) engine/baml-lib/llm-client/src/clients/aws_bedrock.rs:249— UnresolvedAwsBedrock::resolve has cognitive complexity 45 (threshold 15). Drivers by points: if/else 15 (26 pts), match/switch 12 (19 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.
UnresolvedAwsBedrock::create_from (cognitive 24) engine/baml-lib/llm-client/src/clients/aws_bedrock.rs:430— UnresolvedAwsBedrock::create_from has cognitive complexity 24 (threshold 15). Drivers by points: match/switch 8 (20 pts), if/else 2, loops 1 (2 pts) (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.
Code::group (cognitive 44) baml_language/crates/btel_reader/src/value/code.rs:220— Code::group has cognitive complexity 44 (threshold 15). Drivers by points: if/else 9 (25 pts), loops 7 (15 pts), match/switch 2 (4 pts) (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.
Code::visit (cognitive 20) baml_language/crates/btel_reader/src/value/code.rs:137— Code::visit has cognitive complexity 20 (threshold 15). Drivers by points: loops 5 (10 pts), if/else 5 (7 pts), match/switch 1 (3 pts) (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.
generators_rust::ir_to_rust::stream_type_to_rust (cognitive 43) engine/generators/languages/rust/src/ir_to_rust/mod.rs:24— generators_rust::ir_to_rust::stream_type_to_rust has cognitive complexity 43 (threshold 15). Drivers by points: if/else 15 (29 pts), match/switch 7 (14 pts) (nesting depth added 21). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
generators_rust::ir_to_rust::type_to_rust (cognitive 23) engine/generators/languages/rust/src/ir_to_rust/mod.rs:220— generators_rust::ir_to_rust::type_to_rust has cognitive complexity 23 (threshold 15). Drivers by points: if/else 9 (17 pts), match/switch 3 (5 pts), boolean chains 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
generators_go::ir_to_go::stream_type_to_go (cognitive 40) engine/generators/languages/go/src/ir_to_go/mod.rs:18— generators_go::ir_to_go::stream_type_to_go has cognitive complexity 40 (threshold 15). Drivers by points: if/else 13 (26 pts), match/switch 7 (14 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.
generators_go::ir_to_go::type_to_go (cognitive 20) engine/generators/languages/go/src/ir_to_go/mod.rs:202— generators_go::ir_to_go::type_to_go has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (14 pts), match/switch 3 (5 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.
FunctionMetadata::analyze_statement (cognitive 38) engine/baml-compiler/src/watch.rs:246— FunctionMetadata::analyze_statement has cognitive complexity 38 (threshold 15). Drivers by points: if/else 11 (25 pts), match/switch 3 (7 pts), loops 3 (6 pts) (nesting depth added 21). 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.
FunctionMetadata::analyze_expression (cognitive 22) engine/baml-compiler/src/watch.rs:405— FunctionMetadata::analyze_expression has cognitive complexity 22 (threshold 15). Drivers by points: loops 7 (14 pts), match/switch 3 (6 pts), if/else 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.
baml_compiler_diagnostics::render::apply_message_styles (cognitive 37) baml_language/crates/baml_compiler_diagnostics/src/render.rs:765— baml_compiler_diagnostics::render::apply_message_styles has cognitive complexity 37 (threshold 15). Drivers by points: if/else 11 (32 pts), loops 2 (4 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.
baml_compiler_diagnostics::render::render_agent (cognitive 17) baml_language/crates/baml_compiler_diagnostics/src/render.rs:1086— baml_compiler_diagnostics::render::render_agent has cognitive complexity 17 (threshold 15). Drivers by points: if/else 10 (13 pts), loops 2, match/switch 1 (2 pts) (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
GraphBuilder::build_header (cognitive 37) engine/baml-lib/ast/src/ast/baml_vis/graph.rs:424— GraphBuilder::build_header has cognitive complexity 37 (threshold 15). Drivers by points: if/else 14 (22 pts), loops 6 (14 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.
GraphBuilder::classify_and_filter_headers (cognitive 18) engine/baml-lib/ast/src/ast/baml_vis/graph.rs:258— GraphBuilder::classify_and_filter_headers has cognitive complexity 18 (threshold 15). Drivers by points: if/else 9 (14 pts), boolean chains 2, loops 2 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
MapLiteral::single_line_width (cognitive 34) baml_language/crates/baml_fmt/src/ast/expressions.rs:4446— MapLiteral::single_line_width has cognitive complexity 34 (threshold 15). Drivers by points: loops 9 (21 pts), if/else 8 (12 pts), boolean chains 1 (nesting depth added 16). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
MapLiteral::try_print_single_line (cognitive 20) baml_language/crates/baml_fmt/src/ast/expressions.rs:4520— MapLiteral::try_print_single_line has cognitive complexity 20 (threshold 15). Drivers by points: if/else 12 (18 pts), boolean chains 1, 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.
baml_type_runtime::collect (cognitive 30) baml_language/crates/baml_type_runtime/src/lib.rs:352— baml_type_runtime::collect has cognitive complexity 30 (threshold 15). Drivers by points: if/else 6 (15 pts), loops 6 (12 pts), boolean chains 2, match/switch 1 (nesting depth added 15). 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.
baml_type_runtime::solve_var (cognitive 23) baml_language/crates/baml_type_runtime/src/lib.rs:200— baml_type_runtime::solve_var has cognitive complexity 23 (threshold 15). Drivers by points: if/else 4 (11 pts), match/switch 4 (6 pts), loops 3 (5 pts), boolean chains 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
FieldType::repr (cognitive 30) engine/baml-lib/baml-core/src/ir/repr.rs:1885— FieldType::repr has cognitive complexity 30 (threshold 15). Drivers by points: if/else 11 (18 pts), match/switch 4 (9 pts), loops 1 (2 pts), boolean chains 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
FieldType::attributes (cognitive 16) engine/baml-lib/baml-core/src/ir/repr.rs:1784— FieldType::attributes has cognitive complexity 16 (threshold 15). Drivers by points: match/switch 5 (8 pts), if/else 5 (7 pts), loops 1 (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.
BamlValueWithFlags::explanation_impl (cognitive 30) engine/baml-lib/jsonish/src/deserializer/types.rs:292— BamlValueWithFlags::explanation_impl has cognitive complexity 30 (threshold 15). Drivers by points: if/else 11 (23 pts), loops 3 (6 pts), match/switch 1 (nesting depth added 15). 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.
BamlValueWithFlags::fmt (cognitive 25) engine/baml-lib/jsonish/src/deserializer/types.rs:589— BamlValueWithFlags::fmt has cognitive complexity 25 (threshold 15). Drivers by points: if/else 9 (18 pts), loops 3 (6 pts), match/switch 1 (nesting depth added 12). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
baml_vm::debug::display_bytecode (cognitive 29) engine/baml-vm/src/debug.rs:257— baml_vm::debug::display_bytecode has cognitive complexity 29 (threshold 15). Drivers by points: if/else 6 (13 pts), loops 5 (9 pts), match/switch 2 (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.
baml_vm::native::deep_equals_recursive (cognitive 22) engine/baml-vm/src/native.rs:502— baml_vm::native::deep_equals_recursive has cognitive complexity 22 (threshold 15). Drivers by points: boolean chains 9, if/else 4 (7 pts), match/switch 3 (6 pts) (nesting depth added 6). 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.
GEPAOrchestrator::run (cognitive 28) engine/baml-runtime/src/optimize/orchestrator.rs:170— GEPAOrchestrator::run has cognitive complexity 28 (threshold 15). Drivers by points: if/else 10 (23 pts), boolean chains 4, 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.
GEPAOrchestrator::check_convergence (cognitive 21) engine/baml-runtime/src/optimize/orchestrator.rs:558— GEPAOrchestrator::check_convergence has cognitive complexity 21 (threshold 15). Drivers by points: if/else 8 (20 pts), boolean chains 1 (nesting depth added 12). 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.
bex_prof_store::prof::backend::reader::merge_evidence (cognitive 27) baml_language/crates/bex_prof_store/src/prof/backend/reader.rs:875— bex_prof_store::prof::backend::reader::merge_evidence has cognitive complexity 27 (threshold 15). Drivers by points: if/else 7 (21 pts), match/switch 2 (5 pts), loops 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.
bex_prof_store::prof::backend::function_table::decode_function_table (cognitive 16) baml_language/crates/bex_prof_store/src/prof/backend/function_table.rs:160— bex_prof_store::prof::backend::function_table::decode_function_table has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (6 pts), match/switch 3 (6 pts), loops 3 (4 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.
TracePublisher::run (cognitive 27) engine/baml-runtime/src/tracingv2/publisher/publisher.rs:403— TracePublisher::run has cognitive complexity 27 (threshold 15). Drivers by points: if/else 6 (21 pts), match/switch 2 (5 pts), 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.
TracePublisher::process_batch_impl (cognitive 20) engine/baml-runtime/src/tracingv2/publisher/publisher.rs:694— TracePublisher::process_batch_impl has cognitive complexity 20 (threshold 15). Drivers by points: if/else 8 (16 pts), loops 1 (3 pts), match/switch 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.
EqualsDriver::compare_objects (cognitive 26) baml_language/crates/bex_vm/src/package_baml/ops.rs:459— EqualsDriver::compare_objects has cognitive complexity 26 (threshold 15). Drivers by points: if/else 5 (11 pts), loops 3 (6 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.
EqualsDriver::drive (cognitive 22) baml_language/crates/bex_vm/src/package_baml/ops.rs:331— EqualsDriver::drive has cognitive complexity 22 (threshold 15). Drivers by points: if/else 6 (19 pts), match/switch 1 (2 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.
ParserDatabase::to_jinja_type (cognitive 26) engine/baml-lib/parser-database/src/walkers/mod.rs:319— ParserDatabase::to_jinja_type has cognitive complexity 26 (threshold 15). Drivers by points: if/else 9 (18 pts), match/switch 3 (5 pts), loops 1 (2 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.
ParserDatabase::finalize_dependencies (cognitive 20) engine/baml-lib/parser-database/src/lib.rs:149— ParserDatabase::finalize_dependencies has cognitive complexity 20 (threshold 15). Drivers by points: if/else 2 (9 pts), match/switch 2 (7 pts), loops 3 (4 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
RenderDefinitionEquivalence::types_equivalent (cognitive 25) baml_language/crates/bex_vm/src/package_reflect/type_class.rs:710— RenderDefinitionEquivalence::types_equivalent has cognitive complexity 25 (threshold 15). Drivers by points: boolean chains 10, if/else 4 (10 pts), loops 2 (4 pts), 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.
RenderDefinitionEquivalence::definitions_equivalent (cognitive 21) baml_language/crates/bex_vm/src/package_reflect/type_class.rs:614— RenderDefinitionEquivalence::definitions_equivalent has cognitive complexity 21 (threshold 15). Drivers by points: if/else 8 (14 pts), boolean chains 4, loops 1 (2 pts), match/switch 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.
TelemetryRuntime::write_span_with_context (cognitive 25) baml_language/crates/btel_processor/src/runtime.rs:632— TelemetryRuntime::write_span_with_context has cognitive complexity 25 (threshold 15). Drivers by points: if/else 11 (15 pts), boolean chains 6, match/switch 2 (4 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.
TelemetryRuntime::acquire_snapshot_slow (cognitive 16) baml_language/crates/btel_processor/src/runtime.rs:493— TelemetryRuntime::acquire_snapshot_slow has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (14 pts), boolean chains 1, 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.
Structural::decode (cognitive 24) baml_language/crates/bex_vm/src/package_baml/json/decode.rs:1412— Structural::decode has cognitive complexity 24 (threshold 15). Drivers by points: match/switch 9 (17 pts), if/else 4 (7 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.
Structural::literal (cognitive 19) baml_language/crates/bex_vm/src/package_baml/json/decode.rs:1706— Structural::literal has cognitive complexity 19 (threshold 15). Drivers by points: if/else 5 (9 pts), match/switch 5 (9 pts), boolean chains 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.
btel_reader::value::step (cognitive 24) baml_language/crates/btel_reader/src/value.rs:156— btel_reader::value::step has cognitive complexity 24 (threshold 15). Drivers by points: match/switch 6 (12 pts), if/else 5 (10 pts), loops 1 (2 pts) (nesting depth added 12). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own 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.
btel_reader::value::span::reach (cognitive 19) baml_language/crates/btel_reader/src/value/span.rs:170— btel_reader::value::span::reach has cognitive complexity 19 (threshold 15). Drivers by points: match/switch 6 (15 pts), if/else 1 (3 pts), 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.
sys_native::http_server::serve (cognitive 24) baml_language/crates/sys_native/src/http_server.rs:452— sys_native::http_server::serve has cognitive complexity 24 (threshold 15). Drivers by points: match/switch 7 (18 pts), loops 2 (3 pts), if/else 2, boolean chains 1 (nesting depth added 12). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own 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.
sys_native::io_impls::run_process (cognitive 16) baml_language/crates/sys_native/src/io_impls.rs:1716— sys_native::io_impls::run_process has cognitive complexity 16 (threshold 15). Drivers by points: if/else 9 (14 pts), match/switch 1 (2 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Assembler::fill_impl_rules (cognitive 23) baml_language/crates/baml_linker/src/assemble.rs:199— Assembler::fill_impl_rules has cognitive complexity 23 (threshold 15). Drivers by points: loops 8 (18 pts), if/else 2 (5 pts) (nesting depth added 13). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
Assembler::place (cognitive 20) baml_language/crates/baml_linker/src/assemble.rs:101— Assembler::place has cognitive complexity 20 (threshold 15). Drivers by points: loops 5 (11 pts), if/else 2 (8 pts), boolean chains 1 (nesting depth added 12). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
Scratch::add (cognitive 23) baml_language/crates/bex_vm/src/telemetry/snapshot.rs:54— Scratch::add has cognitive complexity 23 (threshold 15). Drivers by points: if/else 8 (14 pts), match/switch 5 (9 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.
Scratch::capture (cognitive 16) baml_language/crates/bex_vm/src/telemetry/snapshot.rs:132— Scratch::capture has cognitive complexity 16 (threshold 15). Drivers by points: if/else 3 (9 pts), match/switch 3 (6 pts), loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
bridge_wasm::wasm_http::sse_background_task (cognitive 23) baml_language/crates/bridge_wasm/src/wasm_http.rs:628— bridge_wasm::wasm_http::sse_background_task has cognitive complexity 23 (threshold 15). Drivers by points: if/else 2 (8 pts), match/switch 3 (8 pts), loops 3 (7 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.
bridge_wasm::wasm_io_glob::collect_scan_paths (cognitive 23) baml_language/crates/bridge_wasm/src/wasm_io_glob.rs:264— bridge_wasm::wasm_io_glob::collect_scan_paths has cognitive complexity 23 (threshold 15). Drivers by points: if/else 5 (13 pts), match/switch 2 (5 pts), loops 2 (3 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.
HotReloader::run (cognitive 23) engine/tools/src/bin/language-server-hot-reload.rs:172— HotReloader::run has cognitive complexity 23 (threshold 15). Drivers by points: if/else 5 (14 pts), loops 3 (7 pts), match/switch 1 (2 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.
HotReloader::start_stdin_forwarding (cognitive 18) engine/tools/src/bin/language-server-hot-reload.rs:111— HotReloader::start_stdin_forwarding has cognitive complexity 18 (threshold 15). Drivers by points: if/else 3 (9 pts), loops 2 (6 pts), match/switch 1 (3 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Expression::repr (cognitive 22) engine/baml-lib/baml-core/src/ir/repr.rs:349— Expression::repr has cognitive complexity 22 (threshold 15). Drivers by points: if/else 7 (10 pts), match/switch 5 (10 pts), loops 1 (2 pts) (nesting depth added 9). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
Expression::to_doc (cognitive 18) engine/baml-compiler/src/hir/dump.rs:423— Expression::to_doc has cognitive complexity 18 (threshold 15). Drivers by points: if/else 11 (17 pts), match/switch 1 (nesting depth added 6). 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.
HeaderCollector::build_index (cognitive 22) engine/baml-lib/ast/src/ast/baml_vis/header_collector.rs:555— HeaderCollector::build_index has cognitive complexity 22 (threshold 15). Drivers by points: if/else 6 (16 pts), loops 3 (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.
HeaderCollector::visit_expression (cognitive 16) engine/baml-lib/ast/src/ast/baml_vis/header_collector.rs:346— HeaderCollector::visit_expression has cognitive complexity 16 (threshold 15). Drivers by points: loops 5 (10 pts), match/switch 2 (4 pts), if/else 1 (2 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.
TypeGeneric::simplify (cognitive 22) engine/baml-lib/baml-types/src/ir_type/simplify/ir.rs:73— TypeGeneric::simplify has cognitive complexity 22 (threshold 15). Drivers by points: if/else 6 (15 pts), match/switch 2 (3 pts), boolean chains 2, 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.
TypeGeneric::to_union_name (cognitive 16) engine/baml-lib/baml-types/src/ir_type/mod.rs:931— TypeGeneric::to_union_name has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (11 pts), match/switch 3 (5 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.
Flag::fmt (cognitive 22) engine/baml-lib/jsonish/src/deserializer/deserialize_flags.rs:157— Flag::fmt has cognitive complexity 22 (threshold 15). Drivers by points: if/else 6 (13 pts), loops 4 (8 pts), match/switch 1 (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.
Flag::fmt (cognitive 16) baml_language/crates/bex_sap/src/deserializer/deserialize_flags.rs:142— Flag::fmt has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (9 pts), loops 3 (6 pts), 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.
LspRuntime::dispatch (cognitive 20) baml_language/crates/baml_lsp_server/src/lsp_runtime.rs:521— LspRuntime::dispatch has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (14 pts), match/switch 3 (5 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.
LspRuntime::record_applied_document (cognitive 18) baml_language/crates/baml_lsp_server/src/lsp_runtime.rs:769— LspRuntime::record_applied_document has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (14 pts), boolean chains 3, 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.
Tarjan::strong_connect (cognitive 20) baml_language/crates/baml_type/src/decl_cycles.rs:263— Tarjan::strong_connect has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (15 pts), loops 2 (3 pts), boolean chains 2 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Tarjan::strong_connect (cognitive 20) engine/baml-lib/parser-database/src/tarjan.rs:114— Tarjan::strong_connect has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (15 pts), loops 2 (3 pts), boolean chains 2 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
bridge_ctypes::value_decode::decode_inbound (cognitive 19) baml_language/crates/bridge_ctypes/src/value_decode.rs:101— bridge_ctypes::value_decode::decode_inbound has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (15 pts), match/switch 3 (4 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
bridge_ctypes::invocation::release_outbound_references (cognitive 16) baml_language/crates/bridge_ctypes/src/invocation.rs:14— bridge_ctypes::invocation::release_outbound_references has cognitive complexity 16 (threshold 15). Drivers by points: if/else 3 (8 pts), loops 3 (6 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.
forked_google_cloud_auth::project_id (cognitive 19) baml_language/forks/google-cloud-auth/src/lib.rs:281— forked_google_cloud_auth::project_id has cognitive complexity 19 (threshold 15). Drivers by points: if/else 9 (18 pts), loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
forked_google_cloud_auth::fetch_subject_token (cognitive 16) baml_language/forks/google-cloud-auth/src/lib.rs:561— forked_google_cloud_auth::fetch_subject_token has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (13 pts), loops 1 (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.
baml_base::escape::scan (cognitive 18) baml_language/crates/baml_base/src/escape.rs:328— baml_base::escape::scan has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (13 pts), boolean chains 2, match/switch 1 (2 pts), loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
baml_base::escape::decode_escape (cognitive 17) baml_language/crates/baml_base/src/escape.rs:388— baml_base::escape::decode_escape has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (10 pts), match/switch 4 (7 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.
baml_sdkgen_types::output_writer::legacy_csharp_owned_files (cognitive 18) baml_language/crates/baml_sdkgen_types/src/output_writer.rs:747— baml_sdkgen_types::output_writer::legacy_csharp_owned_files has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (13 pts), boolean chains 2, match/switch 2, loops 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
baml_sdkgen_types::output_writer::collect_unknown_files_in (cognitive 17) baml_language/crates/baml_sdkgen_types/src/output_writer.rs:1099— baml_sdkgen_types::output_writer::collect_unknown_files_in has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (14 pts), boolean chains 2, 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.
Span::visit (cognitive 18) baml_language/crates/btel_reader/src/value/span.rs:351— Span::visit has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (14 pts), loops 1 (3 pts), 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.
Span::load (cognitive 16) baml_language/crates/btel_reader/src/value/span.rs:288— Span::load has cognitive complexity 16 (threshold 15). Drivers by points: loops 5 (11 pts), if/else 1 (3 pts), match/switch 1 (2 pts) (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.
ReplState::dump_thir (cognitive 18) engine/baml-runtime/src/cli/repl.rs:310— ReplState::dump_thir has cognitive complexity 18 (threshold 15). Drivers by points: loops 6 (12 pts), if/else 6 (nesting depth added 6). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
ReplState::parse_and_evaluate_baml_expression_with_status (cognitive 16) engine/baml-runtime/src/cli/repl.rs:476— ReplState::parse_and_evaluate_baml_expression_with_status has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (12 pts), match/switch 3 (4 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.
Walk::always_null (cognitive 17) baml_language/crates/baml_compiler2_hir_ty/src/llm_output.rs:226— Walk::always_null has cognitive complexity 17 (threshold 15). Drivers by points: if/else 5 (10 pts), loops 2 (4 pts), boolean chains 2, match/switch 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.
Walk::run (cognitive 16) baml_language/crates/baml_ide/src/tokens.rs:528— Walk::run has cognitive complexity 16 (threshold 15). Drivers by points: if/else 3 (9 pts), match/switch 2 (5 pts), boolean chains 1, 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.
baml_bridge::host_value::release_callback_value (cognitive 16) baml_language/sdks/rust/bridge_rust/src/host_value.rs:909— baml_bridge::host_value::release_callback_value has cognitive complexity 16 (threshold 15). Drivers by points: if/else 3 (8 pts), loops 3 (6 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. This shape REPEATS in the file: one other method here (baml_bridge::host_value::clone_callback_value) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
baml_bridge::host_value::clone_callback_value (cognitive 16) baml_language/sdks/rust/bridge_rust/src/host_value.rs:992— baml_bridge::host_value::clone_callback_value has cognitive complexity 16 (threshold 15). Drivers by points: if/else 3 (8 pts), loops 3 (6 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. This shape REPEATS in the file: one other method here (baml_bridge::host_value::release_callback_value) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
Change-coupling hub: chat.rs → completion.rs, mod.rs, runtime_interface.rs engine/baml-runtime/src/internal/llm_client/traits/chat.rs— `engine/baml-runtime/src/internal/llm_client/traits/chat.rs` changes together with 3 other files — `engine/baml-runtime/src/internal/llm_client/traits/completion.rs`, `engine/baml-runtime/src/runtime/mod.rs`, `engine/baml-runtime/src/runtime_interface.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: llm_provider.rs → anthropic_client.rs, openai_client.rs, chat.rs, completion.rs engine/baml-runtime/src/internal/llm_client/llm_provider.rs— `engine/baml-runtime/src/internal/llm_client/llm_provider.rs` changes together with 4 other files — `engine/baml-runtime/src/internal/llm_client/primitive/anthropic/anthropic_client.rs`, `engine/baml-runtime/src/internal/llm_client/primitive/openai/openai_client.rs`, `engine/baml-runtime/src/internal/llm_client/traits/chat.rs`, `engine/baml-runtime/src/internal/llm_client/traits/completion.rs` — none of which declares a dependency on it: one file is the hub of 4 separate couplings, not 4 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 4.
Near-duplicate member pair (54 shared lines) baml_language/crates/bex_sap/src/jsonish/parser/entry.rs:16— baml_language/crates/bex_sap/src/jsonish/parser/entry.rs:16-225 | engine/baml-lib/jsonish/src/jsonish/parser/entry.rs:15-238 — These two members are variants of one another: 54 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Near-duplicate member pair (54 shared lines) engine/generators/languages/ruby/src/ir_to_rb/mod.rs:18— engine/generators/languages/ruby/src/ir_to_rb/mod.rs:18-136 | engine/generators/languages/ruby/src/ir_to_rb/mod.rs:138-234 — These two members are variants of one another: 54 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Near-duplicate member pair (50 shared lines) baml_language/crates/bex_vm/src/debug.rs:543— baml_language/crates/bex_vm/src/debug.rs:543-637 | engine/baml-vm/src/debug.rs:263-360 — These two members are variants of one another: 50 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Near-duplicate member pair (50 shared lines) baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:6256— baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:6256-6317 | baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:6323-6401 — These two members are variants of one another: 50 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Near-duplicate member pair (33 shared lines) baml_language/crates/baml_compiler2_hir_ty/src/lower.rs:1144— baml_language/crates/baml_compiler2_hir_ty/src/lower.rs:1144-1283 | baml_language/crates/baml_compiler2_hir_ty/src/lower.rs:1292-1416 — These two members are variants of one another: 33 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Near-duplicate member pair (33 shared lines) engine/generators/languages/python/src/watchers.rs:74— engine/generators/languages/python/src/watchers.rs:74-140 | engine/generators/languages/typescript/src/watchers.rs:73-136 — These two members are variants of one another: 33 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Near-duplicate member pair (32 shared lines) engine/baml-runtime/src/internal/llm_client/primitive/google/response_handler.rs:27— engine/baml-runtime/src/internal/llm_client/primitive/google/response_handler.rs:27-106 | engine/baml-runtime/src/internal/llm_client/primitive/vertex/response_handler.rs:27-108 — These two members are variants of one another: 32 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Near-duplicate member pair (32 shared lines) baml_language/crates/baml_type/src/normalize/mu.rs:666— baml_language/crates/baml_type/src/normalize/mu.rs:666-734 | baml_language/crates/baml_type/src/normalize/mu.rs:1396-1468 — These two members are variants of one another: 32 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication· Edited copy of a member (37 corresponding lines) · ×2
Edited copy of a member (37 corresponding lines) baml_language/crates/bex_sap/src/jsonish/value.rs:254— baml_language/crates/bex_sap/src/jsonish/value.rs:254-290 | engine/baml-lib/jsonish/src/jsonish/value.rs:196-232 — These two members are one piece of code written twice and then edited apart: 37 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (37 corresponding lines) baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:2692— baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:2692-2748 | baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:2750-2796 — These two members are one piece of code written twice and then edited apart: 37 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Duplicated block (34 lines × 2) baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs:87— baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs:87-120 | baml_language/crates/baml_type/src/unify.rs:197-230 — before extracting anything, compare `baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs` and `baml_language/crates/baml_type/src/unify.rs` as WHOLE FILES: this scan already matched 21 separate duplicated blocks between them, totalling at least 418 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, 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 (34 lines × 2) baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs:498— baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs:498-531 | engine/baml-lib/jsonish/src/jsonish/parser/fixing_parser/json_parse_state.rs:528-561 — before extracting anything, compare `baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs` and `engine/baml-lib/jsonish/src/jsonish/parser/fixing_parser/json_parse_state.rs` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 575 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, 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 (32–33 lines × 2) engine/baml-compiler/src/thir/typecheck.rs:933— engine/baml-compiler/src/thir/typecheck.rs:933-965 | engine/baml-compiler/src/thir/typecheck.rs:1092-1123 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (32–33 lines × 2) integ-tests/ruby/test_collector.rb:41— integ-tests/ruby/test_collector.rb:41-73 | integ-tests/ruby/test_collector.rb:162-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.
Duplicated block (30–32 lines × 2) baml_language/crates/baml_compiler_parser/src/parser.rs:5829— baml_language/crates/baml_compiler_parser/src/parser.rs:5829-5860 | baml_language/crates/baml_compiler_parser/src/parser.rs:7426-7455 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (30–32 lines × 2) engine/baml-runtime/src/internal/llm_client/primitive/google/googleai_client.rs:318— engine/baml-runtime/src/internal/llm_client/primitive/google/googleai_client.rs:318-347 | engine/baml-runtime/src/internal/llm_client/primitive/vertex/vertex_client.rs:523-554 — before extracting anything, compare `engine/baml-runtime/src/internal/llm_client/primitive/google/googleai_client.rs` and `engine/baml-runtime/src/internal/llm_client/primitive/vertex/vertex_client.rs` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 118 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, 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 (31 lines × 2) baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:9577— baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:9577-9607 | baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:9787-9817 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (31 lines × 2) baml_language/sdks/typescript/sdkgen_typescript_shared/src/sdkgen_typescript.rs:14— baml_language/sdks/typescript/sdkgen_typescript_shared/src/sdkgen_typescript.rs:14-44 | baml_language/sdks/typescript/sdkgen_typescript_shared/src/sdkgen_typescript_web.rs:17-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 both call sites, so a change lands once.
Duplicated block (27 lines × 2) baml_language/crates/bex_sap/src/jsonish/value.rs:84— baml_language/crates/bex_sap/src/jsonish/value.rs:84-110 | engine/baml-lib/jsonish/src/jsonish/value.rs:76-102 — before extracting anything, compare `baml_language/crates/bex_sap/src/jsonish/value.rs` and `engine/baml-lib/jsonish/src/jsonish/value.rs` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 160 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, 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 (27 lines × 2) engine/baml-runtime/src/internal/llm_client/orchestrator/call.rs:77— engine/baml-runtime/src/internal/llm_client/orchestrator/call.rs:77-103 | engine/baml-runtime/src/internal/llm_client/orchestrator/stream.rs:192-218 — before extracting anything, compare `engine/baml-runtime/src/internal/llm_client/orchestrator/call.rs` and `engine/baml-runtime/src/internal/llm_client/orchestrator/stream.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 90 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (22–25 lines × 2) baml_language/crates/baml_type/src/normalize.rs:1407— baml_language/crates/baml_type/src/normalize.rs:1407-1431 | baml_language/crates/baml_type/src/normalize.rs:3192-3213 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (22–25 lines × 2) baml_language/crates/btel_snapshot/src/graph.rs:358— baml_language/crates/btel_snapshot/src/graph.rs:358-382 | baml_language/crates/btel_snapshot/src/shape.rs:195-216 — 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 (23–24 lines × 2) baml_language/crates/bex_vm/src/debug.rs:227— baml_language/crates/bex_vm/src/debug.rs:227-249 | baml_language/crates/bex_vm/src/debug.rs:407-430 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (23–24 lines × 2) engine/baml-schema-wasm/src/runtime_wasm/mod.rs:2652— engine/baml-schema-wasm/src/runtime_wasm/mod.rs:2652-2674 | engine/baml-schema-wasm/src/runtime_wasm/mod.rs:2927-2950 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (18–21 lines × 2) baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:553— baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:553-573 | baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:1482-1499 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (18–21 lines × 2) baml_language/crates/baml_compiler2_mir/src/lower.rs:6193— baml_language/crates/baml_compiler2_mir/src/lower.rs:6193-6210 | baml_language/crates/baml_compiler2_mir/src/lower.rs:12149-12169 — both copies are in the same file, so extract the block into 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–21 lines × 2) baml_language/crates/baml_compiler2_emit/src/stack_carry.rs:800— baml_language/crates/baml_compiler2_emit/src/stack_carry.rs:800-815 | baml_language/crates/baml_compiler2_emit/src/stack_carry.rs:837-857 — both copies are in the same file, so extract the block into 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–21 lines × 2) baml_language/crates/baml_compiler2_mir/src/lower.rs:6824— baml_language/crates/baml_compiler2_mir/src/lower.rs:6824-6839 | baml_language/crates/baml_compiler2_mir/src/lower.rs:12310-12330 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (20–21 lines × 2) baml_language/crates/baml_compiler2_mir/src/lower.rs:6480— baml_language/crates/baml_compiler2_mir/src/lower.rs:6480-6500 | baml_language/crates/baml_compiler2_mir/src/lower.rs:6579-6598 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (20–21 lines × 2) baml_language/crates/baml_compiler2_visualization/src/control_flow/flatten.rs:459— baml_language/crates/baml_compiler2_visualization/src/control_flow/flatten.rs:459-479 | engine/baml-runtime/src/control_flow/flatten/step2_hoist_branch_arms.rs:48-67 — before extracting anything, compare `baml_language/crates/baml_compiler2_visualization/src/control_flow/flatten.rs` and `engine/baml-runtime/src/control_flow/flatten/step2_hoist_branch_arms.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 56 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, 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 (19–21 lines × 2) baml_language/crates/baml_compiler2_mir/src/lower.rs:10152— baml_language/crates/baml_compiler2_mir/src/lower.rs:10152-10170 | baml_language/crates/baml_compiler2_mir/src/lower.rs:10209-10229 — both copies are in the same file, so extract the block into 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–21 lines × 2) engine/baml-runtime/src/cli/repl.rs:497— engine/baml-runtime/src/cli/repl.rs:497-515 | engine/baml-runtime/src/cli/repl.rs:672-692 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (18–20 lines × 2) baml_language/crates/bex_engine/src/lib.rs:6515— baml_language/crates/bex_engine/src/lib.rs:6515-6532 | baml_language/crates/bex_engine/src/lib.rs:6580-6599 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (18–20 lines × 2) baml_language/crates/bex_events/src/history/mod.rs:318— baml_language/crates/bex_events/src/history/mod.rs:318-337 | baml_language/crates/bridge_wasm/src/runs.rs:155-172 — 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–19 lines × 2) baml_language/sdks/go/sdkgen_go/src/lib.rs:2491— baml_language/sdks/go/sdkgen_go/src/lib.rs:2491-2506 | baml_language/sdks/go/sdkgen_go/src/lib.rs:2582-2600 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (16–19 lines × 2) engine/generators/languages/python/src/ir_to_py/mod.rs:40— engine/generators/languages/python/src/ir_to_py/mod.rs:40-58 | engine/generators/languages/python/src/ir_to_py/mod.rs:142-157 — both copies are in the same file, so extract the block into 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–18 lines × 2) baml_language/crates/baml_compiler2_emit/src/analysis.rs:906— baml_language/crates/baml_compiler2_emit/src/analysis.rs:906-923 | baml_language/crates/baml_compiler2_emit/src/analysis.rs:952-966 — both copies are in the same file, so extract the block into 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–18 lines × 2) baml_language/crates/baml_compiler2_hir_ty/src/method_resolution.rs:1139— baml_language/crates/baml_compiler2_hir_ty/src/method_resolution.rs:1139-1153 | baml_language/crates/baml_compiler2_hir_ty/src/method_resolution.rs:1202-1219 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (16–18 lines × 2) baml_language/sdks/python/rust/sdkgen_python_pydantic2/src/utils.rs:20— baml_language/sdks/python/rust/sdkgen_python_pydantic2/src/utils.rs:20-35 | engine/generators/languages/python/src/utils.rs:19-36 — 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–18 lines × 2) engine/baml-runtime/src/async_interpreter_runtime.rs:494— engine/baml-runtime/src/async_interpreter_runtime.rs:494-509 | engine/baml-runtime/src/async_vm_runtime.rs:796-813 — before extracting anything, compare `engine/baml-runtime/src/async_interpreter_runtime.rs` and `engine/baml-runtime/src/async_vm_runtime.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 92 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (16 lines × 3) baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs:531— baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs:531-546 | baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs:619-634 | engine/baml-lib/jsonish/src/jsonish/parser/fixing_parser/json_parse_state.rs:654-669 — before extracting anything, compare `baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs` and `engine/baml-lib/jsonish/src/jsonish/parser/fixing_parser/json_parse_state.rs` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 575 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (16 lines × 3) baml_language/crates/bex_vm/src/vm.rs:9762— baml_language/crates/bex_vm/src/vm.rs:9762-9777 | baml_language/crates/bex_vm/src/vm.rs:9834-9849 | baml_language/crates/bex_vm/src/vm.rs:9859-9874 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (12–16 lines × 2) baml_language/crates/baml_cli/src/project_load.rs:150— baml_language/crates/baml_cli/src/project_load.rs:150-161 | baml_language/crates/baml_cli/src/project_load.rs:384-399 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (12–16 lines × 2) baml_language/sdks/python/rust/sdkgen_python_pydantic2/src/leaf.rs:1342— baml_language/sdks/python/rust/sdkgen_python_pydantic2/src/leaf.rs:1342-1353 | baml_language/sdks/python/rust/sdkgen_python_pydantic2/src/leaf.rs:2227-2242 — both copies are in the same file, so extract the block into 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 × 8) baml_language/crates/btel_recorder/src/lib.rs:519— baml_language/crates/btel_recorder/src/lib.rs:519-533 | baml_language/crates/btel_recorder/src/lib.rs:544-558 | baml_language/crates/btel_recorder/src/lib.rs:619-633 | baml_language/crates/btel_recorder/src/lib.rs:644-658 | baml_language/crates/btel_recorder/src/lib.rs:719-733 | baml_language/crates/btel_recorder/src/lib.rs:745-759 | baml_language/crates/btel_recorder/src/lib.rs:770-784 | baml_language/crates/btel_recorder/src/lib.rs:795-809 — all 8 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (15 lines × 8) baml_language/crates/btel_recorder/src/lib.rs:569— baml_language/crates/btel_recorder/src/lib.rs:569-583 | baml_language/crates/btel_recorder/src/lib.rs:594-608 | baml_language/crates/btel_recorder/src/lib.rs:669-683 | baml_language/crates/btel_recorder/src/lib.rs:694-708 | baml_language/crates/btel_recorder/src/lib.rs:820-834 | baml_language/crates/btel_recorder/src/lib.rs:846-860 | baml_language/crates/btel_recorder/src/lib.rs:871-885 | baml_language/crates/btel_recorder/src/lib.rs:896-910 — all 8 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (15 lines × 4) baml_language/crates/btel_recorder/src/lib.rs:921— baml_language/crates/btel_recorder/src/lib.rs:921-935 | baml_language/crates/btel_recorder/src/lib.rs:971-985 | baml_language/crates/btel_recorder/src/lib.rs:1021-1035 | baml_language/crates/btel_recorder/src/lib.rs:1047-1061 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (15 lines × 4) baml_language/crates/btel_recorder/src/lib.rs:946— baml_language/crates/btel_recorder/src/lib.rs:946-960 | baml_language/crates/btel_recorder/src/lib.rs:996-1010 | baml_language/crates/btel_recorder/src/lib.rs:1072-1086 | baml_language/crates/btel_recorder/src/lib.rs:1097-1111 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (15 lines × 3) baml_language/crates/baml_compiler_parser/src/parser.rs:4341— baml_language/crates/baml_compiler_parser/src/parser.rs:4341-4355 | baml_language/crates/baml_compiler_parser/src/parser.rs:7627-7641 | baml_language/crates/baml_compiler_parser/src/parser.rs:7672-7686 — 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) baml_language/sdks/java/sdkgen_java/src/emit.rs:301— baml_language/sdks/java/sdkgen_java/src/emit.rs:301-315 | baml_language/sdks/rust/sdkgen_rust/src/emit/function.rs:657-671 | baml_language/sdks/typescript/sdkgen_typescript_shared/src/emit/mod.rs:196-210 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times.
Duplicated block (14 lines × 5) baml_language/crates/baml_type/src/normalize.rs:772— baml_language/crates/baml_type/src/normalize.rs:772-785 | baml_language/crates/baml_type/src/normalize.rs:887-900 | baml_language/crates/baml_type/src/normalize.rs:1475-1488 | baml_language/crates/baml_type/src/normalize.rs:2476-2489 | baml_language/crates/baml_type/src/normalize.rs:2637-2650 — 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 (14 lines × 5) engine/baml-lib/llm-client/src/clients/helpers.rs:96— engine/baml-lib/llm-client/src/clients/helpers.rs:96-109 | engine/baml-lib/llm-client/src/clients/helpers.rs:117-130 | engine/baml-lib/llm-client/src/clients/helpers.rs:138-151 | engine/baml-lib/llm-client/src/clients/helpers.rs:155-168 | engine/baml-lib/llm-client/src/clients/helpers.rs:172-185 — 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 (14 lines × 3) baml_language/crates/baml_cli/src/pack_command.rs:615— baml_language/crates/baml_cli/src/pack_command.rs:615-628 | baml_language/crates/baml_cli/src/run_command.rs:911-924 | baml_language/crates/baml_cli/src/test_command.rs:410-423 — before extracting anything, compare `baml_language/crates/baml_cli/src/pack_command.rs` and `baml_language/crates/baml_cli/src/run_command.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 50 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (14 lines × 3) engine/baml-lib/llm-client/src/clients/aws_bedrock.rs:301— engine/baml-lib/llm-client/src/clients/aws_bedrock.rs:301-314 | engine/baml-lib/llm-client/src/clients/aws_bedrock.rs:339-352 | engine/baml-lib/llm-client/src/clients/aws_bedrock.rs:365-378 — 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–14 lines × 2) baml_language/crates/baml_query_btel/src/ingest/profile.rs:440— baml_language/crates/baml_query_btel/src/ingest/profile.rs:440-453 | baml_language/crates/baml_query_btel/src/ingest/profile.rs:480-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 (11–14 lines × 2) engine/baml-runtime/src/optimize/storage.rs:191— engine/baml-runtime/src/optimize/storage.rs:191-201 | engine/baml-runtime/src/optimize/tui.rs:1209-1222 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (11–13 lines × 2) baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:6257— baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:6257-6267 | baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:6324-6336 — both copies are in the same file, so extract the block into 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–13 lines × 2) baml_language/sdks/csharp/sdkgen_csharp/src/names.rs:352— baml_language/sdks/csharp/sdkgen_csharp/src/names.rs:352-364 | baml_language/sdks/csharp/sdkgen_csharp/src/routing.rs:264-274 — 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–13 lines × 2) baml_language/crates/baml_compiler2_hir_ty/src/interfaces/impl_rules.rs:1867— baml_language/crates/baml_compiler2_hir_ty/src/interfaces/impl_rules.rs:1867-1875 | baml_language/crates/baml_compiler2_hir_ty/src/interfaces/impl_rules.rs:1947-1959 — both copies are in the same file, so extract the block into 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–13 lines × 2) baml_language/crates/bex_sap/src/deserializer/coercer/match_string.rs:323— baml_language/crates/bex_sap/src/deserializer/coercer/match_string.rs:323-331 | engine/baml-lib/jsonish/src/deserializer/coercer/match_string.rs:294-306 — before extracting anything, compare `baml_language/crates/bex_sap/src/deserializer/coercer/match_string.rs` and `engine/baml-lib/jsonish/src/deserializer/coercer/match_string.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 52 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, 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–9 lines × 4) baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:2670— baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:2670-2678 | baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:2729-2736 | baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:2779-2786 | baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:6047-6054 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (8–9 lines × 4) engine/baml-runtime/src/internal/llm_client/primitive/anthropic/anthropic_client.rs:134— engine/baml-runtime/src/internal/llm_client/primitive/anthropic/anthropic_client.rs:134-141 | engine/baml-runtime/src/internal/llm_client/primitive/aws/aws_client.rs:473-481 | engine/baml-runtime/src/internal/llm_client/primitive/google/googleai_client.rs:166-174 | engine/baml-runtime/src/internal/llm_client/primitive/vertex/vertex_client.rs:190-198 — before extracting anything, compare `engine/baml-runtime/src/internal/llm_client/primitive/anthropic/anthropic_client.rs` and `engine/baml-runtime/src/internal/llm_client/primitive/google/googleai_client.rs` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 79 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (7–9 lines × 2) baml_language/crates/baml_builtins2_codegen/src/codegen_io.rs:1649— baml_language/crates/baml_builtins2_codegen/src/codegen_io.rs:1649-1657 | baml_language/crates/baml_builtins2_codegen/src/codegen_io.rs:1958-1964 — both copies are in the same file, so extract the block into 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–9 lines × 2) baml_language/crates/bex_engine/src/conversion.rs:2409— baml_language/crates/bex_engine/src/conversion.rs:2409-2417 | baml_language/crates/bex_engine/src/conversion.rs:2456-2462 — both copies are in the same file, so extract the block into 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 × 5) engine/baml-runtime/src/internal/llm_client/primitive/anthropic/response_handler.rs:125— engine/baml-runtime/src/internal/llm_client/primitive/anthropic/response_handler.rs:125-132 | engine/baml-runtime/src/internal/llm_client/primitive/google/response_handler.rs:147-154 | engine/baml-runtime/src/internal/llm_client/primitive/openai/response_handler.rs:404-411 | engine/baml-runtime/src/internal/llm_client/primitive/openai/response_handler.rs:458-465 | engine/baml-runtime/src/internal/llm_client/primitive/vertex/response_handler.rs:145-152 — `engine/baml-runtime/src/internal/llm_client/primitive/anthropic/response_handler.rs` and `engine/baml-runtime/src/internal/llm_client/primitive/openai/response_handler.rs` 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 4 separate duplicated blocks between them, totalling at least 33 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.
Duplicated block (8 lines × 5) engine/generators/languages/go/src/ir_to_go/mod.rs:341— engine/generators/languages/go/src/ir_to_go/mod.rs:341-348 | engine/generators/languages/python/src/ir_to_py/mod.rs:238-245 | engine/generators/languages/ruby/src/ir_to_rb/mod.rs:307-314 | engine/generators/languages/rust/src/ir_to_rust/mod.rs:371-378 | engine/generators/languages/typescript/src/ir_to_ts/mod.rs:255-262 — before extracting anything, compare `engine/generators/languages/go/src/ir_to_go/mod.rs` and `engine/generators/languages/rust/src/ir_to_rust/mod.rs` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 208 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (7–8 lines × 3) baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:2392— baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:2392-2399 | baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:2844-2851 | baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:2974-2980 — 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–8 lines × 3) baml_language/crates/baml_compiler2_mir/src/lower.rs:8845— baml_language/crates/baml_compiler2_mir/src/lower.rs:8845-8852 | baml_language/crates/baml_compiler2_mir/src/lower.rs:8926-8932 | baml_language/crates/baml_compiler2_mir/src/lower.rs:8960-8967 — 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–7 lines × 2) baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs:1141— baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs:1141-1147 | baml_language/crates/baml_compiler2_hir_ty/src/interfaces/coherence.rs:377-382 — before extracting anything, compare `baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs` and `baml_language/crates/baml_compiler2_hir_ty/src/interfaces/coherence.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 61 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (6–7 lines × 2) baml_language/crates/baml_fmt/src/ast/expressions.rs:4338— baml_language/crates/baml_fmt/src/ast/expressions.rs:4338-4344 | baml_language/crates/baml_fmt/src/ast/pattern.rs:384-389 — before extracting anything, compare `baml_language/crates/baml_fmt/src/ast/expressions.rs` and `baml_language/crates/baml_fmt/src/ast/pattern.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 39 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (5–6 lines × 2) baml_language/crates/baml_type_macros/src/emit.rs:622— baml_language/crates/baml_type_macros/src/emit.rs:622-626 | baml_language/crates/baml_type_macros/src/emit.rs:636-641 — both copies are in the same file, so extract the block into 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–6 lines × 2) engine/baml-runtime/src/lib.rs:779— engine/baml-runtime/src/lib.rs:779-784 | engine/baml-runtime/src/lib.rs:787-791 — both copies are in the same file, so extract the block into 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 × 6) baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:2391— baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:2391-2395 | baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:2843-2847 | baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:2973-2977 | baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:5662-5666 | baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:5723-5727 | baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:5971-5975 — all 6 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (5 lines × 6) baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:167— baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:167-171 | baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:272-276 | baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:388-392 | baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:515-519 | baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:653-657 | baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:802-806 — all 6 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:167` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:277` calls `t3`, `_bamlEncode`, `_bamlAnnotatingSelectedType` and `baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:172` 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.
End-of-life runtime: Node.js 10 engine/language_client_typescript/REDACTED:68— engine/language_client_typescript/REDACTED declares Node.js 10 as this project's engines.node, and Node.js 10, support ended 2021-04-30. An unsupported runtime receives no security patches, so every vulnerability disclosed in it since 2021-04-30 is present and unfixable without moving off it. This is a migration rather than an upgrade: there is no newer release of a runtime that has ended.
End-of-life runtime: Node.js 18 REDACTED:23— REDACTED declares Node.js 18 as this project's engines.node, and Node.js 18, support ended 2025-04-30. An unsupported runtime receives no security patches, so every vulnerability disclosed in it since 2025-04-30 is present and unfixable without moving off it. This is a migration rather than an upgrade: there is no newer release of a runtime that has ended.
Awaits without ConfigureAwait(false) baml_language/sdks/csharp/bridge_csharp/src/Values/BamlMedia.cs:74— `await using … = new FileStream( path, FileMode.Open, FileAccess.Read, FileShare.Rea...` resumes on the caller's captured context. In library code that context belongs to the host application, so a host that blocks on this call (or runs on a UI thread) can stall or deadlock — append `.ConfigureAwait(false)`.
Awaits without ConfigureAwait(false) baml_language/sdks/csharp/bridge_csharp/src/Values/BamlStream.cs:533— `await Task.Yield()` resumes on the caller's captured context. In library code that context belongs to the host application, so a host that blocks on this call (or runs on a UI thread) can stall or deadlock — append `.ConfigureAwait(false)`.
R10 · Code Duplication· Duplicated block with local edits (129 matched lines × 2 locations) · ×2
Duplicated block with local edits (129 matched lines × 2 locations) typescript2/app-beps/src/components/decisions/decision-form.tsx:73— typescript2/app-beps/src/components/decisions/decision-form.tsx:73 · typescript2/app-beps/src/components/issues/issue-form.tsx:63 — the two spans are one implementation copied and then locally edited — 693 tokens are still identical, in the same order in both files, with only local edits between them. The copies have already begun to drift, which is this row's finding: an edit made to one and not the other changes behaviour silently. Diff the two spans first to learn what genuinely differs, then extract the shared core into one module both sites use, passing the differences in as parameters — or, if one copy exists only because the other could not be imported from its context, make one of them the single source the other is generated or re-exported from. If one copy is no longer reachable, delete it rather than letting it shadow the live one.
Duplicated block with local edits (129 matched lines × 2 locations) typescript2/pkg-playground/src/worker-protocol.ts:863— typescript2/pkg-playground/src/worker-protocol.ts:863 · typescript2/pkg-playground/src/worker-protocol.ts:1060 — the two spans are one implementation copied and then locally edited — 620 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.
Dead file (~399 LoC) engine/language_client_typescript/typescript_src/errors.ts— no import path from any entry point (371 application, 97 tooling, 220 test roots considered), but 2 in-repo import(s) from 2 other file(s) do name it (engine/language_client_typescript/typescript_src/index.ts, engine/language_client_typescript/typescript_src/stream.ts) — every one of those referrers is itself unreachable, so this file is dead only as a member of that cluster: if any referrer is in fact alive, this row falls with it
Dead file (~399 LoC) typescript2/app-website/components/magicui/response-stream.tsx— no import path from any entry point (371 application, 97 tooling, 220 test roots considered), but 1 in-repo import(s) from 1 other file(s) do name it (typescript2/app-website/components/magicui/reasoning.tsx) — every one of those referrers is itself unreachable, so this file is dead only as a member of that cluster: if any referrer is in fact alive, this row falls with it
Blocking `File.WriteAllText` inside an `async` method baml_language/sdk_tests/crates/csharp/streaming/Program.cs:472— `File.WriteAllText` blocks the thread on I/O while `File.WriteAllTextAsync` exists to wait without one — inside a method that is already `async`, await the twin.
Blocking `File.WriteAllText` inside an `async` method baml_language/sdk_tests/crates/csharp/streaming/Program.cs:502— `File.WriteAllText` blocks the thread on I/O while `File.WriteAllTextAsync` exists to wait without one — inside a method that is already `async`, await the twin.
X2 · Cancellation propagation· Async local function without CancellationToken · ×2
Async local function without CancellationToken: VerifyCancelTokenAnyAsync REDACTED:492— Neither takes a CancellationToken nor reads the one of the function it sits in, while it calls something that takes one — this work can't be stopped early once started. Take the token, or pass on the enclosing one.
Async local function without CancellationToken: RequireEventuallyAsync REDACTED:504— Neither takes a CancellationToken nor reads the one of the function it sits in, while it calls something that takes one — this work can't be stopped early once started. Take the token, or pass on the enclosing one.
TirTypeError::render (cyclomatic 201) baml_language/crates/baml_compiler2_hir_ty/src/diagnostics.rs:1226— TirTypeError::render has cyclomatic complexity 201 (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.
ReplArgs::run (cyclomatic 125) engine/baml-runtime/src/cli/repl.rs:848— ReplArgs::run has cyclomatic complexity 125 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
comment-sidebar.CommentSidebar (cyclomatic 109) typescript2/app-beps/src/components/comments/comment-sidebar.tsx:177— comment-sidebar.CommentSidebar has cyclomatic complexity 109 (threshold 15). Of this number, 16 points are the body's own statements and 93 belong to 28 function items inside it that branch. 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.
App.App (cyclomatic 109) typescript2/app-speedtest/src/App.tsx:63— App.App has cyclomatic complexity 109 (threshold 15). Of this number, 47 points are the body's own statements and 62 belong to 21 function items inside it that branch. 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.
webview-media.WebviewMedia (cyclomatic 107) typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/prompt-preview/webview-media.tsx:138— webview-media.WebviewMedia has cyclomatic complexity 107 (threshold 15). Of this number, 53 points are the body's own statements and 54 belong to 15 function items inside it that branch. 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.
baml-lsp-worker.onmessage (cyclomatic 103) typescript2/app-promptfiddle/src/playground/baml-lsp-worker.ts:567— baml-lsp-worker.onmessage has cyclomatic complexity 103 (threshold 15). Of this number, 89 points are the body's own statements and 14 belong to 8 function literals inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
baml-worker.onmessage (cyclomatic 97) typescript2/app-website/playground/baml-worker.ts:394— baml-worker.onmessage has cyclomatic complexity 97 (threshold 15). Of this number, 94 points are the body's own statements and 3 belong to 3 function literals inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ArgCoercer::coerce_arg (cyclomatic 96) engine/baml-lib/baml-core/src/ir/ir_helpers/to_baml_arg.rs:135— ArgCoercer::coerce_arg has cyclomatic complexity 96 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
analyze_ffi.analyze (cyclomatic 94) scripts/ffi-debug/analyze_ffi.py:136— analyze_ffi.analyze has cyclomatic complexity 94 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
baml_go.validateBAMLType (cyclomatic 94) baml_language/sdks/go/baml_go/value.go:474— baml_go.validateBAMLType has cyclomatic complexity 94 (threshold 15). Of this number, 92 points are the body's own statements and 2 belong to one function literal inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ExecutionPanel.ExecutionPanel (cyclomatic 88) typescript2/pkg-playground/src/ExecutionPanel.tsx:494— ExecutionPanel.ExecutionPanel has cyclomatic complexity 88 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This shape REPEATS in the file: one other method here (ExecutionPanel.ExecutionPanel::handleCursorContext) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
bep-route-shell.BepRouteShell (cyclomatic 82) typescript2/app-beps/src/components/bep/bep-route-shell.tsx:74— bep-route-shell.BepRouteShell has cyclomatic complexity 82 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages. This shape REPEATS in the file: one other method here (bep-route-shell.BepRouteShell::handleConfirmSubmit) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
MonacoEditor.MonacoEditor (cyclomatic 82) typescript2/pkg-editor/src/MonacoEditor.tsx:300— MonacoEditor.MonacoEditor has cyclomatic complexity 82 (threshold 15). Most of this is not in the body itself: 5 of the 82 points are its own statements and the rest belongs to 18 function literals inside it that branch (lines 354, 1083, 1151, …). 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.
bep-import-dialog.BepImportDialog (cyclomatic 76) typescript2/app-beps/src/components/bep/bep-import-dialog.tsx:59— bep-import-dialog.BepImportDialog has cyclomatic complexity 76 (threshold 15). Of this number, 38 points are the body's own statements and 38 belong to 9 function literals inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
DetailPanel.LLMNodeContent (cyclomatic 71) typescript/packages/playground-common/src/features/detail-panel/components/DetailPanel.tsx:206— DetailPanel.LLMNodeContent has cyclomatic complexity 71 (threshold 15). Of this number, 34 points are the body's own statements and 37 belong to 13 function items inside it that branch. 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.
DetailPanel.StandardNodeContent (cyclomatic 70) typescript/packages/playground-common/src/features/detail-panel/components/DetailPanel.tsx:540— DetailPanel.StandardNodeContent has cyclomatic complexity 70 (threshold 15). Of this number, 31 points are the body's own statements and 39 belong to 14 function items inside it that branch. 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.
analyze_ffi.generate_plot (cyclomatic 68) scripts/ffi-debug/analyze_ffi.py:515— analyze_ffi.generate_plot has cyclomatic complexity 68 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
pdf-viewer.PdfViewer (cyclomatic 65) typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/prompt-preview/pdf-viewer.tsx:15— pdf-viewer.PdfViewer has cyclomatic complexity 65 (threshold 15). Of this number, 17 points are the body's own statements and 48 belong to 21 function items inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Program::validate (cyclomatic 64) baml_language/crates/bex_vm_types/src/types.rs:204— Program::validate 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.
GlobalState::dispatch_request (cyclomatic 61) baml_language/crates/baml_lsp/src/dispatch/mod.rs:91— GlobalState::dispatch_request has cyclomatic complexity 61 (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.
BamlAsyncVmRuntime::call_function (cyclomatic 60) engine/baml-runtime/src/async_vm_runtime.rs:160— BamlAsyncVmRuntime::call_function has cyclomatic complexity 60 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Diagnostic::fmt (cyclomatic 58) baml_language/crates/bcs_api/src/diagnostics.rs:301— Diagnostic::fmt has cyclomatic complexity 58 (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.
LoweringDiagnostic::to_diagnostic (cyclomatic 57) baml_language/crates/baml_compiler2_ast/src/lowering_diagnostic.rs:325— LoweringDiagnostic::to_diagnostic has cyclomatic complexity 57 (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.
ConversionBuffer::span (cyclomatic 57) baml_language/crates/btel_recorder/src/lib.rs:211— ConversionBuffer::span has cyclomatic complexity 57 (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.
baml_go.decodeDynamicValue (cyclomatic 57) baml_language/sdks/go/baml_go/dynamic.go:619— baml_go.decodeDynamicValue has cyclomatic complexity 57 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
compare._render_md (cyclomatic 54) baml_language/tools/speedtest/src/speedtest/compare.py:152— compare._render_md 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.
OptimizeArgs::run (cyclomatic 53) engine/baml-runtime/src/cli/optimize.rs:167— OptimizeArgs::run has cyclomatic complexity 53 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ProtoWriter.encodeInboundValue (cyclomatic 53) baml_language/sdks/java/baml_bridge/src/main/java/baml_bridge/internal/ProtoWriter.java:239— ProtoWriter.encodeInboundValue has cyclomatic complexity 53 (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.
Hir2Diagnostic::to_diagnostic (cyclomatic 52) baml_language/crates/baml_compiler2_hir/src/diagnostic.rs:304— Hir2Diagnostic::to_diagnostic has cyclomatic complexity 52 (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.
BamlUnion8._bamlDecode (cyclomatic 52) baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:817— BamlUnion8._bamlDecode has cyclomatic complexity 52 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
TelemetryView.OverviewTab (cyclomatic 52) typescript2/pkg-playground/src/telemetry/TelemetryView.tsx:915— TelemetryView.OverviewTab has cyclomatic complexity 52 (threshold 15). Of this number, 43 points are the body's own statements and 9 belong to 6 function literals inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
GraphView.GraphViewInner (cyclomatic 50) typescript2/pkg-playground/src/graph/GraphView.tsx:141— GraphView.GraphViewInner has cyclomatic complexity 50 (threshold 15). Most of this is not in the body itself: 11 of the 50 points are its own statements and the rest belongs to 14 function literals inside it that branch (lines 483, 283, 397, …). 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.
Expr::temporary_same_state (cyclomatic 49) engine/baml-lib/baml-types/src/expr.rs:337— Expr::temporary_same_state has cyclomatic complexity 49 (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.
ai-assistant-panel.AIAssistantPanel (cyclomatic 49) typescript2/app-beps/src/components/ai-assistant/ai-assistant-panel.tsx:54— ai-assistant-panel.AIAssistantPanel has cyclomatic complexity 49 (threshold 15). Most of this is not in the body itself: 15 of the 49 points are its own statements and the rest belongs to 11 function items inside it that branch (a function literal at line 93, handleQuickAction, a function literal at line 382, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
EqualsDriver::compare_objects (cyclomatic 48) baml_language/crates/bex_vm/src/package_baml/ops.rs:459— EqualsDriver::compare_objects has cyclomatic complexity 48 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
compare.cmd_compare (cyclomatic 48) baml_language/tools/speedtest/src/speedtest/compare.py:18— compare.cmd_compare 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.
index.testKitchenSink (cyclomatic 48) engine/generators/data/mixed_complex_types/typescript/index.ts:3— index.testKitchenSink has cyclomatic complexity 48 (threshold 15). Of this number, 45 points are the body's own statements and 3 belong to one function literal inside it that branches. 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.
Bulk::apply (cyclomatic 46) baml_language/crates/baml_query_btel/src/ingest/bulk.rs:546— Bulk::apply 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.
BamlUnion7._bamlDecode (cyclomatic 46) baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:667— BamlUnion7._bamlDecode 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.
App.App (cyclomatic 46) typescript2/app-vscode-webview/src/App.tsx:63— App.App has cyclomatic complexity 46 (threshold 15). Of this number, 22 points are the body's own statements and 24 belong to 9 function literals inside it that branch. 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.
run-store-client.createRunStoreClient (cyclomatic 45) typescript2/pkg-playground/src/run-store-client.ts:223— run-store-client.createRunStoreClient has cyclomatic complexity 45 (threshold 15). Most of this is not in the body itself: 3 of the 45 points are its own statements and the rest belongs to 2 function items inside it that branch (a function literal at line 244, rejectPending). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
Blob::logical_bytes_approx_v1 (cyclomatic 44) baml_language/crates/btel_snapshot/src/logical_bytes.rs:59— Blob::logical_bytes_approx_v1 has cyclomatic complexity 44 (threshold 15). Of this number, 33 points are the body's own statements and 11 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.
proto._set_inbound_value (cyclomatic 44) baml_language/sdks/python/src/baml_bridge/proto.py:272— proto._set_inbound_value has cyclomatic complexity 44 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
baml_go.decodeReflected (cyclomatic 44) baml_language/sdks/go/baml_go/dynamic.go:457— baml_go.decodeReflected has cyclomatic complexity 44 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
RuntimeCli::run (cyclomatic 43) engine/cli/src/commands.rs:117— RuntimeCli::run has cyclomatic complexity 43 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
PropertyHandler::ensure_http_config (cyclomatic 43) engine/baml-lib/llm-client/src/clients/helpers.rs:511— PropertyHandler::ensure_http_config 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.
TyResolvedRef::coerce (cyclomatic 42) baml_language/crates/bex_sap/src/deserializer/coercer/coerce_ty.rs:144— TyResolvedRef::coerce has cyclomatic complexity 42 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
GoTypeProjection::project_inner (cyclomatic 42) baml_language/sdks/go/sdkgen_go/src/types.rs:254— GoTypeProjection::project_inner has cyclomatic complexity 42 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
Type::is_subtype_of (cyclomatic 42) engine/baml-lib/jinja/src/evaluate_type/types.rs:72— Type::is_subtype_of has cyclomatic complexity 42 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
useParticleEngine.useParticleEngine (cyclomatic 42) typescript2/app-website/components/HistoryOfLanguages/useParticleEngine.ts:44— useParticleEngine.useParticleEngine has cyclomatic complexity 42 (threshold 15). Most of this is not in the body itself: 1 of the 42 points is its own statement and the rest belongs to 4 function literals inside it that branch (lines 89, 199, 236, …). 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.
sdkgen_typescript_shared::translate_ty::translate_ty (cyclomatic 41) baml_language/sdks/typescript/sdkgen_typescript_shared/src/translate_ty.rs:49— sdkgen_typescript_shared::translate_ty::translate_ty 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.
deployment-status.DeploymentStatus (cyclomatic 41) typescript2/app-website/components/magicui/deployment-status.tsx:30— deployment-status.DeploymentStatus has cyclomatic complexity 41 (threshold 15). Most of this is not in the body itself: 6 of the 41 points are its own statements and the rest belongs to 9 function items inside it that branch (a function literal at line 254, getProviderStatus, getStatusIcon, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
TypeExprKind::fmt (cyclomatic 40) baml_language/crates/baml_compiler2_ast/src/ast.rs:265— TypeExprKind::fmt has cyclomatic complexity 40 (threshold 15). Of this number, 39 points are the body's own statements and 1 belongs to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
TypeRefDisplay::fmt (cyclomatic 40) baml_language/crates/baml_compiler2_hir/src/type_ref.rs:168— TypeRefDisplay::fmt has cyclomatic complexity 40 (threshold 15). Of this number, 39 points are the body's own statements and 1 belongs to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
parser.parse (cyclomatic 40) tools/bctl_src/oncall/parser.py:72— parser.parse 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.
BamlUnion6._bamlDecode (cyclomatic 40) baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:528— BamlUnion6._bamlDecode 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.
ParticleImage.ParticleImage (cyclomatic 40) typescript2/app-website/components/ParticleImage.tsx:61— ParticleImage.ParticleImage has cyclomatic complexity 40 (threshold 15). Most of this is not in the body itself: 1 of the 40 points is its own statement and the rest belongs to 6 function literals inside it that branch (lines 133, 259, 107, …). 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.
emit-sublime.emitSublimeSyntax (cyclomatic 40) typescript2/pkg-grammar/scripts/emit-sublime.ts:122— emit-sublime.emitSublimeSyntax has cyclomatic complexity 40 (threshold 15). Most of this is not in the body itself: 7 of the 40 points are its own statements and the rest belongs to 8 function items inside it that branch (convertRule, convertCaptures, resolveInclude, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
HashDriver::drive (cyclomatic 39) baml_language/crates/bex_vm/src/package_baml/hashing.rs:40— HashDriver::drive 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.
Class::coerce (cyclomatic 39) engine/baml-lib/jsonish/src/deserializer/coercer/ir_ref/coerce_class.rs:136— Class::coerce 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.
baml_go.encodeAny (cyclomatic 39) baml_language/sdks/go/baml_go/dynamic.go:305— baml_go.encodeAny 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.
index.testComplexNested (cyclomatic 38) engine/generators/data/nested_structures/typescript/index.ts:129— index.testComplexNested has cyclomatic complexity 38 (threshold 15). Of this number, 19 points are the body's own statements and 19 belong to 5 function literals inside it that branch. 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.
page.ProfilePage (cyclomatic 38) typescript2/app-beps/src/app/profile/page.tsx:77— page.ProfilePage has cyclomatic complexity 38 (threshold 15). Of this number, 29 points are the body's own statements and 9 belong to 4 function items inside it that branch. 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.
bep-nav.BepNav (cyclomatic 38) typescript2/app-beps/src/components/bep/bep-nav.tsx:72— bep-nav.BepNav has cyclomatic complexity 38 (threshold 15). Of this number, 17 points are the body's own statements and 21 belong to 4 function items inside it that branch. 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.
WebSocketRuntimePort.fromServer (cyclomatic 38) typescript2/pkg-playground/src/ports/WebSocketRuntimePort.ts:463— WebSocketRuntimePort.fromServer 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.
walkLibFile (cyclomatic 38) tools/stdlib-matrix/extractors/ts-surface.mjs:337— walkLibFile 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.
StreamWriter::publish_if_due (cyclomatic 37) baml_language/crates/bex_prof_store/src/prof/backend/writer.rs:295— StreamWriter::publish_if_due has cyclomatic complexity 37 (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.
comment-feed-view.FeedCommentCard (cyclomatic 37) typescript2/app-beps/src/components/comments/comment-feed-view.tsx:215— comment-feed-view.FeedCommentCard has cyclomatic complexity 37 (threshold 15). Of this number, 22 points are the body's own statements and 15 belong to 8 function items inside it that branch. 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.
comment-thread.SingleComment (cyclomatic 37) typescript2/app-beps/src/components/comments/comment-thread.tsx:133— comment-thread.SingleComment has cyclomatic complexity 37 (threshold 15). Of this number, 24 points are the body's own statements and 13 belong to 7 function items inside it that branch. 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.
baml-editor.BamlEditor (cyclomatic 37) typescript2/app-website/app/learn2/_editor/baml-editor.tsx:359— baml-editor.BamlEditor has cyclomatic complexity 37 (threshold 15). Most of this is not in the body itself: 14 of the 37 points are its own statements and the rest belongs to 8 function literals inside it that branch (lines 398, 443, 502, …). 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.
Structural::decode (cyclomatic 36) baml_language/crates/bex_vm/src/package_baml/json/decode.rs:1412— Structural::decode 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.
proto._fill_wire_ty (cyclomatic 36) baml_language/sdks/python/src/baml_bridge/proto.py:652— proto._fill_wire_ty 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.
index.TestingSidebar (cyclomatic 36) typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/side-bar/index.tsx:48— index.TestingSidebar has cyclomatic complexity 36 (threshold 15). Most of this is not in the body itself: 10 of the 36 points are its own statements and the rest belongs to 8 function items inside it that branch (a function literal at line 109, a function literal at line 205, a function literal at line 265, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
page.RunPage (cyclomatic 36) typescript2/app-website/app/atb/runs/[id]/page.tsx:27— page.RunPage has cyclomatic complexity 36 (threshold 15). Of this number, 32 points are the body's own statements and 4 belong to 3 function items inside it that branch. 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.
LivePlayground.LivePlayground (cyclomatic 36) typescript2/app-website/app/learn2/_components/LivePlayground.tsx:102— LivePlayground.LivePlayground has cyclomatic complexity 36 (threshold 15). Most of this is not in the body itself: 8 of the 36 points are its own statements and the rest belongs to 11 function literals inside it that branch (lines 356, 150, 289, …). 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.
boundary_udf::yaml2jinja::rebuild_from_flattened (cyclomatic 35) engine/boundary-udf/src/yaml2jinja.rs:426— boundary_udf::yaml2jinja::rebuild_from_flattened has cyclomatic complexity 35 (threshold 15). Of this number, 32 points are the body's own statements and 3 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.
baml_go.validateJSONSelectedPayload (cyclomatic 35) baml_language/sdks/go/baml_go/json.go:253— baml_go.validateJSONSelectedPayload has cyclomatic complexity 35 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
baml_derive::derive_baml_hash (cyclomatic 34) engine/baml-lib/baml-derive/src/lib.rs:47— baml_derive::derive_baml_hash has cyclomatic complexity 34 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
BamlUnion5._bamlDecode (cyclomatic 34) baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:400— BamlUnion5._bamlDecode has cyclomatic complexity 34 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
index.testSimpleNested (cyclomatic 34) engine/generators/data/nested_structures/typescript/index.ts:3— index.testSimpleNested 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.
http.createRequestHandler (cyclomatic 34) typescript2/app-product-metrics/src/http.ts:86— http.createRequestHandler has cyclomatic complexity 34 (threshold 15). Most of this is not in the body itself: 1 of the 34 points is its own statement and the rest belongs to one function literal inside it that branches (line 94). The decisions are inside the literal, 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 literal's work into a named function or method at the enclosing scope and have the literal call it, then reduce whichever part then reads as the largest.
args-form-model.matches (cyclomatic 34) typescript2/pkg-playground/src/args-form-model.ts:232— args-form-model.matches has cyclomatic complexity 34 (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.
TelemetryView.ContextInspector (cyclomatic 34) typescript2/pkg-playground/src/telemetry/TelemetryView.tsx:3192— TelemetryView.ContextInspector 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.
baml_compiler_parser::parser::parse_impl (cyclomatic 33) baml_language/crates/baml_compiler_parser/src/parser.rs:8813— baml_compiler_parser::parser::parse_impl 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. This is NOT this file's highest cyclomatic complexity: baml_compiler_parser::parser::token_kind_to_syntax_kind (cyclomatic 97) 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.
Applier::apply (cyclomatic 33) baml_language/crates/baml_query_btel/src/ingest.rs:1068— Applier::apply has cyclomatic complexity 33 (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.
pkg.outboundToGo (cyclomatic 33) baml_language/sdks/go/bridge_go/pkg/proto.go:278— pkg.outboundToGo has cyclomatic complexity 33 (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.
BAMLSDK.parseWatchValue (cyclomatic 33) typescript/packages/playground-common/src/sdk/sdk.ts:1036— BAMLSDK.parseWatchValue 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.
TypeCtx::convert_ty (cyclomatic 32) baml_language/crates/bex_sap/src/sap_model/convert.rs:701— TypeCtx::convert_ty 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.
baml_go.encodeJSON (cyclomatic 32) baml_language/sdks/go/baml_go/json.go:24— baml_go.encodeJSON 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.
index.testLargeStructure (cyclomatic 32) engine/generators/data/edge_cases/typescript/index.ts:27— index.testLargeStructure has cyclomatic complexity 32 (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.
BacktickStringLiteral::flat_parts (cyclomatic 31) baml_language/crates/baml_compiler_syntax/src/ast.rs:1008— BacktickStringLiteral::flat_parts 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.
Walker::visit (cyclomatic 31) baml_language/crates/bex_vm/src/package_baml/json/encode.rs:628— Walker::visit has cyclomatic complexity 31 (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.
TypeContext::infer_type (cyclomatic 31) engine/baml-compiler/src/thir/typecheck.rs:572— TypeContext::infer_type has cyclomatic complexity 31 (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.
runner.cmd_run (cyclomatic 31) baml_language/tools/speedtest/src/speedtest/runner.py:171— runner.cmd_run 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.
serde.convertFieldTypeToGoType (cyclomatic 31) engine/language_client_go/baml_go/serde/decode.go:328— serde.convertFieldTypeToGoType 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.
kpis.html.chart (cyclomatic 31) baml_language/tools/speedtest/src/speedtest/templates/kpis.html:123— kpis.html.chart has cyclomatic complexity 31 (threshold 15). Most of this is not in the body itself: 13 of the 31 points are its own statements and the rest belongs to 7 function items inside it that branch (a function literal at line 139, a function literal at line 136, a function literal at line 137, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
function-item.FunctionItem (cyclomatic 31) typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/side-bar/function-item.tsx:24— function-item.FunctionItem has cyclomatic complexity 31 (threshold 15). Most of this is not in the body itself: 11 of the 31 points are its own statements and the rest belongs to 2 function items inside it that branch (a function literal at line 36, handleClick). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
chart.ChartTooltipContent (cyclomatic 31) REDACTED:107— chart.ChartTooltipContent has cyclomatic complexity 31 (threshold 15). Most of this is not in the body itself: 5 of the 31 points are its own statements and the rest belongs to 2 function literals inside it that branch (lines 182, 131). 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.
Workbench.Workbench (cyclomatic 31) typescript2/app-website/app/bamlcode/_components/Workbench.tsx:24— Workbench.Workbench has cyclomatic complexity 31 (threshold 15). Most of this is not in the body itself: 12 of the 31 points are its own statements and the rest belongs to 4 function literals inside it that branch (lines 59, 228, 108, …). 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.
ClassTy::coerce (cyclomatic 30) baml_language/crates/bex_sap/src/deserializer/coercer/coerce_class.rs:105— ClassTy::coerce 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.
audit-site.main (cyclomatic 30) typescript2/app-developer-docs/scripts/audit-site.py:77— audit-site.main 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.
annotation-svg.renderAnnotatedSnippet (cyclomatic 30) typescript2/app-developer-docs/lib/snippets/annotation-svg.ts:57— annotation-svg.renderAnnotatedSnippet has cyclomatic complexity 30 (threshold 15). Most of this is not in the body itself: 11 of the 30 points are its own statements and the rest belongs to 4 function items inside it that branch (a function literal at line 94, a function literal at line 167, pos, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
sys_ops::output_format::walk_ty (cyclomatic 29) baml_language/crates/sys_ops/src/output_format.rs:1521— sys_ops::output_format::walk_ty has cyclomatic complexity 29 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
baml_types::ir_type::converters::streaming::from_type_ir::partialize_helper (cyclomatic 29) engine/baml-lib/baml-types/src/ir_type/converters/streaming.rs:11— baml_types::ir_type::converters::streaming::from_type_ir::partialize_helper has cyclomatic complexity 29 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
pkg.runHostCallable (cyclomatic 29) REDACTED:196— pkg.runHostCallable has cyclomatic complexity 29 (threshold 15). Of this number, 28 points are the body's own statements and 1 belongs to one function literal inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
index.testRecursiveComplexity (cyclomatic 29) engine/generators/data/mixed_complex_types/typescript/index.ts:185— index.testRecursiveComplexity has cyclomatic complexity 29 (threshold 15). Of this number, 26 points are the body's own statements and 3 belong to 2 function literals inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
comment-feed-view.FeedThreadCard (cyclomatic 29) typescript2/app-beps/src/components/comments/comment-feed-view.tsx:553— comment-feed-view.FeedThreadCard has cyclomatic complexity 29 (threshold 15). Of this number, 18 points are the body's own statements and 11 belong to 5 function items inside it that branch. 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.
args-form-model.reconcileValue (cyclomatic 29) typescript2/pkg-playground/src/args-form-model.ts:403— args-form-model.reconcileValue has cyclomatic complexity 29 (threshold 15). Of this number, 28 points are the body's own statements and 1 belongs to one function literal inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
FunctionSidebar.TestTreeNode (cyclomatic 29) typescript2/pkg-playground/src/FunctionSidebar.tsx:69— FunctionSidebar.TestTreeNode has cyclomatic complexity 29 (threshold 15). Of this number, 25 points are the body's own statements and 4 belong to 2 function literals inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
IngressScheduler::admit_message_with_policy (cyclomatic 28) baml_language/crates/baml_lsp_server/src/lsp_ingress.rs:736— IngressScheduler::admit_message_with_policy 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.
TraceSnapshotBuilder::copy_object (cyclomatic 28) baml_language/crates/bex_engine/src/trace_heap.rs:324— TraceSnapshotBuilder::copy_object has cyclomatic complexity 28 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
baml_go.decodeJSON (cyclomatic 28) baml_language/sdks/go/baml_go/json.go:142— baml_go.decodeJSON 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.
pkg.goToInboundValueTracking (cyclomatic 28) baml_language/sdks/go/bridge_go/pkg/proto.go:85— pkg.goToInboundValueTracking 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.
BamlUnion4._bamlDecode (cyclomatic 28) baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:283— BamlUnion4._bamlDecode 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.
issue-card.IssueCard (cyclomatic 28) typescript2/app-beps/src/components/issues/issue-card.tsx:62— issue-card.IssueCard has cyclomatic complexity 28 (threshold 15). Of this number, 18 points are the body's own statements and 10 belong to 6 function items inside it that branch. 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.
SchemaCx::field_schema (cyclomatic 27) baml_language/crates/baml_ide/src/param_schema.rs:219— SchemaCx::field_schema 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.
internal_baml_parser_database::names::resolve_names (cyclomatic 27) engine/baml-lib/parser-database/src/names/mod.rs:110— internal_baml_parser_database::names::resolve_names 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.
generators_openapi::type::convert_ir_type (cyclomatic 27) engine/generators/languages/openapi/src/type.rs:147— generators_openapi::type::convert_ir_type has cyclomatic complexity 27 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
run.main (cyclomatic 27) baml_language/tools/gc_policy/run.py:14— run.main 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.
baml_go.equalBAMLType (cyclomatic 27) baml_language/sdks/go/baml_go/value.go:347— baml_go.equalBAMLType has cyclomatic complexity 27 (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.
index.testComplexMaps (cyclomatic 27) engine/generators/data/map_types/typescript/index.ts:52— index.testComplexMaps has cyclomatic complexity 27 (threshold 15). Of this number, 21 points are the body's own statements and 6 belong to 2 function literals inside it that branch. 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.
bep-user-stance.BepUserStance (cyclomatic 27) typescript2/app-beps/src/components/bep/bep-user-stance.tsx:59— bep-user-stance.BepUserStance has cyclomatic complexity 27 (threshold 15). Of this number, 19 points are the body's own statements and 8 belong to 4 function items inside it that branch. 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.
search-menu.SearchMenu (cyclomatic 27) typescript2/app-developer-docs/components/search-menu.tsx:35— search-menu.SearchMenu has cyclomatic complexity 27 (threshold 15). Most of this is not in the body itself: 6 of the 27 points are its own statements and the rest belongs to 8 function items inside it that branch (a function literal at line 67, onInputKeyDown, a function literal at line 50, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
no-widen-then-assert.knownValueEvidence (cyclomatic 27) typescript2/app-developer-docs/tools/oxlint/anti-slop/rules/no-widen-then-assert.ts:200— no-widen-then-assert.knownValueEvidence has cyclomatic complexity 27 (threshold 15). Of this number, 26 points are the body's own statements and 1 belongs to one function literal inside it that branches. 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.
page.IssuePage (cyclomatic 27) typescript2/app-website/app/atb/issues/[id]/page.tsx:26— page.IssuePage has cyclomatic complexity 27 (threshold 15). Of this number, 25 points are the body's own statements and 2 belong to one function literal inside it that branches. 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.
HeaderCollector::visit_expression (cyclomatic 26) engine/baml-lib/ast/src/ast/baml_vis/header_collector.rs:346— HeaderCollector::visit_expression has cyclomatic complexity 26 (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.
OutputFormat::call (cyclomatic 26) engine/baml-lib/jinja-runtime/src/output_format/mod.rs:42— OutputFormat::call has cyclomatic complexity 26 (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.
TypeTS::serialize_type (cyclomatic 26) engine/generators/languages/typescript/src/type.rs:151— TypeTS::serialize_type has cyclomatic complexity 26 (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.
btel_record_smoke.measure (cyclomatic 26) baml_language/tools/btel_record_smoke.py:33— btel_record_smoke.measure 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.
baml_release_platforms.load_wrapper_targets (cyclomatic 26) scripts/baml_release_platforms.py:72— baml_release_platforms.load_wrapper_targets 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.
page.loadExamples (cyclomatic 26) engine/baml-runtime/src/control_flow/mermaid-sandbox/app/page.tsx:46— page.loadExamples has cyclomatic complexity 26 (threshold 15). Of this number, 23 points are the body's own statements and 3 belong to 3 function literals inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
index.testUltraComplex (cyclomatic 26) engine/generators/data/mixed_complex_types/typescript/index.ts:121— index.testUltraComplex has cyclomatic complexity 26 (threshold 15). Of this number, 21 points are the body's own statements and 5 belong to 2 function literals inside it that branch. 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.
graph-view.GraphView (cyclomatic 26) typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/prompt-preview/graph-view.tsx:44— graph-view.GraphView has cyclomatic complexity 26 (threshold 15). Most of this is not in the body itself: 8 of the 26 points are its own statements and the rest belongs to 10 function items inside it that branch (a function literal at line 212, a function literal at line 95, a function literal at line 100, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
verify.verifyGeneratedRelease (cyclomatic 26) typescript2/app-developer-docs/lib/generated-content/verify.ts:19— verify.verifyGeneratedRelease 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.
page.AgentsPage (cyclomatic 26) typescript2/app-website/app/atb/agents/page.tsx:37— page.AgentsPage has cyclomatic complexity 26 (threshold 15). Most of this is not in the body itself: 4 of the 26 points are its own statements and the rest belongs to 4 function items inside it that branch (a function literal at line 104, resolve, a function literal at line 69, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
TelemetryView.ErrorCaptureView (cyclomatic 26) typescript2/pkg-playground/src/telemetry/TelemetryView.tsx:1514— TelemetryView.ErrorCaptureView has cyclomatic complexity 26 (threshold 15). Of this number, 25 points are the body's own statements and 1 belongs to one function literal inside it that branches. 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.
decode.deserializeValue (cyclomatic 26) typescript2/pkg-proto/src/decode.ts:234— decode.deserializeValue has cyclomatic complexity 26 (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.
BamlValue.TryGet (cyclomatic 25) baml_language/sdks/csharp/bridge_csharp/src/Values/BamlValue.cs:309— BamlValue.TryGet has cyclomatic complexity 25 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function, or replace a long branch ladder over a single value with a data-driven lookup or dispatch table. This is NOT this file's highest cyclomatic complexity: BamlTypeDescriptor.FromWire (cyclomatic 27) 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 method is counted neither in this dimension's figures nor in its score.
QueryArgs::run (cyclomatic 25) baml_language/crates/baml_cli/src/query_command.rs:168— QueryArgs::run 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.
baml_query::value::semantics::semantic_eq (cyclomatic 25) baml_language/crates/baml_query/src/value/semantics.rs:130— baml_query::value::semantics::semantic_eq 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.
cargo_size_gate::output::render_aggregate_markdown (cyclomatic 25) baml_language/crates/tools_size_gate/src/output.rs:628— cargo_size_gate::output::render_aggregate_markdown 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.
RenderContext::type_source (cyclomatic 25) baml_language/sdks/csharp/sdkgen_csharp/src/semantic.rs:819— RenderContext::type_source 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.
Statement::to_doc (cyclomatic 25) engine/baml-compiler/src/hir/dump.rs:133— Statement::to_doc 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.
ParserDatabase::to_jinja_type (cyclomatic 25) engine/baml-lib/parser-database/src/walkers/mod.rs:319— ParserDatabase::to_jinja_type 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.
Builder.build_target (cyclomatic 25) engine/language_client_cffi/build.py:245— Builder.build_target 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.
baml_go.validateBAMLTypeDefinition (cyclomatic 25) baml_language/sdks/go/baml_go/value.go:284— baml_go.validateBAMLTypeDefinition 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.
Encode.swift.encodeCallArgs (cyclomatic 25) baml_language/sdks/swift/Sources/BamlBridge/Encode.swift:344— Encode.swift.encodeCallArgs has cyclomatic complexity 25 (threshold 15). Of this number, 16 points are the body's own statements and 9 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.
unified-prompt-preview.UnifiedPromptPreview (cyclomatic 25) typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/prompt-preview/unified-prompt-preview.tsx:99— unified-prompt-preview.UnifiedPromptPreview has cyclomatic complexity 25 (threshold 15). Of this number, 18 points are the body's own statements and 7 belong to 2 function items inside it that branch. 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.
comments.CommentThread (cyclomatic 25) typescript2/app-website/app/atb/_components/comments.tsx:95— comments.CommentThread has cyclomatic complexity 25 (threshold 15). Most of this is not in the body itself: 11 of the 25 points are its own statements and the rest belongs to 4 function items inside it that branch (submit, a function literal at line 177, beginCompose, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
shiki-grammars.convertTextmateToShiki (cyclomatic 25) typescript2/app-website/lib/mdx/shiki-grammars.tsx:13— shiki-grammars.convertTextmateToShiki has cyclomatic complexity 25 (threshold 15). Most of this is not in the body itself: 1 of the 25 points is its own statement and the rest belongs to 3 function items inside it that branch (processRepository, a function literal at line 57, convertCaptures). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
CapturedValueCard.CapturedValueCard (cyclomatic 25) typescript2/pkg-playground/src/CapturedValueCard.tsx:95— CapturedValueCard.CapturedValueCard has cyclomatic complexity 25 (threshold 15). Of this number, 21 points are the body's own statements and 4 belong to one function literal inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ExecutionPanel.ExecutionPanel::handleCursorContext (cyclomatic 25) typescript2/pkg-playground/src/ExecutionPanel.tsx:958— ExecutionPanel.ExecutionPanel::handleCursorContext has cyclomatic complexity 25 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages. This shape REPEATS in the file: one other method here (ExecutionPanel.ExecutionPanel) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
BamlValue::baml_decode (cyclomatic 24) languages/rust/baml/src/codec/baml_value.rs:194— BamlValue::baml_decode 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.
DescribeArgs::run (cyclomatic 24) baml_language/crates/baml_cli/src/describe_command.rs:313— DescribeArgs::run 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.
baml_query_profiles::decode::convert (cyclomatic 24) baml_language/crates/baml_query_profiles/src/decode.rs:134— baml_query_profiles::decode::convert 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.
ExecutionReader::load (cyclomatic 24) baml_language/crates/bex_prof_store/src/prof/backend/reader.rs:680— ExecutionReader::load 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.
Value::equal (cyclomatic 24) baml_language/crates/btel_reader/src/value/equality.rs:129— Value::equal 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.
telemetry_resources.run_case (cyclomatic 24) baml_language/scripts/telemetry_resources.py:315— telemetry_resources.run_case 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.
DebugPanel.buildNodesByFile (cyclomatic 24) REDACTED:53— DebugPanel.buildNodesByFile has cyclomatic complexity 24 (threshold 15). Of this number, 16 points are the body's own statements and 8 belong to 2 function items inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
SmartEdge.mergePoints (cyclomatic 24) typescript/packages/playground-common/src/graph-primitives/edges/EdgeController/smart-edge.ts:271— SmartEdge.mergePoints 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.
index.LLMNode (cyclomatic 24) typescript/packages/playground-common/src/graph-primitives/nodes/LLMNode/index.tsx:8— index.LLMNode has cyclomatic complexity 24 (threshold 15). Most of this is not in the body itself: 9 of the 24 points are its own statements and the rest belongs to 4 function items inside it that branch (getOutputPreview, getStateStyle, a function literal at line 156, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
route.PUT (cyclomatic 24) REDACTED:391— route.PUT 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.
dictionary-types.unsafeDirectValue (cyclomatic 24) typescript2/app-developer-docs/tools/oxlint/anti-slop/shared/dictionary-types.ts:176— dictionary-types.unsafeDirectValue 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.
media.MDXMedia (cyclomatic 24) typescript2/app-website/lib/mdx/media.tsx:7— media.MDXMedia has cyclomatic complexity 24 (threshold 15). Of this number, 17 points are the body's own statements and 7 belong to 2 function literals inside it that branch. 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.
args-form-model.defaultValue (cyclomatic 24) typescript2/pkg-playground/src/args-form-model.ts:145— args-form-model.defaultValue 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.
FunctionSidebar.FunctionSidebar (cyclomatic 24) typescript2/pkg-playground/src/FunctionSidebar.tsx:431— FunctionSidebar.FunctionSidebar has cyclomatic complexity 24 (threshold 15). Of this number, 22 points are the body's own statements and 2 belong to 2 function literals inside it that branch. 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.
group-node.GroupNode (cyclomatic 24) typescript2/pkg-playground/src/graph/nodes/group-node.tsx:20— group-node.GroupNode 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.
GenerateArgs::run_generate (cyclomatic 23) baml_language/crates/baml_cli/src/generate.rs:297— GenerateArgs::run_generate 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.
WitnessPat::render (cyclomatic 23) baml_language/crates/baml_compiler2_hir_ty/src/exhaustiveness.rs:671— WitnessPat::render 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.
RenderDefinitionValidator::visit (cyclomatic 23) baml_language/crates/bex_vm/src/package_reflect/type_class.rs:271— RenderDefinitionValidator::visit 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.
ArtifactTelemetry::from_manifest (cyclomatic 23) baml_language/crates/btel_settings/src/artifact.rs:317— ArtifactTelemetry::from_manifest 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.
kpis.build (cyclomatic 23) baml_language/tools/speedtest/src/speedtest/kpis.py:69— kpis.build 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.
Builder.build_all (cyclomatic 23) engine/language_client_cffi/build.py:408— Builder.build_all 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.
baml_go.prepareInvocation (cyclomatic 23) baml_language/sdks/go/baml_go/invocation.go:50— baml_go.prepareInvocation 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.
baml_go.isJSONBAMLType (cyclomatic 23) baml_language/sdks/go/baml_go/json.go:340— baml_go.isJSONBAMLType has cyclomatic complexity 23 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
baml_go.decodeMedia (cyclomatic 23) baml_language/sdks/go/baml_go/media.go:677— baml_go.decodeMedia 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.
BamlRuntime.executeTests (cyclomatic 23) typescript/packages/playground-common/src/sdk/runtime/BamlRuntime.ts:837— BamlRuntime.executeTests has cyclomatic complexity 23 (threshold 15). Most of this is not in the body itself: 10 of the 23 points are its own statements and the rest belongs to 3 function literals inside it that branch (lines 914, 846, 885). 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.
preview-toolbar.PreviewToolbar (cyclomatic 23) typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/preview-toolbar.tsx:97— preview-toolbar.PreviewToolbar has cyclomatic complexity 23 (threshold 15). Of this number, 19 points are the body's own statements and 4 belong to 4 function items inside it that branch. 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.
prompts.buildAIAssistantPrompt (cyclomatic 23) typescript2/app-beps/convex/lib/prompts.ts:65— prompts.buildAIAssistantPrompt has cyclomatic complexity 23 (threshold 15). Most of this is not in the body itself: 11 of the 23 points are its own statements and the rest belongs to 7 function items inside it that branch (a function literal at line 102, formatVersion, a function literal at line 86, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
route.POST (cyclomatic 23) REDACTED:273— route.POST 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.
dictionary-types.dictionaryValueTypes (cyclomatic 23) typescript2/app-developer-docs/tools/oxlint/anti-slop/shared/dictionary-types.ts:232— dictionary-types.dictionaryValueTypes has cyclomatic complexity 23 (threshold 15). Of this number, 21 points are the body's own statements and 2 belong to one function literal inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
article.Article (cyclomatic 23) typescript2/app-website/app/baml-intro/_components/article.tsx:343— article.Article has cyclomatic complexity 23 (threshold 15). Most of this is not in the body itself: 9 of the 23 points are its own statements and the rest belongs to 4 function literals inside it that branch (lines 367, 354, 435, …). 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.
council-gate.Council (cyclomatic 23) typescript2/app-website/app/sheep-council/council-gate.tsx:210— council-gate.Council has cyclomatic complexity 23 (threshold 15). Of this number, 13 points are the body's own statements and 10 belong to 3 function items inside it that branch. 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.
perspective-slider.PerspectiveSlider (cyclomatic 23) REDACTED:1307— perspective-slider.PerspectiveSlider has cyclomatic complexity 23 (threshold 15). Most of this is not in the body itself: 11 of the 23 points are its own statements and the rest belongs to 4 function items inside it that branch (onKeyDown, a function literal at line 1315, tabStyle, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
MetadataBadges.extractMetadata (cyclomatic 23) typescript2/pkg-playground/src/components/MetadataBadges.tsx:15— MetadataBadges.extractMetadata 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.
use-telemetry.useTelemetry (cyclomatic 23) typescript2/pkg-playground/src/telemetry/use-telemetry.ts:100— use-telemetry.useTelemetry has cyclomatic complexity 23 (threshold 15). Most of this is not in the body itself: 1 of the 23 points is its own statement and the rest belongs to 12 function literals inside it that branch (lines 150, 163, 178, …). 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.
encode.serializeValue (cyclomatic 23) typescript2/pkg-proto/src/encode.ts:21— encode.serializeValue 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.
PrimitiveProtocol.DecodeStreamPull (cyclomatic 22) baml_language/sdks/csharp/bridge_csharp/src/Proto/PrimitiveProtocol.cs:330— PrimitiveProtocol.DecodeStreamPull has cyclomatic complexity 22 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
FeedbackInner::run (cyclomatic 22) baml_language/crates/baml_cli/src/feedback_command.rs:206— FeedbackInner::run 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.
TelemetryRuntime::write_span_with_context (cyclomatic 22) baml_language/crates/btel_processor/src/runtime.rs:632— TelemetryRuntime::write_span_with_context 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.
baml_log::logger::log_event_internal (cyclomatic 22) engine/baml-lib/baml-log/src/logger.rs:767— baml_log::logger::log_event_internal 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.
VertexClient::build_request (cyclomatic 22) engine/baml-runtime/src/internal/llm_client/primitive/vertex/vertex_client.rs:240— VertexClient::build_request 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.
bump-version.perform_version_bumps (cyclomatic 22) tools/bump-version.py:322— bump-version.perform_version_bumps 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.
baml_go.resolveRuntime (cyclomatic 22) baml_language/sdks/go/baml_go/runtime_artifact.go:171— baml_go.resolveRuntime 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.
serde.typeToString (cyclomatic 22) engine/language_client_go/baml_go/serde/decode.go:479— serde.typeToString has cyclomatic complexity 22 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
BamlUnion3._bamlDecode (cyclomatic 22) baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:177— BamlUnion3._bamlDecode 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.
EmbedDialog.EmbedDialog (cyclomatic 22) typescript/apps/fiddle-web-app/app/[project_id]/_components/EmbedDialog.tsx:36— EmbedDialog.EmbedDialog has cyclomatic complexity 22 (threshold 15). Most of this is not in the body itself: 8 of the 22 points are its own statements and the rest belongs to 4 function items inside it that branch (a function literal at line 65, buildUrl, a function literal at line 62, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
SmartEdge.splitPoints (cyclomatic 22) typescript/packages/playground-common/src/graph-primitives/edges/EdgeController/smart-edge.ts:138— SmartEdge.splitPoints 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.
index.BaseNode (cyclomatic 22) typescript/packages/playground-common/src/graph-primitives/nodes/BaseNode/index.tsx:8— index.BaseNode has cyclomatic complexity 22 (threshold 15). Of this number, 13 points are the body's own statements and 9 belong to 3 function items inside it that branch. 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.
bep-export-all-dialog.BepExportAllDialog (cyclomatic 22) typescript2/app-beps/src/components/bep/bep-export-all-dialog.tsx:73— bep-export-all-dialog.BepExportAllDialog has cyclomatic complexity 22 (threshold 15). Of this number, 12 points are the body's own statements and 10 belong to 2 function literals inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
bep-table-of-contents.BepTableOfContents (cyclomatic 22) typescript2/app-beps/src/components/bep/bep-table-of-contents.tsx:58— bep-table-of-contents.BepTableOfContents has cyclomatic complexity 22 (threshold 15). Most of this is not in the body itself: 5 of the 22 points are its own statements and the rest belongs to 7 function literals inside it that branch (lines 121, 147, 154, …). 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.
comment-thread.CommentThread (cyclomatic 22) typescript2/app-beps/src/components/comments/comment-thread.tsx:427— comment-thread.CommentThread has cyclomatic complexity 22 (threshold 15). Of this number, 12 points are the body's own statements and 10 belong to 4 function literals inside it that branch. 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.
package-generator.buildReferencePages (cyclomatic 22) typescript2/app-developer-docs/lib/generated-content/package-generator.ts:161— package-generator.buildReferencePages has cyclomatic complexity 22 (threshold 15). Of this number, 19 points are the body's own statements and 3 belong to 3 function literals inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
particles.Particles (cyclomatic 22) typescript2/app-website/components/magicui/particles.tsx:51— particles.Particles has cyclomatic complexity 22 (threshold 15). Most of this is not in the body itself: 2 of the 22 points are its own statements and the rest belongs to 8 function items inside it that branch (a function literal at line 214, onMouseMove, resizeCanvas, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
FunctionSidebar.FunctionTreeNode (cyclomatic 22) typescript2/pkg-playground/src/FunctionSidebar.tsx:286— FunctionSidebar.FunctionTreeNode has cyclomatic complexity 22 (threshold 15). Of this number, 19 points are the body's own statements and 3 belong to 2 function literals inside it that branch. 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.
lod.applyLevelOfDetail (cyclomatic 22) typescript2/pkg-playground/src/graph/lod.ts:106— lod.applyLevelOfDetail has cyclomatic complexity 22 (threshold 15). Of this number, 14 points are the body's own statements and 8 belong to 3 function items inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ReplayServer.ServeRequestAsync (cyclomatic 21) baml_language/sdk_tests/crates/csharp/streaming/Program.cs:433— ReplayServer.ServeRequestAsync 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.
TriviaInfo::classify_trivia (cyclomatic 21) baml_language/crates/baml_fmt/src/trivia_classifier.rs:30— TriviaInfo::classify_trivia 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.
IntTy::coerce (cyclomatic 21) baml_language/crates/bex_sap/src/deserializer/coercer/coerce_primitive.rs:115— IntTy::coerce 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.
sys_glob::glob_to_regex (cyclomatic 21) baml_language/crates/sys_glob/src/lib.rs:98— sys_glob::glob_to_regex 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.
NativeSysOps::_send_sse (cyclomatic 21) baml_language/crates/sys_native/src/io_impls.rs:3175— NativeSysOps::_send_sse has cyclomatic complexity 21 (threshold 15). Of this number, 19 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.
GoNames::for_pool (cyclomatic 21) baml_language/sdks/go/sdkgen_go/src/names.rs:395— GoNames::for_pool 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. This is NOT this file's highest cyclomatic complexity: sdkgen_go::names::union_type_component (cyclomatic 25) 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.
IRHelperExtended::distribute_type_with_meta (cyclomatic 21) engine/baml-lib/baml-core/src/ir/ir_helpers/mod.rs:230— IRHelperExtended::distribute_type_with_meta 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: IRHelperExtended::is_subtype (cyclomatic 29) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded function is counted neither in this dimension's figures nor in its score.
RubyToJson::serialize_baml (cyclomatic 21) engine/language_client_ruby/ext/ruby_ffi/src/ruby_to_json.rs:59— RubyToJson::serialize_baml has cyclomatic complexity 21 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
ProtoReader.armMatchesValue (cyclomatic 21) baml_language/sdks/java/baml_bridge/src/main/java/baml_bridge/internal/ProtoReader.java:1415— ProtoReader.armMatchesValue has cyclomatic complexity 21 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
schedule.validate (cyclomatic 21) tools/bctl_src/oncall/schedule.py:51— schedule.validate 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.
Run.fixture (cyclomatic 21) baml_language/tools/btel_query_smoke.py:124— Run.fixture 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.
baml_go.findOrDownloadLibrary (cyclomatic 21) engine/language_client_go/baml_go/lib_common.go:251— baml_go.findOrDownloadLibrary 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.
serde.encodeValue (cyclomatic 21) engine/language_client_go/baml_go/serde/encode.go:66— serde.encodeValue 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.
atomWithHashBase64.atomWithHash (cyclomatic 21) typescript/apps/fiddle-web-app/lib/atomWithHashBase64.ts:18— atomWithHashBase64.atomWithHash has cyclomatic complexity 21 (threshold 15). Most of this is not in the body itself: 10 of the 21 points are its own statements and the rest belongs to 8 function items inside it that branch (a function literal at line 113, a function literal at line 41, a function literal at line 31, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
bep-list.BepList (cyclomatic 21) typescript2/app-beps/src/components/bep/bep-list.tsx:46— bep-list.BepList has cyclomatic complexity 21 (threshold 15). Of this number, 14 points are the body's own statements and 7 belong to 5 function items inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
decision-form.DecisionForm (cyclomatic 21) typescript2/app-beps/src/components/decisions/decision-form.tsx:35— decision-form.DecisionForm has cyclomatic complexity 21 (threshold 15). Of this number, 11 points are the body's own statements and 10 belong to 3 function items inside it that branch. 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.
pipeline.stageInfo (cyclomatic 21) typescript2/app-feedback/src/lib/pipeline.ts:37— pipeline.stageInfo has cyclomatic complexity 21 (threshold 15). Of this number, 20 points are the body's own statements and 1 belongs to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
app.App (cyclomatic 21) typescript2/app-type-quiz/src/app.tsx:574— app.App has cyclomatic complexity 21 (threshold 15). Most of this is not in the body itself: 9 of the 21 points are its own statements and the rest belongs to 9 function literals inside it that branch (lines 705, 643, 588, …). 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.
flickering-grid.FlickeringGrid (cyclomatic 21) typescript2/app-website/components/magicui/flickering-grid.tsx:23— flickering-grid.FlickeringGrid has cyclomatic complexity 21 (threshold 15). Most of this is not in the body itself: 1 of the 21 points is its own statement and the rest belongs to 8 function literals inside it that branch (lines 48, 151, 167, …). 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.
vscode.VSCodeMock (cyclomatic 21) typescript2/app-website/components/vscode.tsx:30— vscode.VSCodeMock has cyclomatic complexity 21 (threshold 15). Of this number, 19 points are the body's own statements and 2 belong to one function literal inside it that branches. 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.
BamlPlayground.BamlPlayground (cyclomatic 21) typescript2/app-website/playground/BamlPlayground.tsx:33— BamlPlayground.BamlPlayground has cyclomatic complexity 21 (threshold 15). Of this number, 11 points are the body's own statements and 10 belong to 8 function items inside it that branch. 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.
TelemetryView.TimingsTab (cyclomatic 21) typescript2/pkg-playground/src/telemetry/TelemetryView.tsx:2282— TelemetryView.TimingsTab has cyclomatic complexity 21 (threshold 15). Most of this is not in the body itself: 7 of the 21 points are its own statements and the rest belongs to 5 function literals inside it that branch (lines 2316, 2317, 2355, …). 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.
walkNodeModuleFile::visitModuleBody (cyclomatic 21) tools/stdlib-matrix/extractors/ts-surface.mjs:423— walkNodeModuleFile::visitModuleBody 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.
baml_base::escape::decode_escape (cyclomatic 20) baml_language/crates/baml_base/src/escape.rs:388— baml_base::escape::decode_escape has cyclomatic complexity 20 (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.
LeafBody::needs_baml_pyhandle (cyclomatic 20) baml_language/sdks/python/rust/sdkgen_python_pydantic2/src/leaf.rs:131— LeafBody::needs_baml_pyhandle has cyclomatic complexity 20 (threshold 15). Most of this is not in the body itself: 8 of the 20 points are its own statements and the rest belongs to one function item inside it that branches (ty_uses_rust_type). 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.
GraphBuilder::build_header (cyclomatic 20) engine/baml-lib/ast/src/ast/baml_vis/graph.rs:424— GraphBuilder::build_header 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.
Stmt::fmt (cyclomatic 20) engine/baml-lib/ast/src/ast/stmt.rs:192— Stmt::fmt 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.
TypeGeneric::to_union_name (cyclomatic 20) engine/baml-lib/baml-types/src/ir_type/mod.rs:931— TypeGeneric::to_union_name has cyclomatic complexity 20 (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.
proto.decode_value (cyclomatic 20) baml_language/sdks/python/src/baml_bridge/proto.py:1368— proto.decode_value 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.
smoke-go-release.main (cyclomatic 20) scripts/smoke-go-release.py:213— smoke-go-release.main 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.
baml_go.reflectedBAMLType (cyclomatic 20) baml_language/sdks/go/baml_go/dynamic.go:238— baml_go.reflectedBAMLType 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.
baml_go.collectOutboundHandles (cyclomatic 20) baml_language/sdks/go/baml_go/media.go:98— baml_go.collectOutboundHandles 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.
baml_go.releaseOutboundOpaqueHostValues (cyclomatic 20) baml_language/sdks/go/baml_go/media.go:149— baml_go.releaseOutboundOpaqueHostValues 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.
index.testMixedOptionalNullable (cyclomatic 20) engine/generators/data/optional_nullable/typescript/index.ts:65— index.testMixedOptionalNullable has cyclomatic complexity 20 (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.
index.GroupNode (cyclomatic 20) typescript/packages/playground-common/src/graph-primitives/nodes/GroupNode/index.tsx:6— index.GroupNode has cyclomatic complexity 20 (threshold 15). Of this number, 18 points are the body's own statements and 2 belong to 2 function literals inside it that branch. 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.
page.UsersPage (cyclomatic 20) typescript2/app-beps/src/app/users/page.tsx:147— page.UsersPage has cyclomatic complexity 20 (threshold 15). Of this number, 12 points are the body's own statements and 8 belong to 3 function items inside it that branch. 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.
bep-routes.parseBepSegments (cyclomatic 20) typescript2/app-beps/src/lib/bep-routes.ts:31— bep-routes.parseBepSegments 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.
dictionary-types.classifyWideningTarget (cyclomatic 20) typescript2/app-developer-docs/tools/oxlint/anti-slop/shared/dictionary-types.ts:320— dictionary-types.classifyWideningTarget 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.
dictionary-types.classifyAliasBroadTarget (cyclomatic 20) typescript2/app-developer-docs/tools/oxlint/anti-slop/shared/dictionary-types.ts:422— dictionary-types.classifyAliasBroadTarget 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.
issue-detail.IssueDetail (cyclomatic 20) typescript2/app-feedback/src/components/issues/issue-detail.tsx:64— issue-detail.IssueDetail has cyclomatic complexity 20 (threshold 15). Of this number, 19 points are the body's own statements and 1 belongs to one function literal inside it that branches. 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.
issue-list.IssueList (cyclomatic 20) typescript2/app-feedback/src/components/issues/issue-list.tsx:110— issue-list.IssueList has cyclomatic complexity 20 (threshold 15). Most of this is not in the body itself: 9 of the 20 points are its own statements and the rest belongs to 8 function literals inside it that branch (lines 129, 125, 124, …). 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.
newsletter-form.NewsletterForm (cyclomatic 20) typescript2/app-website/app/blog/_components/newsletter-form.tsx:36— newsletter-form.NewsletterForm has cyclomatic complexity 20 (threshold 15). Most of this is not in the body itself: 5 of the 20 points are its own statements and the rest belongs to 9 function items inside it that branch (handleSubmit, SignUpFormButton, hasRecentSubmission, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
NewsletterForm.NewsletterForm (cyclomatic 20) typescript2/app-website/components/NewsletterForm.tsx:35— NewsletterForm.NewsletterForm has cyclomatic complexity 20 (threshold 15). Most of this is not in the body itself: 5 of the 20 points are its own statements and the rest belongs to 9 function items inside it that branch (handleSubmit, SignUpFormButton, hasRecentSubmission, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
story-timeline.EraCard (cyclomatic 20) typescript2/app-website/components/landing/story-timeline.tsx:60— story-timeline.EraCard 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.
ApiKeysDialog.ApiKeysDialog::renderRow (cyclomatic 20) typescript2/pkg-playground/src/components/ApiKeysDialog.tsx:204— ApiKeysDialog.ApiKeysDialog::renderRow has cyclomatic complexity 20 (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.
BamlValue.AddValueHash (cyclomatic 19) baml_language/sdks/csharp/bridge_csharp/src/Values/BamlValue.cs:711— BamlValue.AddValueHash 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. This is NOT this file's highest cyclomatic complexity: BamlTypeDescriptor.FromWire (cyclomatic 27) 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 method is counted neither in this dimension's figures nor in its score.
EscapeIssue::fmt (cyclomatic 19) baml_language/crates/baml_base/src/escape.rs:185— EscapeIssue::fmt 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.
Matrix::specialize (cyclomatic 19) baml_language/crates/baml_compiler2_hir_ty/src/exhaustiveness.rs:976— Matrix::specialize 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.
BigintTy::coerce (cyclomatic 19) baml_language/crates/bex_sap/src/deserializer/coercer/coerce_primitive.rs:304— BigintTy::coerce 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.
BcsDeliveryHandle::submit (cyclomatic 19) baml_language/crates/btel_bcs/src/delivery.rs:801— BcsDeliveryHandle::submit 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.
EncodedSpans::event (cyclomatic 19) baml_language/crates/btel_recorder/src/encoding.rs:72— EncodedSpans::event 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.
IRSignature::new_from_ir (cyclomatic 19) engine/baml-lib/baml-core/src/ir/ir_hasher/mod.rs:291— IRSignature::new_from_ir 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.
internal_baml_prompt_parser::parser::parse_prompt::handle_print_block (cyclomatic 19) engine/baml-lib/prompt-parser/src/parser/parse_prompt.rs:179— internal_baml_prompt_parser::parser::parse_prompt::handle_print_block 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.
App::handle_key (cyclomatic 19) engine/baml-runtime/src/optimize/tui.rs:479— App::handle_key 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.
generators_lib::version_check::check_version (cyclomatic 19) engine/generators/utils/generators_lib/src/version_check.rs:29— generators_lib::version_check::check_version 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.
BamlType.matchesStructural (cyclomatic 19) baml_language/sdks/java/baml_bridge/src/main/java/baml_bridge/BamlType.java:799— BamlType.matchesStructural 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.
_invocation.normalize (cyclomatic 19) baml_language/sdks/python/src/baml_bridge/_invocation.py:16— _invocation.normalize 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.
proto.encode_call_args (cyclomatic 19) baml_language/sdks/python/src/baml_bridge/proto.py:783— proto.encode_call_args 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.
summarize.main (cyclomatic 19) baml_language/tools/gc_policy/summarize.py:10— summarize.main has cyclomatic complexity 19 (threshold 15). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
pkg.coerceToType (cyclomatic 19) REDACTED:399— pkg.coerceToType 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.
BamlPromptJSON._bamlDecode (cyclomatic 19) baml_language/sdks/swift/Sources/BamlBridge/Prompt.swift:120— BamlPromptJSON._bamlDecode 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.
index.testObjectArrays (cyclomatic 19) engine/generators/data/array_types/typescript/index.ts:85— index.testObjectArrays has cyclomatic complexity 19 (threshold 15). Of this number, 10 points are the body's own statements and 9 belong to 3 function literals inside it that branch. 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.
index.testSimpleMaps (cyclomatic 19) engine/generators/data/map_types/typescript/index.ts:3— index.testSimpleMaps has cyclomatic complexity 19 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
index.testNestedMaps (cyclomatic 19) engine/generators/data/map_types/typescript/index.ts:113— index.testNestedMaps has cyclomatic complexity 19 (threshold 15). Of this number, 18 points are the body's own statements and 1 belongs to one function literal inside it that branches. 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.
index.testDeeplyNested (cyclomatic 19) engine/generators/data/nested_structures/typescript/index.ts:80— index.testDeeplyNested has cyclomatic complexity 19 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
index.testMixedPrimitives (cyclomatic 19) engine/generators/data/primitive_types/typescript/index.ts:94— index.testMixedPrimitives has cyclomatic complexity 19 (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.
clientwrapper.EmbedComponentInner (cyclomatic 19) typescript/apps/fiddle-web-app/app/embed/clientwrapper.tsx:91— clientwrapper.EmbedComponentInner has cyclomatic complexity 19 (threshold 15). Of this number, 13 points are the body's own statements and 6 belong to 5 function literals inside it that branch. 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.
collapsible-message.CollapsibleMessage (cyclomatic 19) typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/prompt-preview/collapsible-message.tsx:24— collapsible-message.CollapsibleMessage has cyclomatic complexity 19 (threshold 15). Most of this is not in the body itself: 6 of the 19 points are its own statements and the rest belongs to 3 function items inside it that branch (getMediaIndicator, a function literal at line 32, a function literal at line 90). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
route.GET (cyclomatic 19) typescript2/app-beps/src/app/api/agent/beps/[number]/comments/route.ts:140— route.GET has cyclomatic complexity 19 (threshold 15). Of this number, 13 points are the body's own statements and 6 belong to one function literal inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
bep-route-shell.BepRouteShell::handleConfirmSubmit (cyclomatic 19) typescript2/app-beps/src/components/bep/bep-route-shell.tsx:572— bep-route-shell.BepRouteShell::handleConfirmSubmit has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This shape REPEATS in the file: one other method here (bep-route-shell.BepRouteShell) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
page.IssuesPage (cyclomatic 19) typescript2/app-website/app/atb/issues/page.tsx:20— page.IssuesPage has cyclomatic complexity 19 (threshold 15). Most of this is not in the body itself: 3 of the 19 points are its own statements and the rest belongs to 3 function literals inside it that branch (lines 76, 30, 27). 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.
ProblemsBoard.ProblemsBoard (cyclomatic 19) typescript2/app-website/app/bamlcode/_components/ProblemsBoard.tsx:36— ProblemsBoard.ProblemsBoard has cyclomatic complexity 19 (threshold 15). Most of this is not in the body itself: 3 of the 19 points are its own statements and the rest belongs to 8 function literals inside it that branch (lines 51, 119, 42, …). 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.
code-mirror-viewer.CodeMirrorViewer (cyclomatic 19) typescript2/app-website/lib/mdx/baml-block/baml-project-panel/codemirror-panel/code-mirror-viewer.tsx:51— code-mirror-viewer.CodeMirrorViewer has cyclomatic complexity 19 (threshold 15). Most of this is not in the body itself: 1 of the 19 points is its own statement and the rest belongs to 7 function literals inside it that branch (lines 137, 111, 265, …). 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.
ArgsForm.FieldInput (cyclomatic 19) typescript2/pkg-playground/src/ArgsForm.tsx:266— ArgsForm.FieldInput 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.
ExecutionPanel.CollectionDebugView (cyclomatic 19) typescript2/pkg-playground/src/ExecutionPanel.tsx:369— ExecutionPanel.CollectionDebugView has cyclomatic complexity 19 (threshold 15). Most of this is not in the body itself: 8 of the 19 points are its own statements and the rest belongs to 2 function literals inside it that branch (lines 415, 429). 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.
loadRuns (cyclomatic 19) typescript2/app-speedtest/api-server.mjs:23— loadRuns has cyclomatic complexity 19 (threshold 15). Of this number, 17 points are the body's own statements and 2 belong to one function literal inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
BamlGeneratedCodecContext.ReadUnionCore (cyclomatic 18) baml_language/sdks/csharp/bridge_csharp/src/Generated/V1/BamlGeneratedCodec.cs:708— BamlGeneratedCodecContext.ReadUnionCore 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.
BamlGeneratedRegistry.CreateCanonicalType (cyclomatic 18) baml_language/sdks/csharp/bridge_csharp/src/Generated/V1/BamlGeneratedRegistry.cs:716— BamlGeneratedRegistry.CreateCanonicalType 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.
BamlValue.From (cyclomatic 18) baml_language/sdks/csharp/bridge_csharp/src/Values/BamlValue.cs:226— BamlValue.From has cyclomatic complexity 18 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages. This is NOT this file's highest cyclomatic complexity: BamlTypeDescriptor.FromWire (cyclomatic 27) 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 method is counted neither in this dimension's figures nor in its score.
baml_linker::space::relocate (cyclomatic 18) baml_language/crates/baml_linker/src/space.rs:255— baml_linker::space::relocate 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.
ProfilerStore::publish_bytes_locked (cyclomatic 18) baml_language/crates/bex_prof_store/src/prof/backend/store.rs:833— ProfilerStore::publish_bytes_locked has cyclomatic complexity 18 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ProjectRuntimeCompiler::compile (cyclomatic 18) baml_language/crates/bex_project/src/runtime_compile.rs:1738— ProjectRuntimeCompiler::compile 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.
WasmIoFs::mkdir (cyclomatic 18) baml_language/crates/bridge_wasm/src/wasm_io_fs.rs:525— WasmIoFs::mkdir 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.
Processor::process_available (cyclomatic 18) baml_language/crates/btel_processor/src/lib.rs:571— Processor::process_available 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.
Code::group (cyclomatic 18) baml_language/crates/btel_reader/src/value/code.rs:220— Code::group 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.
WasmHost::call_registered_callable_with_context (cyclomatic 18) baml_language/crates/sys_wasm/src/host_value.rs:644— WasmHost::call_registered_callable_with_context 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.
MermaidGeneratorContext::render_mermaid_graph (cyclomatic 18) engine/baml-lib/ast/src/ast/baml_vis/diagram_generator.rs:79— MermaidGeneratorContext::render_mermaid_graph has cyclomatic complexity 18 (threshold 15). Most of this is not in the body itself: 8 of the 18 points are its own statements and the rest belongs to one function item inside it that branches (emit). 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.
InitUI::render (cyclomatic 18) REDACTED:93— InitUI::render 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.
CandidateApplier::update_field_attributes (cyclomatic 18) engine/baml-runtime/src/optimize/applier.rs:315— CandidateApplier::update_field_attributes 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.
TypePy::serialize_type (cyclomatic 18) engine/generators/languages/python/src/type.rs:130— TypePy::serialize_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.
playground_server::handlers::webview_rpc::webview_rpc_handler (cyclomatic 18) engine/playground-server/src/handlers/webview_rpc.rs:32— playground_server::handlers::webview_rpc::webview_rpc_handler 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.
ProtoReader.decodeClassWithDesc (cyclomatic 18) baml_language/sdks/java/baml_bridge/src/main/java/baml_bridge/internal/ProtoReader.java:1272— ProtoReader.decodeClassWithDesc has cyclomatic complexity 18 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions. This is NOT this file's highest cyclomatic complexity: ProtoReader.decodeValue (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 method is counted neither in this dimension's figures nor in its score.
telemetry_resources.monitor (cyclomatic 18) baml_language/scripts/telemetry_resources.py:240— telemetry_resources.monitor 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.
btel_query_summary.query_section (cyclomatic 18) baml_language/tools/btel_query_summary.py:89— btel_query_summary.query_section 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.
analyze_ffi.parse_log (cyclomatic 18) scripts/ffi-debug/analyze_ffi.py:49— analyze_ffi.parse_log 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.
baml_go.currentRuntimeConfig (cyclomatic 18) baml_language/sdks/go/baml_go/runtime_artifact.go:90— baml_go.currentRuntimeConfig has cyclomatic complexity 18 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
index.testOptionalFields (cyclomatic 18) engine/generators/data/optional_nullable/typescript/index.ts:3— index.testOptionalFields 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.
index.testComplexUnions (cyclomatic 18) engine/generators/data/union_types_extended/typescript/index.ts:29— index.testComplexUnions has cyclomatic complexity 18 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ExecutionLogPanel.ExecutionLogPanel (cyclomatic 18) typescript/packages/playground-common/src/features/detail-panel/components/ExecutionLogPanel.tsx:333— ExecutionLogPanel.ExecutionLogPanel has cyclomatic complexity 18 (threshold 15). Most of this is not in the body itself: 3 of the 18 points are its own statements and the rest belongs to 4 function literals inside it that branch (lines 425, 352, 344, …). 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.
useEdgeDraggable.useEdgeDraggable (cyclomatic 18) typescript/packages/playground-common/src/graph-primitives/edges/EdgeController/useEdgeDraggable.tsx:24— useEdgeDraggable.useEdgeDraggable has cyclomatic complexity 18 (threshold 15). Most of this is not in the body itself: 2 of the 18 points are its own statements and the rest belongs to 6 function items inside it that branch (onDragging, onDragStart, isDraggingEdge, …). 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.
index.DiamondNode (cyclomatic 18) typescript/packages/playground-common/src/graph-primitives/nodes/DiamondNode/index.tsx:9— index.DiamondNode has cyclomatic complexity 18 (threshold 15). Most of this is not in the body itself: 5 of the 18 points are its own statements and the rest belongs to 3 function items inside it that branch (getStateStyle, a function literal at line 119, a function literal at line 105). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
code-mirror-viewer.CodeMirrorViewer (cyclomatic 18) typescript/packages/playground-common/src/shared/baml-project-panel/codemirror-panel/code-mirror-viewer.tsx:120— code-mirror-viewer.CodeMirrorViewer has cyclomatic complexity 18 (threshold 15). Most of this is not in the body itself: 3 of the 18 points are its own statements and the rest belongs to 7 function literals inside it that branch (lines 243, 416, 147, …). 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.
bep-submit-modal.BepSubmitModal (cyclomatic 18) typescript2/app-beps/src/components/bep/bep-submit-modal.tsx:31— bep-submit-modal.BepSubmitModal has cyclomatic complexity 18 (threshold 15). Of this number, 13 points are the body's own statements and 5 belong to 4 function items inside it that branch. 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.
issue-form.IssueForm (cyclomatic 18) typescript2/app-beps/src/components/issues/issue-form.tsx:34— issue-form.IssueForm has cyclomatic complexity 18 (threshold 15). Of this number, 10 points are the body's own statements and 8 belong to 3 function items inside it that branch. 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.
app.Reveal (cyclomatic 18) typescript2/app-type-quiz/src/app.tsx:274— app.Reveal has cyclomatic complexity 18 (threshold 15). Of this number, 12 points are the body's own statements and 6 belong to 4 function literals inside it that branch. 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.
episode-modal.EpisodeModal (cyclomatic 18) typescript2/app-website/app/podcast/_components/episode-modal.tsx:88— episode-modal.EpisodeModal has cyclomatic complexity 18 (threshold 15). Of this number, 16 points are the body's own statements and 2 belong to one function literal inside it that branches. 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.
script-copy-btn.ScriptCopyBtn (cyclomatic 18) typescript2/app-website/components/magicui/script-copy-btn.tsx:23— script-copy-btn.ScriptCopyBtn has cyclomatic complexity 18 (threshold 15). Of this number, 15 points are the body's own statements and 3 belong to 3 function literals inside it that branch. 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.
evidence.reparentToRetainedAncestors (cyclomatic 18) typescript2/pkg-playground/src/telemetry/evidence.ts:976— evidence.reparentToRetainedAncestors has cyclomatic complexity 18 (threshold 15). Of this number, 16 points are the body's own statements and 2 belong to 2 function items inside it that branch. 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.
TelemetryView.ContextTreeRows (cyclomatic 18) typescript2/pkg-playground/src/telemetry/TelemetryView.tsx:2985— TelemetryView.ContextTreeRows has cyclomatic complexity 18 (threshold 15). Of this number, 17 points are the body's own statements and 1 belongs to one function literal inside it that branches. 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.
baml_compiler2_hir::body_type_refs::collect_body_type_refs (cyclomatic 17) baml_language/crates/baml_compiler2_hir/src/body_type_refs.rs:114— baml_compiler2_hir::body_type_refs::collect_body_type_refs 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.
MapLiteral::single_line_width (cyclomatic 17) baml_language/crates/baml_fmt/src/ast/expressions.rs:4446— MapLiteral::single_line_width has cyclomatic complexity 17 (threshold 15). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline. This is NOT this file's highest cyclomatic complexity: Expression::from_cst (cyclomatic 38) 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.
PrintChain::try_print_members_single_line (cyclomatic 17) baml_language/crates/baml_fmt/src/ast/expressions.rs:6071— PrintChain::try_print_members_single_line 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: Expression::from_cst (cyclomatic 38) 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.
UnionTypeMember::take_base_type (cyclomatic 17) baml_language/crates/baml_fmt/src/ast/types.rs:456— UnionTypeMember::take_base_type 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.
FloatTy::coerce (cyclomatic 17) baml_language/crates/bex_sap/src/deserializer/coercer/coerce_primitive.rs:441— FloatTy::coerce 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.
Reader::object (cyclomatic 17) baml_language/crates/btel_snapshot/src/decode.rs:1050— Reader::object 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.
SseParser::feed (cyclomatic 17) baml_language/crates/sys_types/src/sse.rs:47— SseParser::feed 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.
bridge_python::host_value::discard_host_call_args (cyclomatic 17) baml_language/sdks/python/rust/bridge_python/src/host_value.rs:483— bridge_python::host_value::discard_host_call_args has cyclomatic complexity 17 (threshold 15). Most of this is not in the body itself: 4 of the 17 points are its own statements and the rest belongs to one function item inside it that branches (discard). 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.
PreOrderTraversal::from_root_dyn_impl (cyclomatic 17) engine/boundary-udf/src/yaml2jinja.rs:333— PreOrderTraversal::from_root_dyn_impl 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.
proto._ty_to_python_type (cyclomatic 17) baml_language/sdks/python/src/baml_bridge/proto.py:886— proto._ty_to_python_type has cyclomatic complexity 17 (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.
csharp-mtime-cache.restore (cyclomatic 17) .github/scripts/csharp-mtime-cache.py:98— csharp-mtime-cache.restore 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.
telemetry_resource_report.render_report (cyclomatic 17) baml_language/scripts/telemetry_resource_report.py:248— telemetry_resource_report.render_report has cyclomatic complexity 17 (threshold 15). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
baml_go.decodeGeneratedClass (cyclomatic 17) baml_language/sdks/go/baml_go/dynamic.go:850— baml_go.decodeGeneratedClass 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.
baml_go.resolveManifestArtifact (cyclomatic 17) baml_language/sdks/go/baml_go/runtime_artifact.go:262— baml_go.resolveManifestArtifact 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.
kpis.html.standing (cyclomatic 17) baml_language/tools/speedtest/src/speedtest/templates/kpis.html:99— kpis.html.standing has cyclomatic complexity 17 (threshold 15). Of this number, 11 points are the body's own statements and 6 belong to 3 function items inside it that branch. 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.
index.testNumberEdgeCases (cyclomatic 17) engine/generators/data/edge_cases/typescript/index.ts:170— index.testNumberEdgeCases has cyclomatic complexity 17 (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.
index.testNullableTypes (cyclomatic 17) engine/generators/data/optional_nullable/typescript/index.ts:38— index.testNullableTypes has cyclomatic complexity 17 (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.
Node.Node (cyclomatic 17) typescript/apps/fiddle-web-app/app/[project_id]/_components/Tree/Node.tsx:39— Node.Node has cyclomatic complexity 17 (threshold 15). Of this number, 9 points are the body's own statements and 8 belong to 5 function literals inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
simulator.simulateExecution (cyclomatic 17) typescript/packages/playground-common/src/sdk/runtime/simulator.ts:20— simulator.simulateExecution 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.
date-picker-input.DatePickerInput (cyclomatic 17) typescript/packages/ui/src/custom/date-picker-input.tsx:14— date-picker-input.DatePickerInput has cyclomatic complexity 17 (threshold 15). Most of this is not in the body itself: 3 of the 17 points are its own statements and the rest belongs to 2 function literals inside it that branch (lines 19, 63). 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.
page.LoginContent (cyclomatic 17) typescript2/app-beps/src/app/login/page.tsx:30— page.LoginContent has cyclomatic complexity 17 (threshold 15). Most of this is not in the body itself: 7 of the 17 points are its own statements and the rest belongs to 3 function items inside it that branch (handlePasskeySubmit, a function literal at line 40, handleGitHubLogin). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
version-analysis-status.VersionAnalysisStatus (cyclomatic 17) typescript2/app-beps/src/components/ai-assistant/version-analysis-status.tsx:23— version-analysis-status.VersionAnalysisStatus has cyclomatic complexity 17 (threshold 15). Of this number, 14 points are the body's own statements and 3 belong to 2 function literals inside it that branch. 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.
bep-export-dialog.BepExportDialog (cyclomatic 17) typescript2/app-beps/src/components/bep/bep-export-dialog.tsx:35— bep-export-dialog.BepExportDialog has cyclomatic complexity 17 (threshold 15). Of this number, 11 points are the body's own statements and 6 belong to one function literal inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
export-utils.generateAgentContext (cyclomatic 17) typescript2/app-beps/src/lib/export-utils.ts:883— export-utils.generateAgentContext has cyclomatic complexity 17 (threshold 15). Of this number, 10 points are the body's own statements and 7 belong to 6 function literals inside it that branch. 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.
generated-reference.GeneratedReferenceContent (cyclomatic 17) typescript2/app-developer-docs/components/generated-reference.tsx:461— generated-reference.GeneratedReferenceContent has cyclomatic complexity 17 (threshold 15). Of this number, 12 points are the body's own statements and 5 belong to one function literal inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
send-slack-report.captureDashboardOnce (cyclomatic 17) typescript2/app-product-metrics/src/jobs/send-slack-report.ts:204— send-slack-report.captureDashboardOnce has cyclomatic complexity 17 (threshold 15). Of this number, 13 points are the body's own statements and 4 belong to one function literal inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
types.buildGroups (cyclomatic 17) typescript2/app-stdlib-matrix/src/types.ts:350— types.buildGroups has cyclomatic complexity 17 (threshold 15). Of this number, 14 points are the body's own statements and 3 belong to 2 function items inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
app.Question (cyclomatic 17) typescript2/app-type-quiz/src/app.tsx:450— app.Question has cyclomatic complexity 17 (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.
page.FeedCard (cyclomatic 17) typescript2/app-website/app/atb/page.tsx:162— page.FeedCard has cyclomatic complexity 17 (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.
TenetsAccordion.TenetsAccordion (cyclomatic 17) typescript2/app-website/app/baml-intro/_components/TenetsAccordion.tsx:682— TenetsAccordion.TenetsAccordion has cyclomatic complexity 17 (threshold 15). Most of this is not in the body itself: 1 of the 17 points is its own statement and the rest belongs to 7 function literals inside it that branch (lines 730, 704, 690, …). 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.
rehype-preserve-code-props.rehypePreserveCodeProps (cyclomatic 17) typescript2/app-website/lib/mdx/rehype-preserve-code-props.ts:19— rehype-preserve-code-props.rehypePreserveCodeProps has cyclomatic complexity 17 (threshold 15). Most of this is not in the body itself: 3 of the 17 points are its own statements and the rest belongs to one function literal inside it that branches (line 24). The decisions are inside the literal, 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 literal's work into a named function or method at the enclosing scope and have the literal call it, then reduce whichever part then reads as the largest.
baml-editor.registerLensProvider (cyclomatic 17) typescript2/app-website/app/learn2/_editor/baml-editor.tsx:119— baml-editor.registerLensProvider has cyclomatic complexity 17 (threshold 15). Most of this is not in the body itself: 2 of the 17 points are its own statements and the rest belongs to 8 function literals inside it that branch (lines 125, 173, 259, …). 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.
page.EpisodePage (cyclomatic 17) REDACTED:201— page.EpisodePage has cyclomatic complexity 17 (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.
perspective-slider.GraphPanel (cyclomatic 17) REDACTED:731— perspective-slider.GraphPanel has cyclomatic complexity 17 (threshold 15). Most of this is not in the body itself: 4 of the 17 points are its own statements and the rest belongs to 3 function items inside it that branch (a function literal at line 941, a function literal at line 1006, onPanPointerMove). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
perspective-slider.CompactPerspectivePanel (cyclomatic 17) REDACTED:1087— perspective-slider.CompactPerspectivePanel has cyclomatic complexity 17 (threshold 15). Most of this is not in the body itself: 8 of the 17 points are its own statements and the rest belongs to 3 function items inside it that branch (onKeyDown, a function literal at line 1093, a function literal at line 1117). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
FormatArgs::run (cyclomatic 16) baml_language/crates/baml_cli/src/format.rs:51— FormatArgs::run 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.
ProgramIndex::index_objects (cyclomatic 16) baml_language/crates/baml_compiler2_rust/src/index.rs:75— ProgramIndex::index_objects 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.
TypeValue::try_cast (cyclomatic 16) engine/baml-lib/jsonish/src/deserializer/coercer/coerce_primitive.rs:47— TypeValue::try_cast 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.
RuntimeCompileArtifactSlot::measure (cyclomatic 16) baml_language/crates/bex_vm/src/compile_artifact.rs:106— RuntimeCompileArtifactSlot::measure has cyclomatic complexity 16 (threshold 15). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
MapDriver::drive (cyclomatic 16) baml_language/crates/bex_vm/src/package_baml/map.rs:81— MapDriver::drive 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.
PackageReflectImpl::_with_types (cyclomatic 16) baml_language/crates/bex_vm/src/package_reflect/reflect.rs:1274— PackageReflectImpl::_with_types 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.
CffiHandleTableEntry::handle_type (cyclomatic 16) baml_language/crates/bridge_ctypes/src/handle_table.rs:99— CffiHandleTableEntry::handle_type 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.
sys_auth::io_bridge::split_command (cyclomatic 16) baml_language/crates/sys_auth/src/io_bridge.rs:71— sys_auth::io_bridge::split_command 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.
WasmFunction::run_test_with_expr_events (cyclomatic 16) engine/baml-schema-wasm/src/runtime_wasm/mod.rs:2625— WasmFunction::run_test_with_expr_events 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.
TypeGo::zero_value (cyclomatic 16) engine/generators/languages/go/src/type.rs:125— TypeGo::zero_value 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. This is NOT this file's highest cyclomatic complexity: TypeGo::default_name_within_union (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.
runner._save (cyclomatic 16) baml_language/tools/speedtest/src/speedtest/runner.py:271— runner._save 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.
telemetry_resource_report._reference_metrics (cyclomatic 16) baml_language/scripts/telemetry_resource_report.py:163— telemetry_resource_report._reference_metrics 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.
baml_go.jsonLiteralTypeMatchesWire (cyclomatic 16) baml_language/sdks/go/baml_go/json.go:437— baml_go.jsonLiteralTypeMatchesWire has cyclomatic complexity 16 (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.
baml_go.encodeCallForDispatchWithTargetAndTypeArgs (cyclomatic 16) baml_language/sdks/go/baml_go/runtime.go:553— baml_go.encodeCallForDispatchWithTargetAndTypeArgs has cyclomatic complexity 16 (threshold 15). Of this number, 15 points are the body's own statements and 1 belongs to one function literal inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
BamlUnion2._bamlDecode (cyclomatic 16) baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:82— BamlUnion2._bamlDecode 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.
main.decode (cyclomatic 16) baml_language/tools/speedtest/workloads/programs/agent-loop-300/main.js:3— main.decode has cyclomatic complexity 16 (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.
elk-mermaid.layoutELKMermaid.edges (cyclomatic 16) typescript/packages/playground-common/src/features/graph/layout/node/algorithms/elk-mermaid.ts:623— elk-mermaid.layoutELKMermaid.edges has cyclomatic complexity 16 (threshold 15). Of this number, 12 points are the body's own statements and 4 belong to 3 function literals inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
render-text.HighlightedText (cyclomatic 16) typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/prompt-preview/render-text.tsx:32— render-text.HighlightedText has cyclomatic complexity 16 (threshold 15). Most of this is not in the body itself: 1 of the 16 points is its own statement and the rest belongs to 5 function literals inside it that branch (lines 117, 47, 106, …). 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.
prompt-preview-content.PromptPreviewContent (cyclomatic 16) typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/prompt-preview/prompt-preview-content.tsx:18— prompt-preview-content.PromptPreviewContent has cyclomatic complexity 16 (threshold 15). Of this number, 12 points are the body's own statements and 4 belong to one function literal inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
prompt-search-bar.PromptSearchBar (cyclomatic 16) typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/prompt-preview/prompt-search-bar.tsx:21— prompt-search-bar.PromptSearchBar has cyclomatic complexity 16 (threshold 15). Most of this is not in the body itself: 4 of the 16 points are its own statements and the rest belongs to 7 function items inside it that branch (a function literal at line 31, handleKeyDown, a function literal at line 51, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
route.POST (cyclomatic 16) REDACTED:95— route.POST 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.
decision-card.DecisionCard (cyclomatic 16) typescript2/app-beps/src/components/decisions/decision-card.tsx:57— decision-card.DecisionCard has cyclomatic complexity 16 (threshold 15). Of this number, 8 points are the body's own statements and 8 belong to 4 function items inside it that branch. 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.
docs-toc.DocsToc (cyclomatic 16) typescript2/app-developer-docs/components/docs-toc.tsx:12— docs-toc.DocsToc has cyclomatic complexity 16 (threshold 15). Most of this is not in the body itself: 5 of the 16 points are its own statements and the rest belongs to 5 function literals inside it that branch (lines 34, 70, 27, …). 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.
no-widen-then-assert.isBroadRecordType (cyclomatic 16) typescript2/app-developer-docs/tools/oxlint/anti-slop/rules/no-widen-then-assert.ts:52— no-widen-then-assert.isBroadRecordType has cyclomatic complexity 16 (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.
transcript.TurnBlock (cyclomatic 16) typescript2/app-website/app/atb/_components/transcript.tsx:252— transcript.TurnBlock has cyclomatic complexity 16 (threshold 15). Of this number, 15 points are the body's own statements and 1 belongs to one function literal inside it that branches. 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.
webview-media.WebviewMedia (cyclomatic 16) typescript2/app-website/lib/mdx/baml-block/baml-project-panel/playground-panel/prompt-preview/webview-media.tsx:16— webview-media.WebviewMedia has cyclomatic complexity 16 (threshold 15). Of this number, 8 points are the body's own statements and 8 belong to 2 function items inside it that branch. 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.
render-part.RenderPart (cyclomatic 16) typescript2/app-website/lib/mdx/baml-block/baml-project-panel/playground-panel/prompt-preview/render-part.tsx:12— render-part.RenderPart has cyclomatic complexity 16 (threshold 15). Most of this is not in the body itself: 6 of the 16 points are its own statements and the rest belongs to 3 function items inside it that branch (a function literal at line 16, a function literal at line 44, extractStringValues). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
rehype-highlight-code.rehypeHighlightCode (cyclomatic 16) typescript2/app-website/lib/mdx/rehype-highlight-code.ts:14— rehype-highlight-code.rehypeHighlightCode has cyclomatic complexity 16 (threshold 15). Most of this is not in the body itself: 1 of the 16 points is its own statement and the rest belongs to 4 function literals inside it that branch (lines 22, 14, 30, …). 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.
globe.Globe (cyclomatic 16) typescript2/app-website/components/magicui/globe.tsx:53— globe.Globe has cyclomatic complexity 16 (threshold 15). Most of this is not in the body itself: 1 of the 16 points is its own statement and the rest belongs to 9 function items inside it that branch (a function literal at line 77, updatePointerInteraction, updateMovement, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
index.searchSymbols (cyclomatic 16) typescript2/app-website/lib/baml-docs/index.ts:60— index.searchSymbols has cyclomatic complexity 16 (threshold 15). Of this number, 10 points are the body's own statements and 6 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.
baml-worker.onPlaygroundNotification (cyclomatic 16) typescript2/app-website/playground/baml-worker.ts:258— baml-worker.onPlaygroundNotification has cyclomatic complexity 16 (threshold 15). Of this number, 15 points are the body's own statements and 1 belongs to one function literal 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.
new-post.generatePost (cyclomatic 16) typescript2/app-website/scripts/new-post.ts:475— new-post.generatePost has cyclomatic complexity 16 (threshold 15). Of this number, 12 points are the body's own statements and 4 belong to 4 function literals inside it that branch. 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.
TelemetryView.TraceTab (cyclomatic 16) typescript2/pkg-playground/src/telemetry/TelemetryView.tsx:1851— TelemetryView.TraceTab has cyclomatic complexity 16 (threshold 15). Most of this is not in the body itself: 7 of the 16 points are its own statements and the rest belongs to 3 function literals inside it that branch (lines 1864, 1945, 1931). 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.
WebSocketRuntimePort.postMessage (cyclomatic 16) typescript2/pkg-playground/src/ports/WebSocketRuntimePort.ts:149— WebSocketRuntimePort.postMessage 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. This is NOT this file's highest cyclomatic complexity: WebSocketRuntimePort.toServer (cyclomatic 32) 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 method is counted neither in this dimension's figures nor in its score.
D10 · Test Quality· Test project verifies nothing · ×1
Test project verifies nothing: typescript/packages/codemirror-lang-baml typescript/packages/codemirror-lang-baml/test/test.cjs:21— No conventional assertion call was detected in 2 of 2 tests in `typescript/packages/codemirror-lang-baml` — the project as a whole, not one method. Two things look like this: verification that happens indirectly (an approval/verifier harness or BDD step methods), or a suite that genuinely checks nothing. If it is the latter, this project passes unconditionally and cannot fail.
Repeated repair: baml_language/crates/bcs_api/src/auth.rs baml_language/crates/bcs_api/src/auth.rs:87— baml_language/crates/bcs_api/src/auth.rs changed 5 times in last 90 days and 3 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 6 (its worst body is Endpoint::parse at line 87), 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: default baml_language telemetry to production BCS (#5193)”; “fix(auth): share Boundary login through a file cache (#5158)”; “fix(cli): preserve cloud query errors and incomplete results (#5153)”. 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-29..2026-10-27, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-29 02:53:01 +00:00' --until='2026-10-27 02:53:01 +00:00' --full-history --no-merges -- baml_language/crates/bcs_api/src/auth.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.
Dead code: ReadHandleFields baml_language/sdks/csharp/bridge_csharp/src/Generated/V1/BamlGeneratedCodec.cs:1700— Method ReadHandleFields — Roslyn's SymbolFinder walked every project the solution loads, including Baml.Bridge, and found no reference to it. That walk cannot see three kinds of caller, so check them before removing it: code outside the solution file (a solution is a curated list, not the repository — a sibling test tree with its own .sln is invisible), a call resolved by reflection or dependency injection from the symbol's name, and any project the workspace could not load. This is 'no caller found by this walk', not a verdict that the symbol is unused.
ReplArgs::run (cognitive 317) engine/baml-runtime/src/cli/repl.rs:848— ReplArgs::run has cognitive complexity 317 (threshold 15). Drivers by points: if/else 68 (237 pts), loops 11 (33 pts), match/switch 7 (25 pts), boolean chains 22 (nesting depth added 209). 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.
BamlAsyncVmRuntime::call_function (cognitive 186) engine/baml-runtime/src/async_vm_runtime.rs:160— BamlAsyncVmRuntime::call_function has cognitive complexity 186 (threshold 15). Drivers by points: if/else 24 (103 pts), match/switch 20 (65 pts), loops 5 (17 pts), boolean chains 1 (nesting depth added 136). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ArgCoercer::coerce_arg (cognitive 180) engine/baml-lib/baml-core/src/ir/ir_helpers/to_baml_arg.rs:135— ArgCoercer::coerce_arg has cognitive complexity 180 (threshold 15). Drivers by points: if/else 35 (112 pts), match/switch 15 (35 pts), loops 9 (30 pts), boolean chains 3 (nesting depth added 118). 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.
baml-lsp-worker.onmessage (cognitive 162) typescript2/app-promptfiddle/src/playground/baml-lsp-worker.ts:567— baml-lsp-worker.onmessage has cognitive complexity 162 (threshold 15). Drivers by points: if/else 38 (75 pts), ternaries 17 (49 pts), error handling 16 (32 pts), boolean chains 5, match/switch 1 (nesting depth added 85). Of this number, 131 points are the body's own statements and 31 belong to 8 function literals 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.
PropertyHandler::ensure_http_config (cognitive 147) engine/baml-lib/llm-client/src/clients/helpers.rs:511— PropertyHandler::ensure_http_config has cognitive complexity 147 (threshold 15). Drivers by points: if/else 33 (99 pts), match/switch 8 (36 pts), loops 2 (7 pts), boolean chains 5 (nesting depth added 99). 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.
analyze_ffi.analyze (cognitive 139) scripts/ffi-debug/analyze_ffi.py:136— analyze_ffi.analyze has cognitive complexity 139 (threshold 15). Drivers by points: if/else 50 (79 pts), loops 26 (52 pts), ternaries 3 (6 pts), boolean chains 2 (nesting depth added 58). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
baml-worker.onmessage (cognitive 135) typescript2/app-website/playground/baml-worker.ts:394— baml-worker.onmessage has cognitive complexity 135 (threshold 15). Drivers by points: if/else 24 (46 pts), ternaries 15 (44 pts), error handling 15 (30 pts), boolean chains 8, loops 3 (6 pts), match/switch 1 (nesting depth added 69). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Program::validate (cognitive 132) baml_language/crates/bex_vm_types/src/types.rs:204— Program::validate has cognitive complexity 132 (threshold 15). Drivers by points: if/else 33 (81 pts), loops 17 (34 pts), match/switch 5 (13 pts), boolean chains 4 (nesting depth added 73). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
baml_go.validateBAMLType (cognitive 130) baml_language/sdks/go/baml_go/value.go:474— baml_go.validateBAMLType has cognitive complexity 130 (threshold 15). Drivers by points: if/else 49 (107 pts), boolean chains 15, loops 3 (5 pts), match/switch 2 (3 pts) (nesting depth added 61). Of this number, 127 points are the body's own statements and 3 belong to one function literal inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
compare._render_md (cognitive 128) baml_language/tools/speedtest/src/speedtest/compare.py:152— compare._render_md has cognitive complexity 128 (threshold 15). Drivers by points: ternaries 16 (55 pts), if/else 21 (48 pts), boolean chains 13, loops 7 (12 pts) (nesting depth added 71). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
OptimizeArgs::run (cognitive 115) engine/baml-runtime/src/cli/optimize.rs:167— OptimizeArgs::run has cognitive complexity 115 (threshold 15). Drivers by points: if/else 48 (91 pts), loops 4 (12 pts), match/switch 4 (8 pts), boolean chains 4 (nesting depth added 55). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
analyze_ffi.generate_plot (cognitive 111) scripts/ffi-debug/analyze_ffi.py:515— analyze_ffi.generate_plot has cognitive complexity 111 (threshold 15). Drivers by points: if/else 37 (79 pts), ternaries 16 (22 pts), loops 5 (8 pts), boolean chains 1, error handling 1 (nesting depth added 51). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
App.App (cognitive 101) typescript2/app-speedtest/src/App.tsx:63— App.App has cognitive complexity 101 (threshold 15). Drivers by points: if/else 21 (39 pts), boolean chains 35, ternaries 15 (17 pts), loops 6 (9 pts), error handling 1 (nesting depth added 23). Of this number, 62 points are the body's own statements and 39 belong to 21 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.
MonacoEditor.MonacoEditor (cognitive 99) typescript2/pkg-editor/src/MonacoEditor.tsx:300— MonacoEditor.MonacoEditor has cognitive complexity 99 (threshold 15). Drivers by points: if/else 45 (63 pts), error handling 6 (13 pts), boolean chains 10, loops 8 (9 pts), ternaries 3, match/switch 1 (nesting depth added 26). Most of this is not in the body itself: 2 of the 99 points are its own statements and the rest belongs to 18 function literals inside it that branch (lines 354, 1083, 1351, …). 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.
compare.cmd_compare (cognitive 94) baml_language/tools/speedtest/src/speedtest/compare.py:18— compare.cmd_compare has cognitive complexity 94 (threshold 15). Drivers by points: if/else 20 (40 pts), ternaries 14 (38 pts), boolean chains 11, loops 4 (5 pts) (nesting depth added 45). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
comment-sidebar.CommentSidebar (cognitive 93) typescript2/app-beps/src/components/comments/comment-sidebar.tsx:177— comment-sidebar.CommentSidebar has cognitive complexity 93 (threshold 15). Drivers by points: if/else 35 (42 pts), boolean chains 38, loops 4 (5 pts), ternaries 5, error handling 3 (nesting depth added 8). Most of this is not in the body itself: 10 of the 93 points are its own statements and the rest belongs to 28 function items inside it that branch (a function literal at line 332, a function literal at line 541, a function literal at line 839, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
webview-media.WebviewMedia (cognitive 92) typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/prompt-preview/webview-media.tsx:138— webview-media.WebviewMedia has cognitive complexity 92 (threshold 15). Drivers by points: boolean chains 41, if/else 30 (39 pts), error handling 2 (5 pts), ternaries 3 (4 pts), match/switch 2, loops 1 (nesting depth added 13). Of this number, 37 points are the body's own statements and 55 belong to 15 function items inside it that branch. 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.
TirTypeError::render (cognitive 84) baml_language/crates/baml_compiler2_hir_ty/src/diagnostics.rs:1226— TirTypeError::render has cognitive complexity 84 (threshold 15). Drivers by points: if/else 43 (64 pts), match/switch 11 (20 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.
bep-import-dialog.BepImportDialog (cognitive 82) typescript2/app-beps/src/components/bep/bep-import-dialog.tsx:59— bep-import-dialog.BepImportDialog has cognitive complexity 82 (threshold 15). Drivers by points: if/else 16 (30 pts), boolean chains 25, ternaries 14 (23 pts), error handling 2 (3 pts), loops 1 (nesting depth added 24). Of this number, 25 points are the body's own statements and 57 belong to 9 function literals 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.
ExecutionPanel.ExecutionPanel (cognitive 82) typescript2/pkg-playground/src/ExecutionPanel.tsx:494— ExecutionPanel.ExecutionPanel has cognitive complexity 82 (threshold 15). Drivers by points: if/else 144 (202 pts), ternaries 64 (177 pts), boolean chains 141, loops 16 (21 pts), error handling 7 (9 pts), match/switch 2 (3 pts) (nesting depth added 179). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: one other method here (ExecutionPanel.ExecutionPanel::handleCursorContext) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
walkLibFile (cognitive 81) tools/stdlib-matrix/extractors/ts-surface.mjs:337— walkLibFile has cognitive complexity 81 (threshold 15). Drivers by points: if/else 15 (47 pts), loops 5 (15 pts), ternaries 6 (10 pts), boolean chains 7, other 2 (nesting depth added 46). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
pdf-viewer.PdfViewer (cognitive 80) typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/prompt-preview/pdf-viewer.tsx:15— pdf-viewer.PdfViewer has cognitive complexity 80 (threshold 15). Drivers by points: if/else 31 (37 pts), ternaries 7 (21 pts), boolean chains 18, error handling 2 (3 pts), loops 1 (nesting depth added 21). Of this number, 24 points are the body's own statements and 56 belong to 21 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.
bep-route-shell.BepRouteShell (cognitive 79) typescript2/app-beps/src/components/bep/bep-route-shell.tsx:74— bep-route-shell.BepRouteShell has cognitive complexity 79 (threshold 15). Drivers by points: if/else 69 (93 pts), boolean chains 58, ternaries 38 (48 pts), loops 3, error handling 2 (nesting depth added 34). 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. This shape REPEATS in the file: one other method here (bep-route-shell.BepRouteShell::handleConfirmSubmit) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
BamlUnion8._bamlDecode (cognitive 75) baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:817— BamlUnion8._bamlDecode has cognitive complexity 75 (threshold 15). Drivers by points: if/else 35 (59 pts), boolean chains 16 (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.
proto._set_inbound_value (cognitive 71) baml_language/sdks/python/src/baml_bridge/proto.py:272— proto._set_inbound_value has cognitive complexity 71 (threshold 15). Drivers by points: if/else 28 (39 pts), loops 7 (14 pts), error handling 2 (7 pts), ternaries 2 (6 pts), boolean chains 5 (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.
proto._fill_wire_ty (cognitive 68) baml_language/sdks/python/src/baml_bridge/proto.py:652— proto._fill_wire_ty has cognitive complexity 68 (threshold 15). Drivers by points: if/else 25 (47 pts), loops 3 (9 pts), ternaries 3 (9 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.
btel_record_smoke.measure (cognitive 68) baml_language/tools/btel_record_smoke.py:33— btel_record_smoke.measure has cognitive complexity 68 (threshold 15). Drivers by points: if/else 9 (36 pts), loops 9 (21 pts), boolean chains 5, ternaries 1 (5 pts), error handling 1 (nesting depth added 43). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ProtoWriter.encodeInboundValue (cognitive 67) baml_language/sdks/java/baml_bridge/src/main/java/baml_bridge/internal/ProtoWriter.java:239— ProtoWriter.encodeInboundValue has cognitive complexity 67 (threshold 15). Drivers by points: if/else 34 (41 pts), boolean chains 13, ternaries 6 (10 pts), error handling 1 (2 pts), loops 1 (nesting depth added 12). 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.
parser.parse (cognitive 67) tools/bctl_src/oncall/parser.py:72— parser.parse has cognitive complexity 67 (threshold 15). Drivers by points: if/else 25 (49 pts), loops 6 (10 pts), boolean chains 5, error handling 2 (3 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.
BamlUnion7._bamlDecode (cognitive 66) baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:667— BamlUnion7._bamlDecode has cognitive complexity 66 (threshold 15). Drivers by points: if/else 31 (52 pts), boolean chains 14 (nesting depth added 21). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
baml_go.decodeDynamicValue (cognitive 64) baml_language/sdks/go/baml_go/dynamic.go:619— baml_go.decodeDynamicValue has cognitive complexity 64 (threshold 15). Drivers by points: if/else 21 (49 pts), match/switch 4 (7 pts), loops 3 (6 pts), boolean chains 2 (nesting depth added 34). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
run-store-client.createRunStoreClient (cognitive 63) typescript2/pkg-playground/src/run-store-client.ts:223— run-store-client.createRunStoreClient has cognitive complexity 63 (threshold 15). Drivers by points: if/else 20 (45 pts), loops 5 (9 pts), boolean chains 8, match/switch 1 (nesting depth added 29). Most of this is not in the body itself: 2 of the 63 points are its own statements and the rest belongs to 2 function items inside it that branch (a function literal at line 244, rejectPending). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
useParticleEngine.useParticleEngine (cognitive 62) typescript2/app-website/components/HistoryOfLanguages/useParticleEngine.ts:44— useParticleEngine.useParticleEngine has cognitive complexity 62 (threshold 15). Drivers by points: if/else 28 (51 pts), boolean chains 10, loops 1 (nesting depth added 23). None of this is in the body itself: all 62 points belong to 4 function literals inside it that branch (lines 89, 199, 236, …). 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.
Matrix::specialize (cognitive 60) baml_language/crates/baml_compiler2_hir_ty/src/exhaustiveness.rs:976— Matrix::specialize has cognitive complexity 60 (threshold 15). Drivers by points: if/else 6 (22 pts), loops 6 (21 pts), match/switch 5 (15 pts), boolean chains 2 (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.
DetailPanel.LLMNodeContent (cognitive 60) typescript/packages/playground-common/src/features/detail-panel/components/DetailPanel.tsx:206— DetailPanel.LLMNodeContent has cognitive complexity 60 (threshold 15). Drivers by points: boolean chains 28, if/else 19 (21 pts), ternaries 7 (10 pts), match/switch 1 (nesting depth added 5). Of this number, 26 points are the body's own statements and 34 belong to 13 function items inside it that branch. 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.
SmartEdge.mergePoints (cognitive 60) typescript/packages/playground-common/src/graph-primitives/edges/EdgeController/smart-edge.ts:271— SmartEdge.mergePoints has cognitive complexity 60 (threshold 15). Drivers by points: if/else 18 (36 pts), ternaries 8 (20 pts), boolean chains 4 (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.
ClassTy::coerce (cognitive 58) baml_language/crates/bex_sap/src/deserializer/coercer/coerce_class.rs:105— ClassTy::coerce has cognitive complexity 58 (threshold 15). Drivers by points: if/else 16 (31 pts), match/switch 6 (15 pts), loops 3 (9 pts), boolean chains 3 (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.
baml_go.encodeAny (cognitive 58) baml_language/sdks/go/baml_go/dynamic.go:305— baml_go.encodeAny has cognitive complexity 58 (threshold 15). Drivers by points: if/else 24 (49 pts), loops 3 (7 pts), boolean chains 1, match/switch 1 (nesting depth added 29). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
StreamWriter::publish_if_due (cognitive 57) baml_language/crates/bex_prof_store/src/prof/backend/writer.rs:295— StreamWriter::publish_if_due has cognitive complexity 57 (threshold 15). Drivers by points: if/else 16 (28 pts), loops 6 (12 pts), match/switch 5 (10 pts), boolean chains 7 (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.
BamlUnion6._bamlDecode (cognitive 57) baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:528— BamlUnion6._bamlDecode has cognitive complexity 57 (threshold 15). Drivers by points: if/else 27 (45 pts), boolean chains 12 (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.
baml_go.decodeReflected (cognitive 56) baml_language/sdks/go/baml_go/dynamic.go:457— baml_go.decodeReflected has cognitive complexity 56 (threshold 15). Drivers by points: if/else 33 (54 pts), boolean chains 1, match/switch 1 (nesting depth added 21). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
page.loadExamples (cognitive 56) engine/baml-runtime/src/control_flow/mermaid-sandbox/app/page.tsx:46— page.loadExamples has cognitive complexity 56 (threshold 15). Drivers by points: if/else 13 (35 pts), loops 3 (7 pts), boolean chains 6, error handling 1 (4 pts), ternaries 1 (4 pts) (nesting depth added 32). Of this number, 50 points are the body's own statements and 6 belong to 3 function literals 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.
DetailPanel.StandardNodeContent (cognitive 56) typescript/packages/playground-common/src/features/detail-panel/components/DetailPanel.tsx:540— DetailPanel.StandardNodeContent has cognitive complexity 56 (threshold 15). Drivers by points: boolean chains 27, if/else 19 (21 pts), ternaries 5 (7 pts), match/switch 1 (nesting depth added 4). Of this number, 22 points are the body's own statements and 34 belong to 14 function items inside it that branch. 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.
ai-assistant-panel.AIAssistantPanel (cognitive 56) typescript2/app-beps/src/components/ai-assistant/ai-assistant-panel.tsx:54— ai-assistant-panel.AIAssistantPanel has cognitive complexity 56 (threshold 15). Drivers by points: if/else 18 (30 pts), boolean chains 14, ternaries 9 (10 pts), error handling 1, loops 1 (nesting depth added 13). Most of this is not in the body itself: 12 of the 56 points are its own statements and the rest belongs to 11 function items inside it that branch (a function literal at line 93, handleQuickAction, a function literal at line 201, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
TelemetryView.OverviewTab (cognitive 56) typescript2/pkg-playground/src/telemetry/TelemetryView.tsx:915— TelemetryView.OverviewTab has cognitive complexity 56 (threshold 15). Drivers by points: ternaries 22 (40 pts), boolean chains 16 (nesting depth added 18). Of this number, 51 points are the body's own statements and 5 belong to 6 function literals 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.
sys_ops::output_format::walk_ty (cognitive 55) baml_language/crates/sys_ops/src/output_format.rs:1521— sys_ops::output_format::walk_ty has cognitive complexity 55 (threshold 15). Drivers by points: if/else 18 (43 pts), loops 4 (10 pts), boolean chains 1, match/switch 1 (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.
audit-site.main (cognitive 54) typescript2/app-developer-docs/scripts/audit-site.py:77— audit-site.main has cognitive complexity 54 (threshold 15). Drivers by points: if/else 15 (34 pts), loops 6 (9 pts), boolean chains 7, ternaries 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.
baml_go.validateJSONSelectedPayload (cognitive 52) baml_language/sdks/go/baml_go/json.go:253— baml_go.validateJSONSelectedPayload has cognitive complexity 52 (threshold 15). Drivers by points: if/else 20 (40 pts), loops 3 (6 pts), boolean chains 5, 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.
TypeExprKind::fmt (cognitive 51) baml_language/crates/baml_compiler2_ast/src/ast.rs:265— TypeExprKind::fmt has cognitive complexity 51 (threshold 15). Drivers by points: if/else 18 (39 pts), loops 4 (10 pts), boolean chains 1, match/switch 1 (nesting depth added 27). Of this number, 49 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.
TypeRefDisplay::fmt (cognitive 51) baml_language/crates/baml_compiler2_hir/src/type_ref.rs:168— TypeRefDisplay::fmt has cognitive complexity 51 (threshold 15). Drivers by points: if/else 18 (39 pts), loops 4 (10 pts), boolean chains 1, match/switch 1 (nesting depth added 27). Of this number, 49 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.
Diagnostic::fmt (cognitive 51) baml_language/crates/bcs_api/src/diagnostics.rs:301— Diagnostic::fmt has cognitive complexity 51 (threshold 15). Drivers by points: if/else 18 (31 pts), match/switch 8 (16 pts), loops 1 (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.
GraphView.GraphViewInner (cognitive 51) typescript2/pkg-playground/src/graph/GraphView.tsx:141— GraphView.GraphViewInner has cognitive complexity 51 (threshold 15). Drivers by points: ternaries 20 (22 pts), if/else 17 (18 pts), boolean chains 7, loops 4 (nesting depth added 3). Most of this is not in the body itself: 11 of the 51 points are its own statements and the rest belongs to 14 function literals inside it that branch (lines 283, 483, 397, …). 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.
run.main (cognitive 50) baml_language/tools/gc_policy/run.py:14— run.main has cognitive complexity 50 (threshold 15). Drivers by points: if/else 13 (29 pts), loops 5 (8 pts), ternaries 3 (7 pts), boolean chains 3, error handling 1 (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.
Encode.swift.encodeCallArgs (cognitive 50) baml_language/sdks/swift/Sources/BamlBridge/Encode.swift:344— Encode.swift.encodeCallArgs has cognitive complexity 50 (threshold 15). Drivers by points: if/else 13 (31 pts), loops 4 (11 pts), error handling 2 (4 pts), boolean chains 2, match/switch 1 (2 pts) (nesting depth added 28). Of this number, 34 points are the body's own statements and 16 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.
ApiKeysDialog.ApiKeysDialog (cognitive 50) typescript2/pkg-playground/src/components/ApiKeysDialog.tsx:62— ApiKeysDialog.ApiKeysDialog has cognitive complexity 50 (threshold 15). Drivers by points: boolean chains 19, if/else 8 (13 pts), ternaries 11 (13 pts), loops 5 (nesting depth added 7). Most of this is not in the body itself: 8 of the 50 points are its own statements and the rest belongs to 10 function items inside it that branch (renderRow, handleImport, a function literal at line 92, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
WitnessPat::render (cognitive 49) baml_language/crates/baml_compiler2_hir_ty/src/exhaustiveness.rs:671— WitnessPat::render has cognitive complexity 49 (threshold 15). Drivers by points: if/else 10 (34 pts), loops 4 (10 pts), match/switch 3 (5 pts) (nesting depth added 32). 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.
BamlUnion5._bamlDecode (cognitive 48) baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:400— BamlUnion5._bamlDecode has cognitive complexity 48 (threshold 15). Drivers by points: if/else 23 (38 pts), boolean chains 10 (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.
Workbench.Workbench (cognitive 48) typescript2/app-website/app/bamlcode/_components/Workbench.tsx:24— Workbench.Workbench has cognitive complexity 48 (threshold 15). Drivers by points: ternaries 19 (36 pts), if/else 6 (7 pts), boolean chains 4, loops 1 (nesting depth added 18). Most of this is not in the body itself: 15 of the 48 points are its own statements and the rest belongs to 4 function literals inside it that branch (lines 228, 59, 108, …). 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.
baml-editor.BamlEditor (cognitive 48) typescript2/app-website/app/learn2/_editor/baml-editor.tsx:359— baml-editor.BamlEditor has cognitive complexity 48 (threshold 15). Drivers by points: ternaries 15 (28 pts), if/else 10 (11 pts), boolean chains 7, error handling 1, loops 1 (nesting depth added 14). Of this number, 19 points are the body's own statements and 29 belong to 8 function literals 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.
args-form-model.reconcileValue (cognitive 48) typescript2/pkg-playground/src/args-form-model.ts:403— args-form-model.reconcileValue has cognitive complexity 48 (threshold 15). Drivers by points: if/else 12 (28 pts), ternaries 6 (13 pts), boolean chains 3, loops 1 (3 pts), match/switch 1 (nesting depth added 25). Of this number, 46 points are the body's own statements and 2 belong to one function literal inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
http.createRequestHandler (cognitive 47) typescript2/app-product-metrics/src/http.ts:86— http.createRequestHandler has cognitive complexity 47 (threshold 15). Drivers by points: if/else 13 (16 pts), error handling 8 (15 pts), boolean chains 10, ternaries 2 (6 pts) (nesting depth added 14). None of this is in the body itself: all 47 points belong to one function literal inside it that branches (line 94). The decisions are inside the literal, 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 literal's work into a named function or method at the enclosing scope and have the literal call it, then reduce whichever part then reads as the largest.
loadRuns (cognitive 47) typescript2/app-speedtest/api-server.mjs:23— loadRuns has cognitive complexity 47 (threshold 15). Drivers by points: if/else 10 (31 pts), error handling 2 (7 pts), loops 3 (7 pts), boolean chains 1, other 1 (nesting depth added 30). Of this number, 46 points are the body's own statements and 1 belongs to one function literal inside it that branches. 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.
OutputFormat::call (cognitive 46) engine/baml-lib/jinja-runtime/src/output_format/mod.rs:42— OutputFormat::call has cognitive complexity 46 (threshold 15). Drivers by points: match/switch 12 (26 pts), if/else 20 (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.
Processor::process_available (cognitive 45) baml_language/crates/btel_processor/src/lib.rs:571— Processor::process_available has cognitive complexity 45 (threshold 15). Drivers by points: if/else 14 (30 pts), loops 2 (9 pts), match/switch 1 (5 pts), boolean chains 1 (nesting depth added 27). 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.
BacktickStringLiteral::flat_parts (cognitive 44) baml_language/crates/baml_compiler_syntax/src/ast.rs:1008— BacktickStringLiteral::flat_parts has cognitive complexity 44 (threshold 15). Drivers by points: if/else 12 (27 pts), match/switch 4 (8 pts), loops 4 (6 pts), boolean chains 3 (nesting depth added 21). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Blob::logical_bytes_approx_v1 (cognitive 44) baml_language/crates/btel_snapshot/src/logical_bytes.rs:59— Blob::logical_bytes_approx_v1 has cognitive complexity 44 (threshold 15). Drivers by points: match/switch 8 (18 pts), loops 5 (14 pts), if/else 5 (9 pts), boolean chains 3 (nesting depth added 23). Of this number, 38 points are the body's own statements and 6 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.
baml_go.validateBAMLTypeDefinition (cognitive 44) baml_language/sdks/go/baml_go/value.go:284— baml_go.validateBAMLTypeDefinition has cognitive complexity 44 (threshold 15). Drivers by points: if/else 13 (30 pts), loops 6 (9 pts), boolean chains 5 (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.
verify.verifyGeneratedRelease (cognitive 44) typescript2/app-developer-docs/lib/generated-content/verify.ts:19— verify.verifyGeneratedRelease has cognitive complexity 44 (threshold 15). Drivers by points: if/else 11 (21 pts), ternaries 5 (11 pts), loops 4 (7 pts), boolean chains 5 (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.
CapturedValueCard.CapturedValueCard (cognitive 44) typescript2/pkg-playground/src/CapturedValueCard.tsx:95— CapturedValueCard.CapturedValueCard has cognitive complexity 44 (threshold 15). Drivers by points: ternaries 22 (42 pts), boolean chains 2 (nesting depth added 20). Of this number, 37 points are the body's own statements and 7 belong to one function literal inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
baml_log::logger::log_event_internal (cognitive 43) engine/baml-lib/baml-log/src/logger.rs:767— baml_log::logger::log_event_internal has cognitive complexity 43 (threshold 15). Drivers by points: if/else 17 (31 pts), match/switch 3 (8 pts), loops 1 (4 pts) (nesting depth added 22). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
RubyToJson::serialize_baml (cognitive 43) engine/language_client_ruby/ext/ruby_ffi/src/ruby_to_json.rs:59— RubyToJson::serialize_baml has cognitive complexity 43 (threshold 15). Drivers by points: if/else 8 (16 pts), match/switch 5 (15 pts), loops 3 (9 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.
baml_go.collectOutboundHandles (cognitive 43) baml_language/sdks/go/baml_go/media.go:98— baml_go.collectOutboundHandles has cognitive complexity 43 (threshold 15). Drivers by points: if/else 9 (30 pts), loops 3 (9 pts), boolean chains 2, match/switch 1 (2 pts) (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.
index.testKitchenSink (cognitive 43) engine/generators/data/mixed_complex_types/typescript/index.ts:3— index.testKitchenSink has cognitive complexity 43 (threshold 15). Drivers by points: if/else 29, boolean chains 14. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
IngressScheduler::admit_message_with_policy (cognitive 42) baml_language/crates/baml_lsp_server/src/lsp_ingress.rs:736— IngressScheduler::admit_message_with_policy has cognitive complexity 42 (threshold 15). Drivers by points: if/else 15 (29 pts), match/switch 5 (9 pts), boolean chains 4 (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.
ExecutionReader::load (cognitive 42) baml_language/crates/bex_prof_store/src/prof/backend/reader.rs:680— ExecutionReader::load has cognitive complexity 42 (threshold 15). Drivers by points: if/else 14 (25 pts), match/switch 3 (7 pts), boolean chains 5, loops 2 (5 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.
pkg.runHostCallable (cognitive 42) REDACTED:196— pkg.runHostCallable has cognitive complexity 42 (threshold 15). Drivers by points: if/else 23 (37 pts), boolean chains 2, loops 2, match/switch 1 (nesting depth added 14). Of this number, 41 points are the body's own statements and 1 belongs to one function literal inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
serde.convertFieldTypeToGoType (cognitive 42) engine/language_client_go/baml_go/serde/decode.go:328— serde.convertFieldTypeToGoType has cognitive complexity 42 (threshold 15). Drivers by points: if/else 29 (40 pts), match/switch 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.
baml_compiler_parser::parser::parse_impl (cognitive 41) baml_language/crates/baml_compiler_parser/src/parser.rs:8813— baml_compiler_parser::parser::parse_impl has cognitive complexity 41 (threshold 15). Drivers by points: if/else 27 (33 pts), boolean chains 6, loops 2 (nesting depth added 6). 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.
runner.cmd_run (cognitive 41) baml_language/tools/speedtest/src/speedtest/runner.py:171— runner.cmd_run has cognitive complexity 41 (threshold 15). Drivers by points: if/else 17 (26 pts), boolean chains 8, loops 5 (6 pts), ternaries 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.
Builder.build_target (cognitive 41) engine/language_client_cffi/build.py:245— Builder.build_target has cognitive complexity 41 (threshold 15). Drivers by points: if/else 15 (26 pts), error handling 3 (5 pts), ternaries 3 (4 pts), boolean chains 3, 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.
baml_go.findOrDownloadLibrary (cognitive 41) engine/language_client_go/baml_go/lib_common.go:251— baml_go.findOrDownloadLibrary has cognitive complexity 41 (threshold 15). Drivers by points: if/else 17 (31 pts), loops 3 (8 pts), match/switch 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.
MetadataBadges.extractMetadata (cognitive 41) typescript2/pkg-playground/src/components/MetadataBadges.tsx:15— MetadataBadges.extractMetadata has cognitive complexity 41 (threshold 15). Drivers by points: if/else 10 (27 pts), boolean chains 10, error handling 1 (3 pts), loops 1 (nesting depth added 19). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
walkNodeModuleFile::visitModuleBody (cognitive 41) tools/stdlib-matrix/extractors/ts-surface.mjs:423— walkNodeModuleFile::visitModuleBody has cognitive complexity 41 (threshold 15). Drivers by points: if/else 10 (21 pts), loops 5 (16 pts), boolean chains 3, other 1 (nesting depth added 22). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Hir2Diagnostic::to_diagnostic (cognitive 40) baml_language/crates/baml_compiler2_hir/src/diagnostic.rs:304— Hir2Diagnostic::to_diagnostic has cognitive complexity 40 (threshold 15). Drivers by points: loops 8 (18 pts), if/else 9 (15 pts), match/switch 3 (5 pts), boolean chains 2 (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.
TriviaInfo::classify_trivia (cognitive 40) baml_language/crates/baml_fmt/src/trivia_classifier.rs:30— TriviaInfo::classify_trivia has cognitive complexity 40 (threshold 15). Drivers by points: if/else 11 (23 pts), loops 5 (8 pts), match/switch 3 (8 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.
baml_release_platforms.load_wrapper_targets (cognitive 40) scripts/baml_release_platforms.py:72— baml_release_platforms.load_wrapper_targets has cognitive complexity 40 (threshold 15). Drivers by points: if/else 18 (33 pts), boolean chains 3, ternaries 1 (2 pts), error handling 1, 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.
analyze_ffi.parse_log (cognitive 40) scripts/ffi-debug/analyze_ffi.py:49— analyze_ffi.parse_log has cognitive complexity 40 (threshold 15). Drivers by points: ternaries 8 (24 pts), loops 7 (13 pts), if/else 2 (3 pts) (nesting depth added 23). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
baml_go.releaseOutboundOpaqueHostValues (cognitive 40) baml_language/sdks/go/baml_go/media.go:149— baml_go.releaseOutboundOpaqueHostValues has cognitive complexity 40 (threshold 15). Drivers by points: if/else 8 (27 pts), loops 4 (10 pts), match/switch 1 (2 pts), boolean chains 1 (nesting depth added 26). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
DebugPanel.buildNodesByFile (cognitive 40) REDACTED:53— DebugPanel.buildNodesByFile has cognitive complexity 40 (threshold 15). Drivers by points: if/else 11 (21 pts), loops 6 (11 pts), boolean chains 5, ternaries 1 (3 pts) (nesting depth added 17). Of this number, 31 points are the body's own statements and 9 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.
BamlUnion4._bamlDecode (cognitive 39) baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:283— BamlUnion4._bamlDecode has cognitive complexity 39 (threshold 15). Drivers by points: if/else 19 (31 pts), boolean chains 8 (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.
WasmHost::call_registered_callable_with_context (cognitive 38) baml_language/crates/sys_wasm/src/host_value.rs:644— WasmHost::call_registered_callable_with_context has cognitive complexity 38 (threshold 15). Drivers by points: if/else 13 (28 pts), match/switch 5 (9 pts), boolean chains 1 (nesting depth added 19). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
generators_python::watchers::build_notification_collectors (cognitive 38) engine/generators/languages/python/src/watchers.rs:143— generators_python::watchers::build_notification_collectors has cognitive complexity 38 (threshold 15). Drivers by points: if/else 12 (29 pts), loops 4 (5 pts), match/switch 1 (3 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.
telemetry_resources.monitor (cognitive 38) baml_language/scripts/telemetry_resources.py:240— telemetry_resources.monitor has cognitive complexity 38 (threshold 15). Drivers by points: if/else 8 (22 pts), loops 4 (7 pts), error handling 1 (4 pts), ternaries 1 (3 pts), boolean chains 2 (nesting depth added 22). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Builder.build_all (cognitive 38) engine/language_client_cffi/build.py:408— Builder.build_all has cognitive complexity 38 (threshold 15). Drivers by points: if/else 15 (23 pts), ternaries 2 (4 pts), error handling 1 (3 pts), loops 2 (3 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.
BAMLSDK.parseWatchValue (cognitive 38) typescript/packages/playground-common/src/sdk/sdk.ts:1036— BAMLSDK.parseWatchValue has cognitive complexity 38 (threshold 15). Drivers by points: ternaries 8 (24 pts), if/else 4 (8 pts), boolean chains 3, match/switch 1 (2 pts), error handling 1 (nesting depth added 21). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
function-item.FunctionItem (cognitive 38) typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/side-bar/function-item.tsx:24— function-item.FunctionItem has cognitive complexity 38 (threshold 15). Drivers by points: ternaries 9 (16 pts), if/else 10 (15 pts), boolean chains 6, loops 1 (nesting depth added 12). Most of this is not in the body itself: 14 of the 38 points are its own statements and the rest belongs to 2 function items inside it that branch (a function literal at line 36, handleClick). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
App.App (cognitive 38) typescript2/app-vscode-webview/src/App.tsx:63— App.App has cognitive complexity 38 (threshold 15). Drivers by points: if/else 15, boolean chains 13, ternaries 7 (10 pts) (nesting depth added 3). Most of this is not in the body itself: 12 of the 38 points are its own statements and the rest belongs to 9 function literals inside it that branch (lines 85, 140, 178, …). 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.
TestResponse::status (cognitive 37) engine/baml-runtime/src/types/response.rs:424— TestResponse::status has cognitive complexity 37 (threshold 15). Drivers by points: if/else 13 (24 pts), match/switch 3 (11 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.
baml_go.decodeJSON (cognitive 37) baml_language/sdks/go/baml_go/json.go:142— baml_go.decodeJSON has cognitive complexity 37 (threshold 15). Drivers by points: if/else 14 (31 pts), loops 2 (4 pts), boolean chains 1, match/switch 1 (nesting depth added 19). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
BamlGeneratedCodecContext.ReadUnionCore (cognitive 36) baml_language/sdks/csharp/bridge_csharp/src/Generated/V1/BamlGeneratedCodec.cs:708— BamlGeneratedCodecContext.ReadUnionCore has cognitive complexity 36 (threshold 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.
RuntimeCompileArtifactSlot::measure (cognitive 36) baml_language/crates/bex_vm/src/compile_artifact.rs:106— RuntimeCompileArtifactSlot::measure has cognitive complexity 36 (threshold 15). Drivers by points: loops 10 (26 pts), if/else 4 (9 pts), boolean chains 1 (nesting depth added 21). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
RenderDefinitionValidator::visit (cognitive 36) baml_language/crates/bex_vm/src/package_reflect/type_class.rs:271— RenderDefinitionValidator::visit has cognitive complexity 36 (threshold 15). Drivers by points: if/else 11 (30 pts), loops 2 (4 pts), boolean chains 1, match/switch 1 (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.
generators_typescript::watchers::build_event_collectors (cognitive 36) engine/generators/languages/typescript/src/watchers.rs:139— generators_typescript::watchers::build_event_collectors has cognitive complexity 36 (threshold 15). Drivers by points: if/else 11 (28 pts), loops 4 (5 pts), 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.
summarize.main (cognitive 36) baml_language/tools/gc_policy/summarize.py:10— summarize.main has cognitive complexity 36 (threshold 15). Drivers by points: loops 11 (20 pts), if/else 5 (12 pts), ternaries 2 (4 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.
baml_go.encodeJSON (cognitive 36) baml_language/sdks/go/baml_go/json.go:24— baml_go.encodeJSON has cognitive complexity 36 (threshold 15). Drivers by points: if/else 17 (30 pts), boolean chains 3, loops 1 (2 pts), match/switch 1 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
LivePlayground.LivePlayground (cognitive 36) typescript2/app-website/app/learn2/_components/LivePlayground.tsx:102— LivePlayground.LivePlayground has cognitive complexity 36 (threshold 15). Drivers by points: if/else 12, ternaries 10 (12 pts), boolean chains 8, error handling 3 (4 pts) (nesting depth added 3). Most of this is not in the body itself: 8 of the 36 points are its own statements and the rest belongs to 11 function literals inside it that branch (lines 356, 150, 162, …). 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.
RuntimeCli::run (cognitive 35) engine/cli/src/commands.rs:117— RuntimeCli::run has cognitive complexity 35 (threshold 15). Drivers by points: match/switch 17 (28 pts), if/else 4 (5 pts), loops 1 (2 pts) (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.
DescribeArgs::run (cognitive 35) baml_language/crates/baml_cli/src/describe_command.rs:313— DescribeArgs::run has cognitive complexity 35 (threshold 15). Drivers by points: if/else 18 (28 pts), loops 1 (3 pts), match/switch 2 (3 pts), boolean chains 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
VertexClient::build_request (cognitive 35) engine/baml-runtime/src/internal/llm_client/primitive/vertex/vertex_client.rs:240— VertexClient::build_request has cognitive complexity 35 (threshold 15). Drivers by points: if/else 14 (22 pts), match/switch 6 (9 pts), loops 2 (3 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.
WithIr::encode (cognitive 35) engine/language_client_cffi/src/ctypes/baml_value_with_meta_encode.rs:32— WithIr::encode has cognitive complexity 35 (threshold 15). Drivers by points: if/else 17 (28 pts), match/switch 5 (7 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
kpis.build (cognitive 35) baml_language/tools/speedtest/src/speedtest/kpis.py:69— kpis.build has cognitive complexity 35 (threshold 15). Drivers by points: ternaries 6 (14 pts), loops 5 (8 pts), boolean chains 7, if/else 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.
index.testLargeStructure (cognitive 35) engine/generators/data/edge_cases/typescript/index.ts:27— index.testLargeStructure has cognitive complexity 35 (threshold 15). Drivers by points: if/else 14 (18 pts), boolean chains 13, loops 4 (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
simulator.simulateExecution (cognitive 35) typescript/packages/playground-common/src/sdk/runtime/simulator.ts:20— simulator.simulateExecution has cognitive complexity 35 (threshold 15). Drivers by points: if/else 10 (27 pts), boolean chains 5, 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.
FunctionSidebar.TestTreeNode (cognitive 35) typescript2/pkg-playground/src/FunctionSidebar.tsx:69— FunctionSidebar.TestTreeNode has cognitive complexity 35 (threshold 15). Drivers by points: ternaries 10 (19 pts), boolean chains 12, if/else 3 (4 pts) (nesting depth added 10). Of this number, 30 points are the body's own statements and 5 belong to 2 function literals 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.
TraceSnapshotBuilder::copy_object (cognitive 34) baml_language/crates/bex_engine/src/trace_heap.rs:324— TraceSnapshotBuilder::copy_object has cognitive complexity 34 (threshold 15). Drivers by points: if/else 10 (17 pts), loops 4 (11 pts), match/switch 3 (5 pts), boolean chains 1 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
TelemetryState::enter_bytecode_with_trace (cognitive 34) baml_language/crates/bex_vm/src/telemetry.rs:746— TelemetryState::enter_bytecode_with_trace has cognitive complexity 34 (threshold 15). Drivers by points: if/else 19 (21 pts), boolean chains 13 (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.
TypeContext::infer_type (cognitive 34) engine/baml-compiler/src/thir/typecheck.rs:572— TypeContext::infer_type has cognitive complexity 34 (threshold 15). Drivers by points: if/else 10 (17 pts), match/switch 7 (16 pts), boolean chains 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.
InitUI::render (cognitive 34) REDACTED:93— InitUI::render has cognitive complexity 34 (threshold 15). Drivers by points: if/else 13 (26 pts), match/switch 3 (6 pts), boolean chains 1, 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.
schedule.validate (cognitive 34) tools/bctl_src/oncall/schedule.py:51— schedule.validate has cognitive complexity 34 (threshold 15). Drivers by points: if/else 13 (26 pts), boolean chains 4, loops 2 (3 pts), error handling 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.
SmartEdge.splitPoints (cognitive 34) typescript/packages/playground-common/src/graph-primitives/edges/EdgeController/smart-edge.ts:138— SmartEdge.splitPoints has cognitive complexity 34 (threshold 15). Drivers by points: if/else 15 (24 pts), ternaries 5 (7 pts), boolean chains 3 (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.
route.POST (cognitive 34) REDACTED:273— route.POST has cognitive complexity 34 (threshold 15). Drivers by points: if/else 10 (19 pts), boolean chains 6, ternaries 2 (4 pts), error handling 3, 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.
route.PUT (cognitive 34) REDACTED:391— route.PUT has cognitive complexity 34 (threshold 15). Drivers by points: if/else 11 (20 pts), boolean chains 5, ternaries 2 (4 pts), error handling 3, 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.
search-menu.SearchMenu (cognitive 34) typescript2/app-developer-docs/components/search-menu.tsx:35— search-menu.SearchMenu has cognitive complexity 34 (threshold 15). Drivers by points: if/else 14 (15 pts), ternaries 6 (14 pts), boolean chains 5 (nesting depth added 9). Most of this is not in the body itself: 11 of the 34 points are its own statements and the rest belongs to 8 function items inside it that branch (a function literal at line 67, onInputKeyDown, a function literal at line 50, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
index.testSimpleNested (cognitive 33) engine/generators/data/nested_structures/typescript/index.ts:3— index.testSimpleNested has cognitive complexity 33 (threshold 15). Drivers by points: if/else 18, boolean chains 15. 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.
package-generator.buildReferencePages (cognitive 33) typescript2/app-developer-docs/lib/generated-content/package-generator.ts:161— package-generator.buildReferencePages has cognitive complexity 33 (threshold 15). Drivers by points: loops 11 (15 pts), if/else 6 (14 pts), boolean chains 3, ternaries 1 (nesting depth added 12). Of this number, 29 points are the body's own statements and 4 belong to 3 function literals 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.
TyResolvedRef::coerce (cognitive 32) baml_language/crates/bex_sap/src/deserializer/coercer/coerce_ty.rs:144— TyResolvedRef::coerce has cognitive complexity 32 (threshold 15). Drivers by points: if/else 11 (18 pts), match/switch 6 (13 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.
sys_glob::glob_to_regex (cognitive 32) baml_language/crates/sys_glob/src/lib.rs:98— sys_glob::glob_to_regex has cognitive complexity 32 (threshold 15). Drivers by points: if/else 10 (20 pts), boolean chains 6, loops 2 (4 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.
telemetry_resource_report.render_report (cognitive 32) baml_language/scripts/telemetry_resource_report.py:248— telemetry_resource_report.render_report has cognitive complexity 32 (threshold 15). Drivers by points: loops 10 (20 pts), if/else 4 (6 pts), ternaries 2 (4 pts), error handling 1 (2 pts) (nesting depth added 15). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
baml_go.prepareInvocation (cognitive 32) baml_language/sdks/go/baml_go/invocation.go:50— baml_go.prepareInvocation has cognitive complexity 32 (threshold 15). Drivers by points: if/else 16 (27 pts), boolean chains 3, 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.
pkg.goToInboundValueTracking (cognitive 32) baml_language/sdks/go/bridge_go/pkg/proto.go:85— pkg.goToInboundValueTracking has cognitive complexity 32 (threshold 15). Drivers by points: if/else 10 (24 pts), loops 2 (4 pts), match/switch 2 (3 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.
emit-sublime.renderYaml (cognitive 32) typescript2/pkg-grammar/scripts/emit-sublime.ts:344— emit-sublime.renderYaml has cognitive complexity 32 (threshold 15). Drivers by points: if/else 5 (20 pts), loops 4 (9 pts), match/switch 1 (3 pts) (nesting depth added 22). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
IntTy::coerce (cognitive 31) baml_language/crates/bex_sap/src/deserializer/coercer/coerce_primitive.rs:115— IntTy::coerce has cognitive complexity 31 (threshold 15). Drivers by points: if/else 15 (28 pts), boolean chains 2, match/switch 1 (nesting depth added 13). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
ProtoReader.decodeUnionVariant (cognitive 31) baml_language/sdks/java/baml_bridge/src/main/java/baml_bridge/internal/ProtoReader.java:739— ProtoReader.decodeUnionVariant has cognitive complexity 31 (threshold 15). Drivers by points: if/else 10 (21 pts), ternaries 2 (7 pts), match/switch 1 (2 pts), loops 1 (nesting depth added 17). 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.
baml_go.decodeMedia (cognitive 31) baml_language/sdks/go/baml_go/media.go:677— baml_go.decodeMedia has cognitive complexity 31 (threshold 15). Drivers by points: if/else 15 (27 pts), match/switch 2 (3 pts), boolean chains 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
pkg.outboundToGo (cognitive 31) baml_language/sdks/go/bridge_go/pkg/proto.go:278— pkg.outboundToGo has cognitive complexity 31 (threshold 15). Drivers by points: if/else 9 (22 pts), loops 3 (6 pts), match/switch 2 (3 pts) (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
bep-nav.BepNav (cognitive 31) typescript2/app-beps/src/components/bep/bep-nav.tsx:72— bep-nav.BepNav has cognitive complexity 31 (threshold 15). Drivers by points: boolean chains 15, if/else 8 (9 pts), loops 4, ternaries 3 (nesting depth added 1). Most of this is not in the body itself: 12 of the 31 points are its own statements and the rest belongs to 4 function items inside it that branch (a function literal at line 150, a function literal at line 128, appendSubtree, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
comment-feed-view.FeedCommentCard (cognitive 31) typescript2/app-beps/src/components/comments/comment-feed-view.tsx:215— comment-feed-view.FeedCommentCard has cognitive complexity 31 (threshold 15). Drivers by points: boolean chains 23, if/else 6, error handling 1, ternaries 1. Of this number, 18 points are the body's own statements and 13 belong to 8 function items inside it that branch. 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.
comment-thread.SingleComment (cognitive 31) typescript2/app-beps/src/components/comments/comment-thread.tsx:133— comment-thread.SingleComment has cognitive complexity 31 (threshold 15). Drivers by points: boolean chains 21, if/else 6, ternaries 3, error handling 1. Of this number, 18 points are the body's own statements and 13 belong to 7 function items inside it that branch. 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.
encode.serializeValue (cognitive 31) typescript2/pkg-proto/src/encode.ts:21— encode.serializeValue has cognitive complexity 31 (threshold 15). Drivers by points: if/else 14 (23 pts), boolean chains 5, ternaries 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.
FormatArgs::run (cognitive 30) baml_language/crates/baml_cli/src/format.rs:51— FormatArgs::run has cognitive complexity 30 (threshold 15). Drivers by points: if/else 14 (20 pts), match/switch 4 (9 pts), loops 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
QueryArgs::run (cognitive 30) baml_language/crates/baml_cli/src/query_command.rs:168— QueryArgs::run has cognitive complexity 30 (threshold 15). Drivers by points: match/switch 9 (14 pts), if/else 11 (13 pts), boolean chains 3 (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.
Collector::body (cognitive 30) baml_language/crates/baml_compiler2_rust/src/reach.rs:58— Collector::body has cognitive complexity 30 (threshold 15). Drivers by points: if/else 7 (23 pts), match/switch 1 (4 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.
Shared::take (cognitive 30) baml_language/crates/bex_chunkedringbuffer/src/lib.rs:273— Shared::take has cognitive complexity 30 (threshold 15). Drivers by points: if/else 11 (26 pts), loops 2 (3 pts), boolean chains 1 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
baml_go.decodeGeneratedClass (cognitive 30) baml_language/sdks/go/baml_go/dynamic.go:850— baml_go.decodeGeneratedClass has cognitive complexity 30 (threshold 15). Drivers by points: if/else 11 (25 pts), boolean chains 3, 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.
BamlUnion3._bamlDecode (cognitive 30) baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:177— BamlUnion3._bamlDecode has cognitive complexity 30 (threshold 15). Drivers by points: if/else 15 (24 pts), boolean chains 6 (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.
bep-route-shell.BepRouteShell::handleConfirmSubmit (cognitive 30) typescript2/app-beps/src/components/bep/bep-route-shell.tsx:572— bep-route-shell.BepRouteShell::handleConfirmSubmit has cognitive complexity 30 (threshold 15). Drivers by points: if/else 11 (21 pts), boolean chains 5, loops 2, error handling 1, ternaries 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. This shape REPEATS in the file: one other method here (bep-route-shell.BepRouteShell) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
deployment-status.DeploymentStatus (cognitive 30) typescript2/app-website/components/magicui/deployment-status.tsx:30— deployment-status.DeploymentStatus has cognitive complexity 30 (threshold 15). Drivers by points: boolean chains 20, if/else 8, match/switch 1, ternaries 1. Most of this is not in the body itself: 3 of the 30 points are its own statements and the rest belongs to 9 function items inside it that branch (a function literal at line 254, getProviderStatus, a function literal at line 117, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
TelemetryView.ContextInspector (cognitive 30) typescript2/pkg-playground/src/telemetry/TelemetryView.tsx:3192— TelemetryView.ContextInspector has cognitive complexity 30 (threshold 15). Drivers by points: ternaries 16 (19 pts), boolean chains 10, if/else 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.
ProgramIndex::index_objects (cognitive 29) baml_language/crates/baml_compiler2_rust/src/index.rs:75— ProgramIndex::index_objects has cognitive complexity 29 (threshold 15). Drivers by points: if/else 5 (16 pts), match/switch 4 (12 pts), loops 1 (nesting depth added 19). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Consumer::drain_chunks (cognitive 29) baml_language/crates/bex_chunkedringbuffer/src/lib.rs:901— Consumer::drain_chunks has cognitive complexity 29 (threshold 15). Drivers by points: if/else 8 (16 pts), loops 5 (9 pts), match/switch 1 (3 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.
BigintTy::coerce (cognitive 29) baml_language/crates/bex_sap/src/deserializer/coercer/coerce_primitive.rs:304— BigintTy::coerce has cognitive complexity 29 (threshold 15). Drivers by points: if/else 15 (28 pts), match/switch 1 (nesting depth added 13). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
GoTypeProjection::project_inner (cognitive 29) baml_language/sdks/go/sdkgen_go/src/types.rs:254— GoTypeProjection::project_inner has cognitive complexity 29 (threshold 15). Drivers by points: if/else 11 (16 pts), match/switch 5 (9 pts), boolean chains 4 (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.
Bench.run_query (cognitive 29) baml_language/tools/btel_query_bench.py:233— Bench.run_query has cognitive complexity 29 (threshold 15). Drivers by points: loops 6 (17 pts), if/else 3 (12 pts) (nesting depth added 20). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
btel_query_summary.query_section (cognitive 29) baml_language/tools/btel_query_summary.py:89— btel_query_summary.query_section has cognitive complexity 29 (threshold 15). Drivers by points: if/else 9 (14 pts), loops 7 (14 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.
pkg.thrownError (cognitive 29) baml_language/sdks/go/bridge_go/pkg/proto.go:238— pkg.thrownError has cognitive complexity 29 (threshold 15). Drivers by points: if/else 8 (24 pts), loops 2 (3 pts), boolean chains 2 (nesting depth added 17). 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.
BamlRuntime.executeTests (cognitive 29) typescript/packages/playground-common/src/sdk/runtime/BamlRuntime.ts:837— BamlRuntime.executeTests has cognitive complexity 29 (threshold 15). Drivers by points: if/else 10 (13 pts), boolean chains 7, loops 4 (5 pts), error handling 1 (3 pts), ternaries 1 (nesting depth added 6). Most of this is not in the body itself: 10 of the 29 points are its own statements and the rest belongs to 3 function literals inside it that branch (lines 914, 846, 885). 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.
annotation-svg.renderAnnotatedSnippet (cognitive 29) typescript2/app-developer-docs/lib/snippets/annotation-svg.ts:57— annotation-svg.renderAnnotatedSnippet has cognitive complexity 29 (threshold 15). Drivers by points: if/else 11 (12 pts), boolean chains 8, ternaries 5, loops 4 (nesting depth added 1). Most of this is not in the body itself: 8 of the 29 points are its own statements and the rest belongs to 4 function items inside it that branch (a function literal at line 94, a function literal at line 167, pos, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
dictionary-types.unsafeDirectValue (cognitive 29) typescript2/app-developer-docs/tools/oxlint/anti-slop/shared/dictionary-types.ts:176— dictionary-types.unsafeDirectValue has cognitive complexity 29 (threshold 15). Drivers by points: if/else 14 (15 pts), ternaries 5 (10 pts), boolean chains 4 (nesting depth added 6). 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.
types.buildGroups (cognitive 29) typescript2/app-stdlib-matrix/src/types.ts:350— types.buildGroups has cognitive complexity 29 (threshold 15). Drivers by points: if/else 10 (17 pts), loops 4 (6 pts), ternaries 3 (6 pts) (nesting depth added 12). Of this number, 25 points are the body's own statements and 4 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.
CallArgs::single_line_width (cognitive 28) baml_language/crates/baml_fmt/src/ast/expressions.rs:2993— CallArgs::single_line_width has cognitive complexity 28 (threshold 15). Drivers by points: loops 9 (21 pts), if/else 4 (7 pts) (nesting depth added 15). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
IRSignature::new_from_ir (cognitive 28) engine/baml-lib/baml-core/src/ir/ir_hasher/mod.rs:291— IRSignature::new_from_ir has cognitive complexity 28 (threshold 15). Drivers by points: if/else 6 (15 pts), loops 12 (13 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.
baml_types::ir_type::converters::streaming::from_type_ir::partialize_helper (cognitive 28) engine/baml-lib/baml-types/src/ir_type/converters/streaming.rs:11— baml_types::ir_type::converters::streaming::from_type_ir::partialize_helper has cognitive complexity 28 (threshold 15). Drivers by points: if/else 13 (21 pts), boolean chains 4, match/switch 2 (3 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
proto.encode_call_args (cognitive 28) baml_language/sdks/python/src/baml_bridge/proto.py:783— proto.encode_call_args has cognitive complexity 28 (threshold 15). Drivers by points: if/else 9 (12 pts), error handling 3 (7 pts), loops 4 (7 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.
Run.fixture (cognitive 28) baml_language/tools/btel_query_smoke.py:124— Run.fixture has cognitive complexity 28 (threshold 15). Drivers by points: if/else 7 (11 pts), loops 5 (7 pts), boolean chains 5, ternaries 3 (5 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
baml_go.resolveRuntime (cognitive 28) baml_language/sdks/go/baml_go/runtime_artifact.go:171— baml_go.resolveRuntime has cognitive complexity 28 (threshold 15). Drivers by points: if/else 21 (28 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.
index.testRecursiveComplexity (cognitive 28) engine/generators/data/mixed_complex_types/typescript/index.ts:185— index.testRecursiveComplexity has cognitive complexity 28 (threshold 15). Drivers by points: if/else 13 (19 pts), boolean chains 9 (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.
index.TestingSidebar (cognitive 28) typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/side-bar/index.tsx:48— index.TestingSidebar has cognitive complexity 28 (threshold 15). Drivers by points: boolean chains 18, if/else 6 (7 pts), ternaries 3 (nesting depth added 1). Most of this is not in the body itself: 5 of the 28 points are its own statements and the rest belongs to 8 function items inside it that branch (a function literal at line 109, a function literal at line 205, a function literal at line 265, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
dictionary-types.dictionaryValueTypes (cognitive 28) typescript2/app-developer-docs/tools/oxlint/anti-slop/shared/dictionary-types.ts:232— dictionary-types.dictionaryValueTypes has cognitive complexity 28 (threshold 15). Drivers by points: ternaries 6 (12 pts), if/else 10, boolean chains 6 (nesting depth added 6). Of this number, 25 points are the body's own statements and 3 belong to one function literal inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
page.RunPage (cognitive 28) typescript2/app-website/app/atb/runs/[id]/page.tsx:27— page.RunPage has cognitive complexity 28 (threshold 15). Drivers by points: boolean chains 21, ternaries 4, if/else 3. Of this number, 26 points are the body's own statements and 2 belong to 3 function items inside it that branch. 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.
og-card.OgCard (cognitive 28) typescript2/app-website/components/og/og-card.tsx:50— og-card.OgCard has cognitive complexity 28 (threshold 15). Drivers by points: ternaries 11 (26 pts), boolean chains 2 (nesting depth added 15). Most of this is not in the body itself: 13 of the 28 points are its own statements and the rest belongs to 2 function literals inside it that branch (lines 272, 197). 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.
FeedbackInner::run (cognitive 27) baml_language/crates/baml_cli/src/feedback_command.rs:206— FeedbackInner::run has cognitive complexity 27 (threshold 15). Drivers by points: if/else 17 (23 pts), boolean chains 2, match/switch 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.
ArtifactTelemetry::from_manifest (cognitive 27) baml_language/crates/btel_settings/src/artifact.rs:317— ArtifactTelemetry::from_manifest has cognitive complexity 27 (threshold 15). Drivers by points: if/else 11 (16 pts), match/switch 3 (7 pts), boolean chains 2, loops 1 (2 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
launch-runtime.runtime_environment (cognitive 27) tools/atb2/deploy/launch-runtime.py:28— launch-runtime.runtime_environment has cognitive complexity 27 (threshold 15). Drivers by points: if/else 9 (21 pts), loops 2 (4 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.
csharp-mtime-cache.restore (cognitive 27) .github/scripts/csharp-mtime-cache.py:98— csharp-mtime-cache.restore has cognitive complexity 27 (threshold 15). Drivers by points: if/else 9 (13 pts), loops 5 (8 pts), error handling 2 (4 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.
telemetry_resource_report._reference_metrics (cognitive 27) baml_language/scripts/telemetry_resource_report.py:163— telemetry_resource_report._reference_metrics has cognitive complexity 27 (threshold 15). Drivers by points: if/else 7 (15 pts), ternaries 3 (6 pts), loops 3 (4 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.
baml_go.equalBAMLType (cognitive 27) baml_language/sdks/go/baml_go/value.go:347— baml_go.equalBAMLType has cognitive complexity 27 (threshold 15). Drivers by points: if/else 6 (12 pts), boolean chains 7, loops 2 (5 pts), 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.
FileViewer.FileViewer (cognitive 27) typescript/apps/fiddle-web-app/app/[project_id]/_components/Tree/FileViewer.tsx:113— FileViewer.FileViewer has cognitive complexity 27 (threshold 15). Drivers by points: if/else 10 (20 pts), boolean chains 3, loops 2 (3 pts), ternaries 1 (nesting depth added 11). Most of this is not in the body itself: 2 of the 27 points are its own statements and the rest belongs to 5 function literals inside it that branch (lines 178, 257, 168, …). 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.
chart.ChartTooltipContent (cognitive 27) REDACTED:107— chart.ChartTooltipContent has cognitive complexity 27 (threshold 15). Drivers by points: boolean chains 14, ternaries 6 (9 pts), if/else 4 (nesting depth added 3). Most of this is not in the body itself: 4 of the 27 points are its own statements and the rest belongs to 2 function literals inside it that branch (lines 182, 131). 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.
copy-button.CopyButton (cognitive 27) typescript/packages/ui/src/custom/copy-button.tsx:44— copy-button.CopyButton has cognitive complexity 27 (threshold 15). Drivers by points: ternaries 9 (23 pts), if/else 2 (3 pts), error handling 1 (nesting depth added 15). Of this number, 23 points are the body's own statements and 4 belong to one function item inside it that branches. 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.
page.ProfilePage (cognitive 27) typescript2/app-beps/src/app/profile/page.tsx:77— page.ProfilePage has cognitive complexity 27 (threshold 15). Drivers by points: boolean chains 14, if/else 7, error handling 3, ternaries 3. Of this number, 18 points are the body's own statements and 9 belong to 4 function items inside it that branch. 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.
bep-export-all-dialog.BepExportAllDialog (cognitive 27) typescript2/app-beps/src/components/bep/bep-export-all-dialog.tsx:73— bep-export-all-dialog.BepExportAllDialog has cognitive complexity 27 (threshold 15). Drivers by points: boolean chains 8, if/else 5 (8 pts), ternaries 6 (7 pts), loops 2 (3 pts), error handling 1 (nesting depth added 5). Most of this is not in the body itself: 11 of the 27 points are its own statements and the rest belongs to 2 function literals inside it that branch (lines 83, 139). 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.
issue-card.IssueCard (cognitive 27) typescript2/app-beps/src/components/issues/issue-card.tsx:62— issue-card.IssueCard has cognitive complexity 27 (threshold 15). Drivers by points: boolean chains 9, ternaries 8 (9 pts), error handling 4 (5 pts), if/else 4 (nesting depth added 2). Of this number, 16 points are the body's own statements and 11 belong to 6 function items inside it that branch. 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.
page.AgentsPage (cognitive 27) typescript2/app-website/app/atb/agents/page.tsx:37— page.AgentsPage has cognitive complexity 27 (threshold 15). Drivers by points: ternaries 9 (17 pts), boolean chains 5, if/else 5 (nesting depth added 8). Most of this is not in the body itself: 3 of the 27 points are its own statements and the rest belongs to 4 function items inside it that branch (a function literal at line 104, resolve, a function literal at line 69, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
args-form-model.matches (cognitive 27) typescript2/pkg-playground/src/args-form-model.ts:232— args-form-model.matches has cognitive complexity 27 (threshold 15). Drivers by points: if/else 7 (16 pts), boolean chains 10, 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.
lod.applyLevelOfDetail (cognitive 27) typescript2/pkg-playground/src/graph/lod.ts:106— lod.applyLevelOfDetail has cognitive complexity 27 (threshold 15). Drivers by points: if/else 11 (16 pts), boolean chains 7, loops 4 (nesting depth added 5). Of this number, 19 points are the body's own statements and 8 belong to 3 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.
WebSocketRuntimePort.fromServer (cognitive 27) typescript2/pkg-playground/src/ports/WebSocketRuntimePort.ts:463— WebSocketRuntimePort.fromServer has cognitive complexity 27 (threshold 15). Drivers by points: ternaries 6 (12 pts), if/else 6 (11 pts), loops 1 (2 pts), boolean chains 1, match/switch 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.
ReplayServer.ServeRequestAsync (cognitive 26) baml_language/sdk_tests/crates/csharp/streaming/Program.cs:433— ReplayServer.ServeRequestAsync has cognitive complexity 26 (threshold 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.
ProjectRuntimeCompiler::compile (cognitive 26) baml_language/crates/bex_project/src/runtime_compile.rs:1738— ProjectRuntimeCompiler::compile has cognitive complexity 26 (threshold 15). Drivers by points: if/else 8 (14 pts), match/switch 5 (8 pts), loops 3, 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.
MapDriver::drive (cognitive 26) baml_language/crates/bex_vm/src/package_baml/map.rs:81— MapDriver::drive has cognitive complexity 26 (threshold 15). Drivers by points: if/else 6 (14 pts), match/switch 4 (10 pts), boolean chains 1, 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.
Value::equal (cognitive 26) baml_language/crates/btel_reader/src/value/equality.rs:129— Value::equal has cognitive complexity 26 (threshold 15). Drivers by points: if/else 5 (14 pts), loops 3 (7 pts), boolean chains 4, match/switch 1 (nesting depth added 13). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
SseParser::feed (cognitive 26) baml_language/crates/sys_types/src/sse.rs:47— SseParser::feed has cognitive complexity 26 (threshold 15). Drivers by points: if/else 10 (19 pts), match/switch 2 (6 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.
ProtoReader.decodeClassWithDesc (cognitive 26) baml_language/sdks/java/baml_bridge/src/main/java/baml_bridge/internal/ProtoReader.java:1272— ProtoReader.decodeClassWithDesc has cognitive complexity 26 (threshold 15). Drivers by points: if/else 5 (10 pts), match/switch 2 (6 pts), loops 3 (5 pts), boolean chains 3, ternaries 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.
runner._save (cognitive 26) baml_language/tools/speedtest/src/speedtest/runner.py:271— runner._save has cognitive complexity 26 (threshold 15). Drivers by points: if/else 6 (10 pts), loops 5 (8 pts), ternaries 3 (7 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.
bump-version.perform_version_bumps (cognitive 26) tools/bump-version.py:322— bump-version.perform_version_bumps has cognitive complexity 26 (threshold 15). Drivers by points: ternaries 11 (23 pts), loops 1 (2 pts), if/else 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.
Tree.splay (cognitive 26) baml_language/tools/speedtest/workloads/memory/splay-2k/main.js:9— Tree.splay has cognitive complexity 26 (threshold 15). Drivers by points: if/else 10 (25 pts), loops 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.
Node.Node (cognitive 26) typescript/apps/fiddle-web-app/app/[project_id]/_components/Tree/Node.tsx:39— Node.Node has cognitive complexity 26 (threshold 15). Drivers by points: if/else 6 (12 pts), ternaries 7 (11 pts), boolean chains 2, loops 1 (nesting depth added 10). Most of this is not in the body itself: 12 of the 26 points are its own statements and the rest belongs to 5 function literals inside it that branch (lines 47, 121, 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.
bep-list.BepList (cognitive 26) typescript2/app-beps/src/components/bep/bep-list.tsx:46— bep-list.BepList has cognitive complexity 26 (threshold 15). Drivers by points: ternaries 11 (20 pts), boolean chains 5, if/else 1 (nesting depth added 9). Of this number, 19 points are the body's own statements and 7 belong to 5 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.
dictionary-types.classifyWideningTarget (cognitive 26) typescript2/app-developer-docs/tools/oxlint/anti-slop/shared/dictionary-types.ts:320— dictionary-types.classifyWideningTarget has cognitive complexity 26 (threshold 15). Drivers by points: ternaries 6 (13 pts), if/else 11, 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.
render-part.RenderPart (cognitive 26) typescript2/app-website/lib/mdx/baml-block/baml-project-panel/playground-panel/prompt-preview/render-part.tsx:12— render-part.RenderPart has cognitive complexity 26 (threshold 15). Drivers by points: if/else 10 (16 pts), error handling 2 (5 pts), boolean chains 3, ternaries 1 (2 pts) (nesting depth added 10). Most of this is not in the body itself: 6 of the 26 points are its own statements and the rest belongs to 3 function items inside it that branch (a function literal at line 16, a function literal at line 44, extractStringValues). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
council-gate.Council (cognitive 26) typescript2/app-website/app/sheep-council/council-gate.tsx:210— council-gate.Council has cognitive complexity 26 (threshold 15). Drivers by points: ternaries 7 (10 pts), if/else 8 (9 pts), boolean chains 5, error handling 2 (nesting depth added 4). Of this number, 13 points are the body's own statements and 13 belong to 3 function items inside it that branch. 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.
perspective-slider.PerspectiveSlider (cognitive 26) REDACTED:1307— perspective-slider.PerspectiveSlider has cognitive complexity 26 (threshold 15). Drivers by points: ternaries 10 (14 pts), if/else 9, boolean chains 3 (nesting depth added 4). Most of this is not in the body itself: 11 of the 26 points are its own statements and the rest belongs to 4 function items inside it that branch (onKeyDown, a function literal at line 1315, tabStyle, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
BaseEdge.pathFromPoints (cognitive 26) typescript2/pkg-playground/src/graph/edges/BaseEdge.tsx:23— BaseEdge.pathFromPoints has cognitive complexity 26 (threshold 15). Drivers by points: ternaries 6 (16 pts), if/else 4 (6 pts), boolean chains 3, loops 1 (nesting depth added 12). Of this number, 23 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.
HostCallableProtocol.BindArguments (cognitive 25) baml_language/sdks/csharp/bridge_csharp/src/Proto/HostCallableProtocol.cs:38— HostCallableProtocol.BindArguments has cognitive complexity 25 (threshold 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.
GenerateArgs::run_generate (cognitive 25) baml_language/crates/baml_cli/src/generate.rs:297— GenerateArgs::run_generate has cognitive complexity 25 (threshold 15). Drivers by points: if/else 11 (15 pts), loops 4 (8 pts), match/switch 1 (2 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SchemaCx::field_schema (cognitive 25) baml_language/crates/baml_ide/src/param_schema.rs:219— SchemaCx::field_schema has cognitive complexity 25 (threshold 15). Drivers by points: if/else 8 (14 pts), match/switch 6 (11 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.
baml_lsp::diagnostics::collect_root_candidate (cognitive 25) baml_language/crates/baml_lsp/src/diagnostics.rs:39— baml_lsp::diagnostics::collect_root_candidate has cognitive complexity 25 (threshold 15). Drivers by points: if/else 6 (16 pts), loops 5 (7 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.
sys_auth::io_bridge::split_command (cognitive 25) baml_language/crates/sys_auth/src/io_bridge.rs:71— sys_auth::io_bridge::split_command has cognitive complexity 25 (threshold 15). Drivers by points: if/else 7 (12 pts), match/switch 4 (12 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.
PythonNames::allocate_leaf_bindings (cognitive 25) baml_language/sdks/python/rust/sdkgen_python_pydantic2/src/names.rs:241— PythonNames::allocate_leaf_bindings has cognitive complexity 25 (threshold 15). Drivers by points: if/else 4 (10 pts), loops 5 (9 pts), match/switch 2 (5 pts), boolean chains 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
DuplicateNames::into_errors (cognitive 25) engine/baml-lib/parser-database/src/names/mod.rs:38— DuplicateNames::into_errors has cognitive complexity 25 (threshold 15). Drivers by points: if/else 6 (13 pts), loops 7 (12 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.
BamlRuntime::get_llm_provider_impl (cognitive 25) engine/baml-runtime/src/lib.rs:1874— BamlRuntime::get_llm_provider_impl has cognitive complexity 25 (threshold 15). Drivers by points: if/else 9 (20 pts), boolean chains 2, loops 1 (2 pts), match/switch 1 (nesting depth added 12). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
generators_lib::version_check::check_version (cognitive 25) engine/generators/utils/generators_lib/src/version_check.rs:29— generators_lib::version_check::check_version has cognitive complexity 25 (threshold 15). Drivers by points: if/else 9 (12 pts), match/switch 6 (12 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.
Tree.splay (cognitive 25) baml_language/tools/speedtest/workloads/memory/splay-2k/main.py:30— Tree.splay has cognitive complexity 25 (threshold 15). Drivers by points: if/else 9 (24 pts), loops 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.
notify.compose_handoff (cognitive 25) tools/bctl_src/oncall/notify.py:61— notify.compose_handoff has cognitive complexity 25 (threshold 15). Drivers by points: if/else 7 (16 pts), loops 3 (5 pts), ternaries 2 (4 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
EmbedDialog.EmbedDialog (cognitive 25) typescript/apps/fiddle-web-app/app/[project_id]/_components/EmbedDialog.tsx:36— EmbedDialog.EmbedDialog has cognitive complexity 25 (threshold 15). Drivers by points: if/else 11 (14 pts), boolean chains 9, error handling 1, ternaries 1 (nesting depth added 3). Most of this is not in the body itself: 7 of the 25 points are its own statements and the rest belongs to 4 function items inside it that branch (a function literal at line 65, buildUrl, a function literal at line 62, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
simple.getSimplePath (cognitive 25) typescript/packages/playground-common/src/features/graph/layout/edge/algorithms/simple.ts:24— simple.getSimplePath has cognitive complexity 25 (threshold 15). Drivers by points: if/else 14 (23 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.
pipeline.stageInfo (cognitive 25) typescript2/app-feedback/src/lib/pipeline.ts:37— pipeline.stageInfo has cognitive complexity 25 (threshold 15). Drivers by points: ternaries 9 (13 pts), if/else 5 (7 pts), boolean chains 2, loops 1 (2 pts), match/switch 1 (nesting depth added 7). Of this number, 24 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.
index.searchSymbols (cognitive 25) typescript2/app-website/lib/baml-docs/index.ts:60— index.searchSymbols has cognitive complexity 25 (threshold 15). Drivers by points: if/else 9 (13 pts), ternaries 2 (7 pts), loops 2 (3 pts), boolean chains 2 (nesting depth added 10). Of this number, 19 points are the body's own statements and 6 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.
group-node.GroupNode (cognitive 25) typescript2/pkg-playground/src/graph/nodes/group-node.tsx:20— group-node.GroupNode has cognitive complexity 25 (threshold 15). Drivers by points: ternaries 17 (19 pts), boolean chains 6 (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.
Decoder::walk (cognitive 24) baml_language/crates/bex_vm/src/package_baml/json/decode.rs:664— Decoder::walk has cognitive complexity 24 (threshold 15). Drivers by points: match/switch 4 (10 pts), if/else 3 (7 pts), loops 3 (7 pts) (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ImplResolver::match_template (cognitive 24) baml_language/crates/bex_vm/src/package_baml/resolve.rs:1072— ImplResolver::match_template has cognitive complexity 24 (threshold 15). Drivers by points: match/switch 9 (17 pts), boolean chains 6, if/else 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.
PredefinedTypes::check_function_args (cognitive 24) engine/baml-lib/jinja/src/evaluate_type/types.rs:714— PredefinedTypes::check_function_args has cognitive complexity 24 (threshold 15). Drivers by points: if/else 10 (20 pts), loops 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.
_invocation.normalize (cognitive 24) baml_language/sdks/python/src/baml_bridge/_invocation.py:16— _invocation.normalize has cognitive complexity 24 (threshold 15). Drivers by points: if/else 14 (19 pts), boolean chains 3, loops 1 (2 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
runner.print_table (cognitive 24) baml_language/tools/speedtest/src/speedtest/runner.py:134— runner.print_table has cognitive complexity 24 (threshold 15). Drivers by points: ternaries 6 (15 pts), if/else 3 (4 pts), loops 3 (4 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.
schedule.fill_horizon (cognitive 24) tools/bctl_src/oncall/schedule.py:157— schedule.fill_horizon has cognitive complexity 24 (threshold 15). Drivers by points: if/else 10 (15 pts), loops 5 (8 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.
smoke-go-release.run (cognitive 24) scripts/smoke-go-release.py:113— smoke-go-release.run has cognitive complexity 24 (threshold 15). Drivers by points: if/else 5 (13 pts), ternaries 2 (6 pts), boolean chains 2, error handling 1 (2 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.
baml_go.resolveManifestArtifact (cognitive 24) baml_language/sdks/go/baml_go/runtime_artifact.go:262— baml_go.resolveManifestArtifact has cognitive complexity 24 (threshold 15). Drivers by points: if/else 15 (23 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.
elk-geometry.intersection (cognitive 24) typescript/packages/playground-common/src/features/graph/layout/node/algorithms/elk-geometry.ts:50— elk-geometry.intersection has cognitive complexity 24 (threshold 15). Drivers by points: if/else 8 (13 pts), ternaries 6 (11 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.
index.LLMNode (cognitive 24) typescript/packages/playground-common/src/graph-primitives/nodes/LLMNode/index.tsx:8— index.LLMNode has cognitive complexity 24 (threshold 15). Drivers by points: ternaries 12 (13 pts), boolean chains 7, if/else 4 (nesting depth added 1). Most of this is not in the body itself: 8 of the 24 points are its own statements and the rest belongs to 4 function items inside it that branch (getOutputPreview, getStateStyle, a function literal at line 156, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
graph-view.GraphView (cognitive 24) typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/prompt-preview/graph-view.tsx:44— graph-view.GraphView has cognitive complexity 24 (threshold 15). Drivers by points: if/else 12 (13 pts), boolean chains 6, ternaries 5 (nesting depth added 1). Most of this is not in the body itself: 6 of the 24 points are its own statements and the rest belongs to 10 function items inside it that branch (a function literal at line 212, a function literal at line 95, a function literal at line 100, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
prompts.buildAIAssistantPrompt (cognitive 24) typescript2/app-beps/convex/lib/prompts.ts:65— prompts.buildAIAssistantPrompt has cognitive complexity 24 (threshold 15). Drivers by points: boolean chains 9, if/else 9, ternaries 6. Of this number, 12 points are the body's own statements and 12 belong to 7 function items inside it that branch. 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.
export-utils.generateSummariesMd (cognitive 24) typescript2/app-beps/src/lib/export-utils.ts:715— export-utils.generateSummariesMd has cognitive complexity 24 (threshold 15). Drivers by points: ternaries 4 (14 pts), if/else 3 (5 pts), loops 2 (4 pts), boolean chains 1 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
dictionary-types.classifyAliasBroadTarget (cognitive 24) typescript2/app-developer-docs/tools/oxlint/anti-slop/shared/dictionary-types.ts:422— dictionary-types.classifyAliasBroadTarget has cognitive complexity 24 (threshold 15). Drivers by points: if/else 11, ternaries 5 (10 pts), boolean chains 3 (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.
comments.CommentThread (cognitive 24) typescript2/app-website/app/atb/_components/comments.tsx:95— comments.CommentThread has cognitive complexity 24 (threshold 15). Drivers by points: boolean chains 13, if/else 8 (9 pts), error handling 1, ternaries 1 (nesting depth added 1). Most of this is not in the body itself: 7 of the 24 points are its own statements and the rest belongs to 4 function items inside it that branch (submit, beginCompose, a function literal at line 177, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
article.Article (cognitive 24) typescript2/app-website/app/baml-intro/_components/article.tsx:343— article.Article has cognitive complexity 24 (threshold 15). Drivers by points: if/else 8 (10 pts), boolean chains 8, loops 3, ternaries 3 (nesting depth added 2). Most of this is not in the body itself: 8 of the 24 points are its own statements and the rest belongs to 4 function literals inside it that branch (lines 367, 354, 413, …). 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.
code-mirror-viewer.CodeMirrorViewer (cognitive 24) typescript2/app-website/lib/mdx/baml-block/baml-project-panel/codemirror-panel/code-mirror-viewer.tsx:51— code-mirror-viewer.CodeMirrorViewer has cognitive complexity 24 (threshold 15). Drivers by points: if/else 11 (15 pts), boolean chains 3, error handling 2 (3 pts), loops 1 (2 pts), ternaries 1 (nesting depth added 6). None of this is in the body itself: all 24 points belong to 7 function literals inside it that branch (lines 137, 111, 265, …). 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.
flickering-grid.FlickeringGrid (cognitive 24) typescript2/app-website/components/magicui/flickering-grid.tsx:23— flickering-grid.FlickeringGrid has cognitive complexity 24 (threshold 15). Drivers by points: if/else 8 (9 pts), boolean chains 6, loops 5 (6 pts), ternaries 1 (3 pts) (nesting depth added 4). None of this is in the body itself: all 24 points belong to 8 function literals inside it that branch (lines 48, 151, 141, …). 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.
path (cognitive 24) baml_language/tools/speedtest/workloads/compute/json-tree-path/main.js:38— path has cognitive complexity 24 (threshold 15). Drivers by points: if/else 5 (13 pts), loops 3 (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.
main.path (cognitive 23) baml_language/tools/speedtest/workloads/compute/json-tree-path/main.py:42— main.path has cognitive complexity 23 (threshold 15). Drivers by points: if/else 5 (13 pts), loops 3 (7 pts), boolean chains 3 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
telemetry_resources.run_case (cognitive 23) baml_language/scripts/telemetry_resources.py:315— telemetry_resources.run_case has cognitive complexity 23 (threshold 15). Drivers by points: boolean chains 8, ternaries 8, if/else 6, loops 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.
smoke-go-release.extract_archive (cognitive 23) scripts/smoke-go-release.py:75— smoke-go-release.extract_archive has cognitive complexity 23 (threshold 15). Drivers by points: if/else 7 (17 pts), loops 2 (4 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.
baml_go.outboundFailureIdentity (cognitive 23) baml_language/sdks/go/baml_go/runtime.go:784— baml_go.outboundFailureIdentity has cognitive complexity 23 (threshold 15). Drivers by points: if/else 4 (15 pts), loops 2 (4 pts), boolean chains 2, match/switch 1 (2 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.
pkg.coerceToType (cognitive 23) REDACTED:399— pkg.coerceToType has cognitive complexity 23 (threshold 15). Drivers by points: if/else 9 (17 pts), match/switch 3 (6 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.
serde.typeToString (cognitive 23) engine/language_client_go/baml_go/serde/decode.go:479— serde.typeToString has cognitive complexity 23 (threshold 15). Drivers by points: if/else 19 (21 pts), match/switch 1 (2 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.
index.BaseNode (cognitive 23) typescript/packages/playground-common/src/graph-primitives/nodes/BaseNode/index.tsx:8— index.BaseNode has cognitive complexity 23 (threshold 15). Drivers by points: ternaries 13 (16 pts), boolean chains 5, if/else 2 (nesting depth added 3). Of this number, 14 points are the body's own statements and 9 belong to 3 function items inside it that branch. 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.
export-all-utils.generateClaudeMd (cognitive 23) typescript2/app-beps/src/lib/export-all-utils.ts:197— export-all-utils.generateClaudeMd has cognitive complexity 23 (threshold 15). Drivers by points: ternaries 4 (11 pts), loops 4 (5 pts), if/else 2 (4 pts), boolean chains 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.
generated-reference.GeneratedReferenceContent (cognitive 23) typescript2/app-developer-docs/components/generated-reference.tsx:461— generated-reference.GeneratedReferenceContent has cognitive complexity 23 (threshold 15). Drivers by points: ternaries 14 (21 pts), boolean chains 1, if/else 1 (nesting depth added 7). Of this number, 13 points are the body's own statements and 10 belong to one function literal inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
page.IssuesPage (cognitive 23) typescript2/app-website/app/atb/issues/page.tsx:20— page.IssuesPage has cognitive complexity 23 (threshold 15). Drivers by points: ternaries 5 (13 pts), boolean chains 6, if/else 4 (nesting depth added 8). Most of this is not in the body itself: 3 of the 23 points are its own statements and the rest belongs to 3 function literals inside it that branch (lines 76, 30, 27). 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.
shiki-grammars.convertTextmateToShiki::processRepository (cognitive 23) typescript2/app-website/lib/mdx/shiki-grammars.tsx:115— shiki-grammars.convertTextmateToShiki::processRepository has cognitive complexity 23 (threshold 15). Drivers by points: if/else 7 (20 pts), boolean chains 2, 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.
evidence.reparentToRetainedAncestors (cognitive 23) typescript2/pkg-playground/src/telemetry/evidence.ts:976— evidence.reparentToRetainedAncestors has cognitive complexity 23 (threshold 15). Drivers by points: loops 5 (8 pts), if/else 4 (7 pts), boolean chains 5, ternaries 2 (3 pts) (nesting depth added 7). Of this number, 21 points are the body's own statements and 2 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.
BamlGeneratedRegistry.CreateCanonicalType (cognitive 22) baml_language/sdks/csharp/bridge_csharp/src/Generated/V1/BamlGeneratedRegistry.cs:716— BamlGeneratedRegistry.CreateCanonicalType has cognitive complexity 22 (threshold 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.
UnionTypeMember::take_base_type (cognitive 22) baml_language/crates/baml_fmt/src/ast/types.rs:456— UnionTypeMember::take_base_type has cognitive complexity 22 (threshold 15). Drivers by points: if/else 5 (12 pts), loops 2 (4 pts), match/switch 2 (4 pts), boolean chains 2 (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.
bcs_api::telemetry::send_control (cognitive 22) baml_language/crates/bcs_api/src/telemetry.rs:53— bcs_api::telemetry::send_control has cognitive complexity 22 (threshold 15). Drivers by points: if/else 9 (18 pts), match/switch 1 (2 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.
ProfilerStore::publish_bytes_locked (cognitive 22) baml_language/crates/bex_prof_store/src/prof/backend/store.rs:833— ProfilerStore::publish_bytes_locked has cognitive complexity 22 (threshold 15). Drivers by points: if/else 17 (21 pts), boolean chains 1 (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
Config::load (cognitive 22) baml_language/crates/tools_stow/src/main.rs:146— Config::load has cognitive complexity 22 (threshold 15). Drivers by points: if/else 7 (22 pts) (nesting depth added 15). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
GoPackages::for_pool_with_interfaces (cognitive 22) baml_language/sdks/go/sdkgen_go/src/packages.rs:52— GoPackages::for_pool_with_interfaces has cognitive complexity 22 (threshold 15). Drivers by points: if/else 6 (14 pts), loops 4 (7 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.
bstd::dedent::dedent (cognitive 22) engine/bstd/src/dedent.rs:6— bstd::dedent::dedent has cognitive complexity 22 (threshold 15). Drivers by points: if/else 7 (13 pts), loops 4 (6 pts), boolean chains 3 (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.
Parser.read_value (cognitive 22) baml_language/tools/speedtest/workloads/programs/json-parser-15/main.py:132— Parser.read_value has cognitive complexity 22 (threshold 15). Drivers by points: if/else 11 (17 pts), loops 2 (4 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.
btel_query_summary.record_section (cognitive 22) baml_language/tools/btel_query_summary.py:38— btel_query_summary.record_section has cognitive complexity 22 (threshold 15). Drivers by points: if/else 5 (11 pts), loops 4 (6 pts), ternaries 2 (5 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.
baml_go.dispatchHostCall (cognitive 22) baml_language/sdks/go/baml_go/host_callable.go:161— baml_go.dispatchHostCall has cognitive complexity 22 (threshold 15). Drivers by points: if/else 11 (19 pts), boolean chains 2, loops 1 (nesting depth added 8). Of this number, 19 points are the body's own statements and 3 belong to 2 function literals 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.
baml_go.getTargetLibFilename (cognitive 22) engine/language_client_go/baml_go/lib_common.go:416— baml_go.getTargetLibFilename has cognitive complexity 22 (threshold 15). Drivers by points: if/else 14 (21 pts), match/switch 1 (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.
BamlFunctionArguments.encode (cognitive 22) engine/language_client_go/pkg/rawobjects_function_args.go:29— BamlFunctionArguments.encode has cognitive complexity 22 (threshold 15). Drivers by points: if/else 11 (18 pts), loops 2 (4 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
kpis.html.chart (cognitive 22) baml_language/tools/speedtest/src/speedtest/templates/kpis.html:123— kpis.html.chart has cognitive complexity 22 (threshold 15). Drivers by points: if/else 7 (8 pts), ternaries 8, boolean chains 6 (nesting depth added 1). Most of this is not in the body itself: 10 of the 22 points are its own statements and the rest belongs to 7 function items inside it that branch (a function literal at line 139, a function literal at line 136, a function literal at line 157, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
main.setup (cognitive 22) baml_language/tools/speedtest/workloads/compute/json-request-body/main.js:37— main.setup has cognitive complexity 22 (threshold 15). Drivers by points: if/else 5 (9 pts), ternaries 2 (8 pts), loops 3 (5 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.
Parser.readValue (cognitive 22) baml_language/tools/speedtest/workloads/programs/json-parser-15/main.js:59— Parser.readValue has cognitive complexity 22 (threshold 15). Drivers by points: if/else 11 (17 pts), loops 2 (4 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.
index.testUltraComplex (cognitive 22) engine/generators/data/mixed_complex_types/typescript/index.ts:121— index.testUltraComplex has cognitive complexity 22 (threshold 15). Drivers by points: if/else 13 (15 pts), boolean chains 7 (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.
route.GET (cognitive 22) typescript2/app-beps/src/app/api/agent/beps/[number]/comments/route.ts:140— route.GET has cognitive complexity 22 (threshold 15). Drivers by points: if/else 8 (10 pts), ternaries 4 (6 pts), boolean chains 3, loops 2, error handling 1 (nesting depth added 4). Of this number, 14 points are the body's own statements and 8 belong to one function literal inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
bep-export-dialog.BepExportDialog (cognitive 22) typescript2/app-beps/src/components/bep/bep-export-dialog.tsx:35— bep-export-dialog.BepExportDialog has cognitive complexity 22 (threshold 15). Drivers by points: if/else 5 (8 pts), ternaries 6 (8 pts), boolean chains 4, error handling 1, loops 1 (nesting depth added 5). Of this number, 12 points are the body's own statements and 10 belong to one function literal inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
comment-feed-view.FeedThreadCard (cognitive 22) typescript2/app-beps/src/components/comments/comment-feed-view.tsx:553— comment-feed-view.FeedThreadCard has cognitive complexity 22 (threshold 15). Drivers by points: boolean chains 15, if/else 4, ternaries 2, error handling 1. Of this number, 13 points are the body's own statements and 9 belong to 5 function items inside it that branch. 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.
docs-toc.DocsToc (cognitive 22) typescript2/app-developer-docs/components/docs-toc.tsx:12— docs-toc.DocsToc has cognitive complexity 22 (threshold 15). Drivers by points: ternaries 6 (11 pts), if/else 4 (6 pts), boolean chains 3, loops 2 (nesting depth added 7). Most of this is not in the body itself: 6 of the 22 points are its own statements and the rest belongs to 5 function literals inside it that branch (lines 34, 70, 27, …). 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.
media.MDXMedia (cognitive 22) typescript2/app-website/lib/mdx/media.tsx:7— media.MDXMedia has cognitive complexity 22 (threshold 15). Drivers by points: boolean chains 13, if/else 7, ternaries 2. Of this number, 15 points are the body's own statements and 7 belong to 2 function literals inside it that branch. 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.
BamlPlayground.BamlPlayground (cognitive 22) typescript2/app-website/playground/BamlPlayground.tsx:33— BamlPlayground.BamlPlayground has cognitive complexity 22 (threshold 15). Drivers by points: ternaries 11 (13 pts), if/else 8, error handling 1 (nesting depth added 2). Of this number, 11 points are the body's own statements and 11 belong to 8 function items inside it that branch. 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.
FunctionSidebar.FunctionTreeNode (cognitive 22) typescript2/pkg-playground/src/FunctionSidebar.tsx:286— FunctionSidebar.FunctionTreeNode has cognitive complexity 22 (threshold 15). Drivers by points: boolean chains 11, ternaries 7 (10 pts), if/else 1 (nesting depth added 3). Of this number, 18 points are the body's own statements and 4 belong to 2 function literals inside it that branch. 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.
layout.layoutGraph (cognitive 22) typescript2/pkg-playground/src/graph/layout.ts:295— layout.layoutGraph has cognitive complexity 22 (threshold 15). Drivers by points: if/else 6 (12 pts), loops 4 (5 pts), ternaries 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.
TelemetryView.ErrorCaptureView (cognitive 22) typescript2/pkg-playground/src/telemetry/TelemetryView.tsx:1514— TelemetryView.ErrorCaptureView has cognitive complexity 22 (threshold 15). Drivers by points: boolean chains 15, ternaries 5 (7 pts) (nesting depth added 2). Of this number, 21 points are the body's own statements and 1 belongs to one function literal inside it that branches. 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.
ExecutionPanel.ExecutionPanel::handleCursorContext (cognitive 22) typescript2/pkg-playground/src/ExecutionPanel.tsx:958— ExecutionPanel.ExecutionPanel::handleCursorContext has cognitive complexity 22 (threshold 15). Drivers by points: if/else 11 (13 pts), boolean chains 5, ternaries 3 (4 pts) (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition. This shape REPEATS in the file: one other method here (ExecutionPanel.ExecutionPanel) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
baml::project_toolchain_selector (cognitive 21) baml_language/crates/baml/src/main.rs:542— baml::project_toolchain_selector has cognitive complexity 21 (threshold 15). Drivers by points: if/else 6 (19 pts), boolean chains 1, 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.
PrintChain::print_multi_line (cognitive 21) baml_language/crates/baml_fmt/src/ast/expressions.rs:5833— PrintChain::print_multi_line has cognitive complexity 21 (threshold 15). Drivers by points: if/else 9 (14 pts), loops 4 (5 pts), boolean chains 1, 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.
LocalUsageCollector::collect (cognitive 21) baml_language/crates/baml_ide/src/usages.rs:293— LocalUsageCollector::collect has cognitive complexity 21 (threshold 15). Drivers by points: if/else 5 (15 pts), loops 2 (4 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.
HydrationContext::resolve_batch (cognitive 21) baml_language/crates/baml_query/src/value/resolver.rs:113— HydrationContext::resolve_batch has cognitive complexity 21 (threshold 15). Drivers by points: if/else 8 (15 pts), loops 3 (5 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.
bex_external_types::host_return::value_satisfies_ty (cognitive 21) baml_language/crates/bex_external_types/src/host_return.rs:166— bex_external_types::host_return::value_satisfies_ty has cognitive complexity 21 (threshold 15). Drivers by points: match/switch 9 (17 pts), boolean chains 2, if/else 1 (2 pts) (nesting depth added 9). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own 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.
StreamReader::open (cognitive 21) baml_language/crates/bex_prof_store/src/prof/backend/reader.rs:232— StreamReader::open has cognitive complexity 21 (threshold 15). Drivers by points: if/else 4 (10 pts), match/switch 3 (7 pts), loops 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.
WasmIoFs::mkdir (cognitive 21) baml_language/crates/bridge_wasm/src/wasm_io_fs.rs:525— WasmIoFs::mkdir has cognitive complexity 21 (threshold 15). Drivers by points: match/switch 8 (15 pts), if/else 3 (5 pts), loops 1 (nesting depth added 9). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own 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.
BcsDeliveryHandle::submit (cognitive 21) baml_language/crates/btel_bcs/src/delivery.rs:801— BcsDeliveryHandle::submit has cognitive complexity 21 (threshold 15). Drivers by points: if/else 7 (9 pts), boolean chains 5, loops 4, match/switch 2 (3 pts) (nesting depth added 3). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Cuts::decide (cognitive 21) baml_language/crates/btel_snapshot/src/shape.rs:968— Cuts::decide has cognitive complexity 21 (threshold 15). Drivers by points: if/else 4 (11 pts), loops 3 (6 pts), boolean chains 2, match/switch 1 (2 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
_error_capture._attributes (cognitive 21) baml_language/sdks/python/src/baml_bridge/_error_capture.py:6— _error_capture._attributes has cognitive complexity 21 (threshold 15). Drivers by points: if/else 4 (11 pts), error handling 1 (4 pts), loops 3 (4 pts), boolean chains 2 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
profiler._build_name_map (cognitive 21) baml_language/tools/speedtest/src/speedtest/profiler.py:92— profiler._build_name_map has cognitive complexity 21 (threshold 15). Drivers by points: if/else 4 (13 pts), error handling 1 (4 pts), loops 2 (3 pts), boolean chains 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
storage.list_all (cognitive 21) baml_language/tools/speedtest/src/speedtest/storage.py:319— storage.list_all has cognitive complexity 21 (threshold 15). Drivers by points: if/else 5 (12 pts), loops 3 (7 pts), boolean chains 2 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
main.setup (cognitive 21) baml_language/tools/speedtest/workloads/compute/json-request-body/main.py:41— main.setup has cognitive complexity 21 (threshold 15). Drivers by points: if/else 4 (8 pts), ternaries 2 (8 pts), loops 3 (5 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.
baml_go.encodeCallForDispatchWithTargetAndTypeArgs (cognitive 21) baml_language/sdks/go/baml_go/runtime.go:553— baml_go.encodeCallForDispatchWithTargetAndTypeArgs has cognitive complexity 21 (threshold 15). Drivers by points: if/else 11 (16 pts), loops 3, boolean chains 2 (nesting depth added 5). Of this number, 20 points are the body's own statements and 1 belongs to one function literal inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
baml_go.currentRuntimeConfig (cognitive 21) baml_language/sdks/go/baml_go/runtime_artifact.go:90— baml_go.currentRuntimeConfig has cognitive complexity 21 (threshold 15). Drivers by points: if/else 14 (18 pts), boolean chains 3 (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
serde.encodeValue (cognitive 21) engine/language_client_go/baml_go/serde/encode.go:66— serde.encodeValue has cognitive complexity 21 (threshold 15). Drivers by points: if/else 12 (19 pts), match/switch 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.
BamlUnion2._bamlDecode (cognitive 21) baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:82— BamlUnion2._bamlDecode has cognitive complexity 21 (threshold 15). Drivers by points: if/else 11 (17 pts), boolean chains 4 (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.
kpis.html.fmt (cognitive 21) baml_language/tools/speedtest/src/speedtest/templates/kpis.html:78— kpis.html.fmt has cognitive complexity 21 (threshold 15). Drivers by points: ternaries 6 (21 pts) (nesting depth added 15). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
atoms-orch-graph.buildUnitNodesAndGroups (cognitive 21) typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/atoms-orch-graph.ts:309— atoms-orch-graph.buildUnitNodesAndGroups has cognitive complexity 21 (threshold 15). Drivers by points: if/else 5 (14 pts), boolean chains 4, loops 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.
preview-toolbar.PreviewToolbar (cognitive 21) typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/preview-toolbar.tsx:97— preview-toolbar.PreviewToolbar has cognitive complexity 21 (threshold 15). Drivers by points: ternaries 9 (11 pts), boolean chains 8, error handling 1, if/else 1 (nesting depth added 2). Of this number, 17 points are the body's own statements and 4 belong to 4 function items inside it that branch. 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.
bep-table-of-contents.BepTableOfContents (cognitive 21) typescript2/app-beps/src/components/bep/bep-table-of-contents.tsx:58— bep-table-of-contents.BepTableOfContents has cognitive complexity 21 (threshold 15). Drivers by points: if/else 13 (14 pts), boolean chains 5, loops 1, ternaries 1 (nesting depth added 1). Most of this is not in the body itself: 4 of the 21 points are its own statements and the rest belongs to 7 function literals inside it that branch (lines 121, 147, 154, …). 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.
bep-routes.parseBepSegments (cognitive 21) typescript2/app-beps/src/lib/bep-routes.ts:31— bep-routes.parseBepSegments has cognitive complexity 21 (threshold 15). Drivers by points: if/else 11 (15 pts), boolean chains 6 (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.
github.loadDistinctGithubIssueAuthors (cognitive 21) typescript2/app-product-metrics/src/clients/github.ts:44— github.loadDistinctGithubIssueAuthors has cognitive complexity 21 (threshold 15). Drivers by points: if/else 5 (14 pts), loops 2 (3 pts), boolean chains 2, ternaries 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.
aggregate-weekly-metric.zoomAttendanceCount (cognitive 21) typescript2/app-product-metrics/src/jobs/aggregate-weekly-metric.ts:99— aggregate-weekly-metric.zoomAttendanceCount has cognitive complexity 21 (threshold 15). Drivers by points: if/else 4 (14 pts), loops 3 (6 pts), boolean chains 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
navigation.tokenize (cognitive 21) typescript2/app-stdlib-matrix/src/navigation.ts:80— navigation.tokenize has cognitive complexity 21 (threshold 15). Drivers by points: loops 5 (11 pts), boolean chains 5, if/else 3 (5 pts) (nesting depth added 8). Of this number, 20 points are the body's own statements and 1 belongs to one function item inside it that branches. To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
newsletter-form.NewsletterForm (cognitive 21) typescript2/app-website/app/blog/_components/newsletter-form.tsx:36— newsletter-form.NewsletterForm has cognitive complexity 21 (threshold 15). Drivers by points: if/else 9, ternaries 6 (8 pts), boolean chains 3, match/switch 1 (nesting depth added 2). Most of this is not in the body itself: 5 of the 21 points are its own statements and the rest belongs to 9 function items inside it that branch (handleSubmit, SignUpFormButton, hasRecentSubmission, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
NewsletterForm.NewsletterForm (cognitive 21) typescript2/app-website/components/NewsletterForm.tsx:35— NewsletterForm.NewsletterForm has cognitive complexity 21 (threshold 15). Drivers by points: if/else 9, ternaries 6 (8 pts), boolean chains 3, match/switch 1 (nesting depth added 2). Most of this is not in the body itself: 5 of the 21 points are its own statements and the rest belongs to 9 function items inside it that branch (handleSubmit, SignUpFormButton, hasRecentSubmission, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
script-copy-btn.ScriptCopyBtn (cognitive 21) typescript2/app-website/components/magicui/script-copy-btn.tsx:23— script-copy-btn.ScriptCopyBtn has cognitive complexity 21 (threshold 15). Drivers by points: ternaries 9 (12 pts), boolean chains 5, if/else 4 (nesting depth added 3). Of this number, 17 points are the body's own statements and 4 belong to 3 function literals inside it that branch. 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.
RunOutputTerminal.RunOutputTerminal (cognitive 21) typescript2/pkg-playground/src/RunOutputTerminal.tsx:43— RunOutputTerminal.RunOutputTerminal has cognitive complexity 21 (threshold 15). Drivers by points: if/else 7 (11 pts), ternaries 2 (7 pts), loops 2, boolean chains 1 (nesting depth added 9). None of this is in the body itself: all 21 points belong to 6 function literals inside it that branch (lines 124, 60, 109, …). 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.
FileSemanticIndex::scope_at_offset (cognitive 20) baml_language/crates/baml_compiler2_hir/src/semantic_index.rs:354— FileSemanticIndex::scope_at_offset has cognitive complexity 20 (threshold 15). Drivers by points: if/else 6 (12 pts), boolean chains 4, loops 2 (4 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
NormalTy::absorb_subtypes (cognitive 20) baml_language/crates/baml_type/src/normalize.rs:2533— NormalTy::absorb_subtypes has cognitive complexity 20 (threshold 15). Drivers by points: if/else 6 (13 pts), boolean chains 4, loops 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.
Walker::visit (cognitive 20) baml_language/crates/bex_vm/src/package_baml/json/encode.rs:628— Walker::visit has cognitive complexity 20 (threshold 15). Drivers by points: match/switch 7 (12 pts), if/else 4 (8 pts) (nesting depth added 9). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own 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.
sys_wasm::host_value::complete_host_call (cognitive 20) baml_language/crates/sys_wasm/src/host_value.rs:429— sys_wasm::host_value::complete_host_call has cognitive complexity 20 (threshold 15). Drivers by points: if/else 8 (11 pts), match/switch 4 (8 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.
RenderContext::type_source_for (cognitive 20) baml_language/sdks/csharp/sdkgen_csharp/src/semantic.rs:895— RenderContext::type_source_for has cognitive complexity 20 (threshold 15). Drivers by points: if/else 10 (18 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.
internal_baml_prompt_parser::parser::parse_prompt::handle_print_block (cognitive 20) engine/baml-lib/prompt-parser/src/parser/parse_prompt.rs:179— internal_baml_prompt_parser::parser::parse_prompt::handle_print_block has cognitive complexity 20 (threshold 15). Drivers by points: match/switch 6 (13 pts), loops 2 (4 pts), if/else 3 (nesting depth added 9). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own 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.
OpenAIClient::to_media_message (cognitive 20) engine/baml-runtime/src/internal/llm_client/primitive/openai/openai_client.rs:771— OpenAIClient::to_media_message has cognitive complexity 20 (threshold 15). Drivers by points: match/switch 8 (20 pts) (nesting depth added 12). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own 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.
OptimizationStorage::save_candidate (cognitive 20) engine/baml-runtime/src/optimize/storage.rs:160— OptimizationStorage::save_candidate has cognitive complexity 20 (threshold 15). Drivers by points: if/else 6 (13 pts), loops 5 (7 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.
baml_macros::encode::derive_enum_encode (cognitive 20) languages/rust/baml-macros/src/encode.rs:102— baml_macros::encode::derive_enum_encode has cognitive complexity 20 (threshold 15). Drivers by points: if/else 9 (12 pts), match/switch 2 (6 pts), boolean chains 1, 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.
generate_stubs.main (cognitive 20) baml_language/sdks/python/generate_stubs.py:20— generate_stubs.main has cognitive complexity 20 (threshold 15). Drivers by points: if/else 8 (17 pts), loops 1 (2 pts), boolean chains 1 (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.
_capture_adapters.http_summary (cognitive 20) baml_language/sdks/python/src/baml_bridge/_capture_adapters.py:57— _capture_adapters.http_summary has cognitive complexity 20 (threshold 15). Drivers by points: if/else 6 (10 pts), ternaries 3 (9 pts), boolean chains 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
proto._ty_to_python_type (cognitive 20) baml_language/sdks/python/src/baml_bridge/proto.py:886— proto._ty_to_python_type has cognitive complexity 20 (threshold 15). Drivers by points: if/else 14 (17 pts), error handling 1 (2 pts), boolean chains 1 (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
proto.decode_call_result (cognitive 20) baml_language/sdks/python/src/baml_bridge/proto.py:1481— proto.decode_call_result has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (14 pts), ternaries 2 (5 pts), boolean chains 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
kpis._value (cognitive 20) baml_language/tools/speedtest/src/speedtest/kpis.py:41— kpis._value has cognitive complexity 20 (threshold 15). Drivers by points: if/else 10 (14 pts), ternaries 2 (4 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.
main.test_ultra_complex (cognitive 20) engine/generators/data/mixed_complex_types/python/main.py:84— main.test_ultra_complex has cognitive complexity 20 (threshold 15). Drivers by points: if/else 8 (18 pts), loops 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.
smoke-go-release.main (cognitive 20) scripts/smoke-go-release.py:213— smoke-go-release.main has cognitive complexity 20 (threshold 15). Drivers by points: if/else 12 (13 pts), boolean chains 4, error handling 1, loops 1, ternaries 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.
baml_go.isJSONBAMLType (cognitive 20) baml_language/sdks/go/baml_go/json.go:340— baml_go.isJSONBAMLType has cognitive complexity 20 (threshold 15). Drivers by points: if/else 4 (8 pts), boolean chains 7, match/switch 2 (3 pts), 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.
baml_go.semanticUnionOptions (cognitive 20) baml_language/sdks/go/baml_go/value.go:406— baml_go.semanticUnionOptions has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (14 pts), loops 3 (4 pts), boolean chains 1, 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.
main.quickSort (cognitive 20) baml_language/tools/speedtest/workloads/compute/quick-sort-3way-1k/main.js:8— main.quickSort has cognitive complexity 20 (threshold 15). Drivers by points: if/else 8 (16 pts), loops 2 (4 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
index.testComplexMaps (cognitive 20) engine/generators/data/map_types/typescript/index.ts:52— index.testComplexMaps has cognitive complexity 20 (threshold 15). Drivers by points: boolean chains 10, if/else 10. 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.
index.testComplexNested (cognitive 20) engine/generators/data/nested_structures/typescript/index.ts:129— index.testComplexNested has cognitive complexity 20 (threshold 15). Drivers by points: if/else 13, boolean chains 7. Of this number, 18 points are the body's own statements and 2 belong to 5 function literals inside it that branch. 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.
render-text.HighlightedText (cognitive 20) typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/prompt-preview/render-text.tsx:32— render-text.HighlightedText has cognitive complexity 20 (threshold 15). Drivers by points: if/else 8 (11 pts), ternaries 3 (5 pts), boolean chains 3, loops 1 (nesting depth added 5). None of this is in the body itself: all 20 points belong to 5 function literals inside it that branch (lines 117, 47, 106, …). 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.
collapsible-message.CollapsibleMessage (cognitive 20) typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/prompt-preview/collapsible-message.tsx:24— collapsible-message.CollapsibleMessage has cognitive complexity 20 (threshold 15). Drivers by points: if/else 9 (13 pts), ternaries 4, boolean chains 2, loops 1 (nesting depth added 4). Most of this is not in the body itself: 3 of the 20 points are its own statements and the rest belongs to 3 function items inside it that branch (getMediaIndicator, a function literal at line 32, a function literal at line 90). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
unified-prompt-preview.UnifiedPromptPreview (cognitive 20) typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/prompt-preview/unified-prompt-preview.tsx:99— unified-prompt-preview.UnifiedPromptPreview has cognitive complexity 20 (threshold 15). Drivers by points: boolean chains 15, if/else 5. Of this number, 13 points are the body's own statements and 7 belong to 2 function items inside it that branch. 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.
decision-form.DecisionForm (cognitive 20) typescript2/app-beps/src/components/decisions/decision-form.tsx:35— decision-form.DecisionForm has cognitive complexity 20 (threshold 15). Drivers by points: boolean chains 10, if/else 4, ternaries 3, loops 1 (2 pts), error handling 1 (nesting depth added 1). Most of this is not in the body itself: 9 of the 20 points are its own statements and the rest belongs to 3 function items inside it that branch (handleSubmit, a function literal at line 62, a function literal at line 58). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
export-all-utils.generateBepReadme (cognitive 20) typescript2/app-beps/src/lib/export-all-utils.ts:350— export-all-utils.generateBepReadme has cognitive complexity 20 (threshold 15). Drivers by points: if/else 8 (11 pts), loops 4 (8 pts), boolean chains 1 (nesting depth added 7). Of this number, 16 points are the body's own statements and 4 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.
document-projector.validateLogicalLinks (cognitive 20) typescript2/app-developer-docs/lib/generated-content/document-projector.ts:366— document-projector.validateLogicalLinks has cognitive complexity 20 (threshold 15). Drivers by points: if/else 2 (7 pts), loops 3 (6 pts), ternaries 2 (6 pts), boolean chains 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
parser.parseMetadata (cognitive 20) typescript2/app-developer-docs/lib/snippets/parser.ts:33— parser.parseMetadata has cognitive complexity 20 (threshold 15). Drivers by points: if/else 8 (16 pts), ternaries 1 (2 pts), error handling 1, 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.
parser.parseBamlSource (cognitive 20) typescript2/app-developer-docs/lib/snippets/parser.ts:109— parser.parseBamlSource has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (16 pts), 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.
no-widen-then-assert.knownValueEvidence (cognitive 20) typescript2/app-developer-docs/tools/oxlint/anti-slop/rules/no-widen-then-assert.ts:200— no-widen-then-assert.knownValueEvidence has cognitive complexity 20 (threshold 15). Drivers by points: if/else 9 (11 pts), boolean chains 9 (nesting depth added 2). Of this number, 19 points are the body's own statements and 1 belongs to one function literal inside it that branches. 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.
streaming-animation.AnnotationIcon (cognitive 20) typescript2/app-website/components/landing/feature-animations/streaming-animation.tsx:176— streaming-animation.AnnotationIcon has cognitive complexity 20 (threshold 15). Drivers by points: ternaries 9 (18 pts), if/else 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.
particles.Particles (cognitive 20) typescript2/app-website/components/magicui/particles.tsx:51— particles.Particles has cognitive complexity 20 (threshold 15). Drivers by points: if/else 11 (14 pts), boolean chains 3, ternaries 2, loops 1 (nesting depth added 3). Most of this is not in the body itself: 1 of the 20 points is its own statement and the rest belongs to 8 function items inside it that branch (a function literal at line 214, onMouseMove, drawCircle, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
emit-sublime.emitSublimeSyntax::convertRule (cognitive 20) typescript2/pkg-grammar/scripts/emit-sublime.ts:232— emit-sublime.emitSublimeSyntax::convertRule has cognitive complexity 20 (threshold 15). Drivers by points: if/else 9 (14 pts), boolean chains 2, loops 1 (2 pts), ternaries 1 (2 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.
use-telemetry.useTelemetry (cognitive 20) typescript2/pkg-playground/src/telemetry/use-telemetry.ts:100— use-telemetry.useTelemetry has cognitive complexity 20 (threshold 15). Drivers by points: if/else 10, boolean chains 8, ternaries 2. None of this is in the body itself: all 20 points belong to 12 function literals inside it that branch (lines 150, 178, 134, …). 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.
ExecutionPanel.CollectionDebugView (cognitive 20) typescript2/pkg-playground/src/ExecutionPanel.tsx:369— ExecutionPanel.CollectionDebugView has cognitive complexity 20 (threshold 15). Drivers by points: ternaries 8 (11 pts), boolean chains 9 (nesting depth added 3). Most of this is not in the body itself: 6 of the 20 points are its own statements and the rest belongs to 2 function literals inside it that branch (lines 415, 429). 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.
CacheContext::collect_diagnostics_with_plan (cognitive 19) baml_language/crates/baml_cli/src/bytecode_cache.rs:1035— CacheContext::collect_diagnostics_with_plan has cognitive complexity 19 (threshold 15). Drivers by points: if/else 5 (7 pts), match/switch 3 (6 pts), loops 2 (4 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.
FloatTy::coerce (cognitive 19) baml_language/crates/bex_sap/src/deserializer/coercer/coerce_primitive.rs:441— FloatTy::coerce has cognitive complexity 19 (threshold 15). Drivers by points: if/else 13 (18 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.
Heartbeat::run_authorized (cognitive 19) baml_language/crates/btel_bcs/src/liveness.rs:192— Heartbeat::run_authorized has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (11 pts), match/switch 3 (6 pts), boolean chains 1, 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.
MermaidDiagramGenerator::render_headers_only (cognitive 19) engine/baml-lib/ast/src/ast/baml_vis/mermaid_debug.rs:869— MermaidDiagramGenerator::render_headers_only has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (15 pts), loops 4 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
BamlAsyncInterpreterRuntime::call_function (cognitive 19) engine/baml-runtime/src/async_interpreter_runtime.rs:160— BamlAsyncInterpreterRuntime::call_function has cognitive complexity 19 (threshold 15). Drivers by points: if/else 9 (12 pts), match/switch 4 (6 pts), boolean chains 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Server::baml_stream (cognitive 19) engine/baml-runtime/src/cli/serve/mod.rs:444— Server::baml_stream has cognitive complexity 19 (threshold 15). Drivers by points: match/switch 6 (13 pts), if/else 2 (6 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.
BlobUploader::run (cognitive 19) engine/baml-runtime/src/tracingv2/publisher/publisher.rs:866— BlobUploader::run has cognitive complexity 19 (threshold 15). Drivers by points: if/else 4 (13 pts), match/switch 2 (5 pts), loops 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.
generators_ruby::ir_to_rb::stream_type_to_rb (cognitive 19) engine/generators/languages/ruby/src/ir_to_rb/mod.rs:18— generators_ruby::ir_to_rb::stream_type_to_rb has cognitive complexity 19 (threshold 15). Drivers by points: if/else 4 (10 pts), match/switch 5 (9 pts) (nesting depth added 10). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
TypeTS::serialize_type (cognitive 19) engine/generators/languages/typescript/src/type.rs:151— TypeTS::serialize_type has cognitive complexity 19 (threshold 15). Drivers by points: if/else 5 (10 pts), match/switch 4 (7 pts), loops 1 (2 pts) (nesting depth added 9). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
FileCollector::remove_dir_safe (cognitive 19) engine/generators/utils/dir_writer/src/lib.rs:326— FileCollector::remove_dir_safe has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (14 pts), match/switch 2 (3 pts), boolean chains 1, 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.
playground_server::handlers::webview_rpc::webview_rpc_handler (cognitive 19) engine/playground-server/src/handlers/webview_rpc.rs:32— playground_server::handlers::webview_rpc::webview_rpc_handler has cognitive complexity 19 (threshold 15). Drivers by points: if/else 5 (11 pts), match/switch 3 (7 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.
proto.decode_value (cognitive 19) baml_language/sdks/python/src/baml_bridge/proto.py:1368— proto.decode_value has cognitive complexity 19 (threshold 15). Drivers by points: if/else 18, boolean chains 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.
main.quick_sort (cognitive 19) baml_language/tools/speedtest/workloads/compute/quick-sort-3way-1k/main.py:14— main.quick_sort has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (15 pts), loops 2 (4 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
show_rust_lints.read_workspace_members (cognitive 19) engine/tools/show_rust_lints.py:73— show_rust_lints.read_workspace_members has cognitive complexity 19 (threshold 15). Drivers by points: if/else 4 (10 pts), loops 2 (4 pts), ternaries 1 (4 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.
kpis.html.standing (cognitive 19) baml_language/tools/speedtest/src/speedtest/templates/kpis.html:99— kpis.html.standing has cognitive complexity 19 (threshold 15). Drivers by points: ternaries 11 (14 pts), boolean chains 5 (nesting depth added 3). Of this number, 10 points are the body's own statements and 9 belong to 3 function items inside it that branch. 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.
index.testMixedOptionalNullable (cognitive 19) engine/generators/data/optional_nullable/typescript/index.ts:65— index.testMixedOptionalNullable has cognitive complexity 19 (threshold 15). Drivers by points: boolean chains 10, if/else 9. 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.
elk-mermaid.buildHierarchicalElkNodes (cognitive 19) typescript/packages/playground-common/src/features/graph/layout/node/algorithms/elk-mermaid.ts:162— elk-mermaid.buildHierarchicalElkNodes has cognitive complexity 19 (threshold 15). Drivers by points: if/else 3 (7 pts), ternaries 2 (6 pts), boolean chains 5, loops 1 (nesting depth added 8). Of this number, 13 points are the body's own statements and 6 belong to 2 function literals 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.
index.GroupNode (cognitive 19) typescript/packages/playground-common/src/graph-primitives/nodes/GroupNode/index.tsx:6— index.GroupNode has cognitive complexity 19 (threshold 15). Drivers by points: ternaries 13, boolean chains 6. Of this number, 17 points are the body's own statements and 2 belong to 2 function literals inside it that branch. 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.
page.LoginContent (cognitive 19) typescript2/app-beps/src/app/login/page.tsx:30— page.LoginContent has cognitive complexity 19 (threshold 15). Drivers by points: if/else 5 (6 pts), boolean chains 5, error handling 3 (4 pts), ternaries 3 (4 pts) (nesting depth added 3). Most of this is not in the body itself: 6 of the 19 points are its own statements and the rest belongs to 3 function items inside it that branch (handlePasskeySubmit, a function literal at line 40, handleGitHubLogin). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
page.UsersPage (cognitive 19) typescript2/app-beps/src/app/users/page.tsx:147— page.UsersPage has cognitive complexity 19 (threshold 15). Drivers by points: boolean chains 8, if/else 6 (7 pts), ternaries 3, error handling 1 (nesting depth added 1). Of this number, 11 points are the body's own statements and 8 belong to 3 function items inside it that branch. 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.
app.App (cognitive 19) typescript2/app-type-quiz/src/app.tsx:574— app.App has cognitive complexity 19 (threshold 15). Drivers by points: boolean chains 9, if/else 7, error handling 2, ternaries 1. Most of this is not in the body itself: 7 of the 19 points are its own statements and the rest belongs to 9 function literals inside it that branch (lines 705, 643, 588, …). 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.
page.IssuePage (cognitive 19) typescript2/app-website/app/atb/issues/[id]/page.tsx:26— page.IssuePage has cognitive complexity 19 (threshold 15). Drivers by points: boolean chains 17, if/else 2. To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
FeedbackWidget.FeedbackForm (cognitive 19) typescript2/app-website/app/bamlcode/_components/FeedbackWidget.tsx:35— FeedbackWidget.FeedbackForm has cognitive complexity 19 (threshold 15). Drivers by points: ternaries 6 (12 pts), boolean chains 5, error handling 1, if/else 1 (nesting depth added 6). Of this number, 11 points are the body's own statements and 8 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.
rehype-preserve-code-props.rehypePreserveCodeProps (cognitive 19) typescript2/app-website/lib/mdx/rehype-preserve-code-props.ts:19— rehype-preserve-code-props.rehypePreserveCodeProps has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (9 pts), boolean chains 8, ternaries 1 (2 pts) (nesting depth added 3). Most of this is not in the body itself: 2 of the 19 points are its own statements and the rest belongs to one function literal inside it that branches (line 24). The decisions are inside the literal, 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 literal's work into a named function or method at the enclosing scope and have the literal call it, then reduce whichever part then reads as the largest.
perspective-slider.GraphPanel (cognitive 19) REDACTED:731— perspective-slider.GraphPanel has cognitive complexity 19 (threshold 15). Drivers by points: ternaries 13 (16 pts), if/else 2, boolean chains 1 (nesting depth added 3). Most of this is not in the body itself: 3 of the 19 points are its own statements and the rest belongs to 3 function items inside it that branch (a function literal at line 1006, a function literal at line 941, onPanPointerMove). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
story-timeline.EraCard (cognitive 19) typescript2/app-website/components/landing/story-timeline.tsx:60— story-timeline.EraCard has cognitive complexity 19 (threshold 15). Drivers by points: ternaries 11 (14 pts), boolean chains 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.
default-function-selection.selectLongestWorkflowFunctionName (cognitive 19) typescript2/pkg-playground/src/default-function-selection.ts:46— default-function-selection.selectLongestWorkflowFunctionName has cognitive complexity 19 (threshold 15). Drivers by points: if/else 5 (11 pts), loops 3 (4 pts), ternaries 2 (3 pts), boolean chains 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
evidence.parseErrorValue (cognitive 19) typescript2/pkg-playground/src/telemetry/evidence.ts:695— evidence.parseErrorValue has cognitive complexity 19 (threshold 15). Drivers by points: if/else 4 (9 pts), error handling 2 (6 pts), boolean chains 2, loops 1 (2 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
TelemetryView.ExecutionDetail (cognitive 19) typescript2/pkg-playground/src/telemetry/TelemetryView.tsx:725— TelemetryView.ExecutionDetail has cognitive complexity 19 (threshold 15). Drivers by points: ternaries 6 (16 pts), boolean chains 2, if/else 1 (nesting depth added 10). Of this number, 17 points are the body's own statements and 2 belong to 2 function literals inside it that branch. 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.
TelemetryView.TimingsTab (cognitive 19) typescript2/pkg-playground/src/telemetry/TelemetryView.tsx:2282— TelemetryView.TimingsTab has cognitive complexity 19 (threshold 15). Drivers by points: ternaries 7 (10 pts), boolean chains 4, if/else 4, match/switch 1 (nesting depth added 3). Most of this is not in the body itself: 5 of the 19 points are its own statements and the rest belongs to 5 function literals inside it that branch (lines 2316, 2355, 2302, …). 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.
FunctionType::try_print_single_line (cognitive 18) baml_language/crates/baml_fmt/src/ast/types.rs:1208— FunctionType::try_print_single_line has cognitive complexity 18 (threshold 15). Drivers by points: if/else 11 (17 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.
PlaygroundTelemetry::open_execution (cognitive 18) baml_language/crates/baml_lsp_server/src/playground_btel.rs:211— PlaygroundTelemetry::open_execution has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (13 pts), loops 3 (4 pts), 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.
PlaygroundHttp::_send (cognitive 18) baml_language/crates/baml_lsp_server/src/playground_http.rs:321— PlaygroundHttp::_send has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (13 pts), match/switch 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.
NativePlaygroundSender::send_playground_notification (cognitive 18) baml_language/crates/baml_lsp_server/src/playground_sender.rs:92— NativePlaygroundSender::send_playground_notification has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (17 pts), boolean chains 1 (nesting depth added 9). 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.
TypeCtx::convert_ty (cognitive 18) baml_language/crates/bex_sap/src/sap_model/convert.rs:701— TypeCtx::convert_ty has cognitive complexity 18 (threshold 15). Drivers by points: if/else 4 (10 pts), match/switch 3 (6 pts), loops 1 (2 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
MapTy::coerce (cognitive 18) baml_language/crates/bex_sap/src/deserializer/coercer/coerce_map.rs:82— MapTy::coerce has cognitive complexity 18 (threshold 15). Drivers by points: match/switch 5 (11 pts), loops 2 (4 pts), if/else 2 (3 pts) (nesting depth added 9). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own 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.
Recording::publish (cognitive 18) baml_language/crates/bex_vm/src/telemetry/manual.rs:357— Recording::publish has cognitive complexity 18 (threshold 15). Drivers by points: if/else 12 (16 pts), 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.
bridge_python::host_value::discard_host_call_args::discard (cognitive 18) baml_language/sdks/python/rust/bridge_python/src/host_value.rs:484— bridge_python::host_value::discard_host_call_args::discard has cognitive complexity 18 (threshold 15). Drivers by points: if/else 4 (10 pts), loops 3 (6 pts), boolean chains 1, 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.
LiteralValue::coerce (cognitive 18) engine/baml-lib/jsonish/src/deserializer/coercer/coerce_literal.rs:68— LiteralValue::coerce has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (13 pts), match/switch 3 (5 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
RawPtrTypeDefinitions::parse (cognitive 18) engine/baml_cffi_macros/src/lib.rs:1654— RawPtrTypeDefinitions::parse has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (13 pts), loops 2 (5 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.
profiler._collect_addresses (cognitive 18) baml_language/tools/speedtest/src/speedtest/profiler.py:36— profiler._collect_addresses has cognitive complexity 18 (threshold 15). Drivers by points: if/else 4 (10 pts), error handling 1 (4 pts), loops 2 (3 pts), boolean chains 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
main.run_conversation (cognitive 18) baml_language/tools/speedtest/workloads/programs/agent-loop-300/main.py:33— main.run_conversation has cognitive complexity 18 (threshold 15). Drivers by points: ternaries 3 (9 pts), if/else 4 (8 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.
main.test_large_structure (cognitive 18) engine/generators/data/edge_cases/python/main.py:25— main.test_large_structure has cognitive complexity 18 (threshold 15). Drivers by points: loops 8 (12 pts), if/else 4 (6 pts) (nesting depth added 6). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
baml_go.reflectedBAMLType (cognitive 18) baml_language/sdks/go/baml_go/dynamic.go:238— baml_go.reflectedBAMLType has cognitive complexity 18 (threshold 15). Drivers by points: if/else 12 (17 pts), 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.
Value.ClassWithTypeArgs (cognitive 18) baml_language/sdks/go/baml_go/class.go:90— Value.ClassWithTypeArgs has cognitive complexity 18 (threshold 15). Drivers by points: if/else 10 (15 pts), loops 2, 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.
baml_go.downloadBamlLibrary (cognitive 18) engine/language_client_go/baml_go/lib_common.go:474— baml_go.downloadBamlLibrary has cognitive complexity 18 (threshold 15). Drivers by points: if/else 15 (18 pts) (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
main.conversations (cognitive 18) baml_language/tools/speedtest/workloads/programs/agent-loop-300/main.js:50— main.conversations has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (11 pts), loops 3 (7 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.
index.testSimpleMaps (cognitive 18) engine/generators/data/map_types/typescript/index.ts:3— index.testSimpleMaps has cognitive complexity 18 (threshold 15). Drivers by points: if/else 12, boolean chains 6. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
index.testDeeplyNested (cognitive 18) engine/generators/data/nested_structures/typescript/index.ts:80— index.testDeeplyNested has cognitive complexity 18 (threshold 15). Drivers by points: if/else 12, boolean chains 6. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
edge.getPathWithRoundCorners (cognitive 18) typescript/packages/playground-common/src/features/graph/layout/edge/edge.ts:88— edge.getPathWithRoundCorners has cognitive complexity 18 (threshold 15). Drivers by points: ternaries 6 (10 pts), if/else 6 (7 pts), loops 1 (nesting depth added 5). Most of this is not in the body itself: 6 of the 18 points are its own statements and the rest belongs to one function item inside it that branches (getRoundCorner). 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.
message-handlers.handleWorkspaceCommand (cognitive 18) typescript/packages/playground-common/src/baml_wasm_web/message-handlers.ts:149— message-handlers.handleWorkspaceCommand has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (10 pts), error handling 2 (3 pts), boolean chains 2, ternaries 1 (2 pts), match/switch 1 (nesting depth added 7). Of this number, 16 points are the body's own statements and 2 belong to one function literal inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
elk-mermaid.layoutELKMermaid.edges (cognitive 18) typescript/packages/playground-common/src/features/graph/layout/node/algorithms/elk-mermaid.ts:623— elk-mermaid.layoutELKMermaid.edges has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (9 pts), boolean chains 7, ternaries 1 (2 pts) (nesting depth added 5). Of this number, 13 points are the body's own statements and 5 belong to 3 function literals 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.
a-star.getAStarPath (cognitive 18) typescript/packages/playground-common/src/features/graph/layout/edge/algorithms/a-star.ts:29— a-star.getAStarPath has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (12 pts), loops 3 (5 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.
useEdgeDraggable.useEdgeDraggable (cognitive 18) typescript/packages/playground-common/src/graph-primitives/edges/EdgeController/useEdgeDraggable.tsx:24— useEdgeDraggable.useEdgeDraggable has cognitive complexity 18 (threshold 15). Drivers by points: if/else 9 (11 pts), boolean chains 3, loops 2, ternaries 2 (nesting depth added 2). Most of this is not in the body itself: 1 of the 18 points is its own statement and the rest belongs to 6 function items inside it that branch (onDragging, onDragStart, onDragEnd, …). 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.
code-mirror-viewer.CodeMirrorViewer (cognitive 18) typescript/packages/playground-common/src/shared/baml-project-panel/codemirror-panel/code-mirror-viewer.tsx:120— code-mirror-viewer.CodeMirrorViewer has cognitive complexity 18 (threshold 15). Drivers by points: if/else 9, boolean chains 3, error handling 2 (3 pts), ternaries 3 (nesting depth added 1). Most of this is not in the body itself: 2 of the 18 points are its own statements and the rest belongs to 7 function literals inside it that branch (lines 243, 416, 147, …). 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.
webview-media.getFileFormat (cognitive 18) typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/prompt-preview/webview-media.tsx:93— webview-media.getFileFormat has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (18 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.
prompt-preview-content.PromptPreviewContent (cognitive 18) typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/prompt-preview/prompt-preview-content.tsx:18— prompt-preview-content.PromptPreviewContent has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (8 pts), ternaries 3 (6 pts), boolean chains 3, error handling 1 (nesting depth added 5). Of this number, 15 points are the body's own statements and 3 belong to one function literal inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
prompt-search-bar.PromptSearchBar (cognitive 18) typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/prompt-preview/prompt-search-bar.tsx:21— prompt-search-bar.PromptSearchBar has cognitive complexity 18 (threshold 15). Drivers by points: if/else 9 (10 pts), boolean chains 4, ternaries 2 (4 pts) (nesting depth added 3). Most of this is not in the body itself: 2 of the 18 points are its own statements and the rest belongs to 7 function items inside it that branch (a function literal at line 31, handleKeyDown, a function literal at line 51, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
issue-list.IssueList (cognitive 18) typescript2/app-feedback/src/components/issues/issue-list.tsx:110— issue-list.IssueList has cognitive complexity 18 (threshold 15). Drivers by points: ternaries 9 (12 pts), boolean chains 6 (nesting depth added 3). Most of this is not in the body itself: 8 of the 18 points are its own statements and the rest belongs to 8 function literals inside it that branch (lines 124, 125, 126, …). 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.
TenetsAccordion.TenetsAccordion (cognitive 18) typescript2/app-website/app/baml-intro/_components/TenetsAccordion.tsx:682— TenetsAccordion.TenetsAccordion has cognitive complexity 18 (threshold 15). Drivers by points: ternaries 8 (9 pts), if/else 7, loops 2 (nesting depth added 1). None of this is in the body itself: all 18 points belong to 7 function literals inside it that branch (lines 730, 704, 690, …). 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.
baml-reference.DocCard (cognitive 18) typescript2/app-website/app/bamlcode/_components/baml-reference.tsx:113— baml-reference.DocCard has cognitive complexity 18 (threshold 15). Drivers by points: ternaries 11 (16 pts), boolean chains 2 (nesting depth added 5). Of this number, 16 points are the body's own statements and 2 belong to one function literal inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
vscode.VSCodeMock (cognitive 18) typescript2/app-website/components/vscode.tsx:30— vscode.VSCodeMock has cognitive complexity 18 (threshold 15). Drivers by points: ternaries 10 (11 pts), boolean chains 7 (nesting depth added 1). Of this number, 15 points are the body's own statements and 3 belong to one function literal inside it that branches. 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.
convert-videos.findVideoFiles (cognitive 18) typescript2/app-website/scripts/convert-videos.ts:130— convert-videos.findVideoFiles has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (17 pts), ternaries 1 (nesting depth added 9). Of this number, 12 points are the body's own statements and 6 belong to one function literal inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
convert-videos.processBatch (cognitive 18) typescript2/app-website/scripts/convert-videos.ts:414— convert-videos.processBatch has cognitive complexity 18 (threshold 15). Drivers by points: ternaries 4 (10 pts), error handling 2 (4 pts), if/else 2 (3 pts), loops 1 (nesting depth added 9). Most of this is not in the body itself: 6 of the 18 points are its own statements and the rest belongs to 3 function literals inside it that branch (lines 437, 461, 470). 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.
args-form-model.defaultValue (cognitive 18) typescript2/pkg-playground/src/args-form-model.ts:145— args-form-model.defaultValue has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (10 pts), ternaries 2 (5 pts), loops 1 (2 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.
function-sidebar-tree.buildFunctionSidebarTree (cognitive 18) typescript2/pkg-playground/src/function-sidebar-tree.ts:50— function-sidebar-tree.buildFunctionSidebarTree has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (11 pts), boolean chains 4, loops 2 (3 pts) (nesting depth added 6). Of this number, 14 points are the body's own statements and 4 belong to one function literal inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
BamlValue::baml_decode (cognitive 17) languages/rust/baml/src/codec/baml_value.rs:194— BamlValue::baml_decode has cognitive complexity 17 (threshold 15). Drivers by points: match/switch 4 (7 pts), if/else 3 (6 pts), loops 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.
VcmpCidUdf::invoke_with_args (cognitive 17) baml_language/crates/baml_query/src/value/lowering.rs:735— VcmpCidUdf::invoke_with_args has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (12 pts), loops 2, match/switch 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.
TelemetryRecording::from_artifact (cognitive 17) baml_language/crates/bex_engine/src/telemetry.rs:170— TelemetryRecording::from_artifact has cognitive complexity 17 (threshold 15). Drivers by points: match/switch 6 (11 pts), if/else 4 (6 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.
bex_events::history::path::find_boundary_dir (cognitive 17) baml_language/crates/bex_events/src/history/path.rs:56— bex_events::history::path::find_boundary_dir has cognitive complexity 17 (threshold 15). Drivers by points: if/else 3 (11 pts), loops 3 (6 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.
CloudPublisher::service (cognitive 17) baml_language/crates/btel_bcs/src/publisher.rs:709— CloudPublisher::service has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (13 pts), loops 1 (2 pts), match/switch 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.
Builder::object (cognitive 17) baml_language/crates/btel_reader/src/value/equality.rs:436— Builder::object has cognitive complexity 17 (threshold 15). Drivers by points: if/else 4 (11 pts), loops 1 (3 pts), match/switch 2 (3 pts) (nesting depth added 10). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
CSharpFileRoutes::allocate_with_hashers (cognitive 17) baml_language/sdks/csharp/sdkgen_csharp/src/routing.rs:127— CSharpFileRoutes::allocate_with_hashers has cognitive complexity 17 (threshold 15). Drivers by points: loops 9 (15 pts), if/else 1 (2 pts) (nesting depth added 7). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
IRHelperExtended::distribute_type_with_meta (cognitive 17) engine/baml-lib/baml-core/src/ir/ir_helpers/mod.rs:230— IRHelperExtended::distribute_type_with_meta has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (11 pts), match/switch 2 (4 pts), boolean chains 2 (nesting depth added 6). 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.
DeliveryThread::run (cognitive 17) engine/baml-runtime/src/tracing/threaded_tracer.rs:98— DeliveryThread::run has cognitive complexity 17 (threshold 15). Drivers by points: if/else 4 (8 pts), match/switch 2 (5 pts), boolean chains 3, 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.
boundary_udf::yaml2jinja::rebuild_from_flattened (cognitive 17) engine/boundary-udf/src/yaml2jinja.rs:426— boundary_udf::yaml2jinja::rebuild_from_flattened has cognitive complexity 17 (threshold 15). Drivers by points: match/switch 5 (12 pts), if/else 2 (4 pts), loops 1 (nesting depth added 9). Of this number, 16 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. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
baml_bridge._build_type_args (cognitive 17) baml_language/sdks/python/src/baml_bridge/__init__.py:243— baml_bridge._build_type_args has cognitive complexity 17 (threshold 15). Drivers by points: ternaries 4 (9 pts), if/else 4 (5 pts), loops 1 (2 pts), boolean chains 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
profiler._count_samples (cognitive 17) baml_language/tools/speedtest/src/speedtest/profiler.py:139— profiler._count_samples has cognitive complexity 17 (threshold 15). Drivers by points: if/else 3 (10 pts), loops 3 (6 pts), boolean chains 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
cli.notify (cognitive 17) tools/bctl_src/oncall/cli.py:108— cli.notify has cognitive complexity 17 (threshold 15). Drivers by points: loops 4 (8 pts), if/else 5, ternaries 1 (3 pts), error handling 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.
BamlMedia.construct (cognitive 17) baml_language/sdks/swift/Sources/BamlBridge/Media.swift:36— BamlMedia.construct has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (13 pts), error handling 1 (2 pts), match/switch 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.
main.runConversation (cognitive 17) baml_language/tools/speedtest/workloads/programs/agent-loop-300/main.js:18— main.runConversation has cognitive complexity 17 (threshold 15). Drivers by points: if/else 5 (9 pts), ternaries 2 (7 pts), loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
index.testNestedMaps (cognitive 17) engine/generators/data/map_types/typescript/index.ts:113— index.testNestedMaps has cognitive complexity 17 (threshold 15). Drivers by points: boolean chains 9, if/else 8. 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.
index.testOptionalFields (cognitive 17) engine/generators/data/optional_nullable/typescript/index.ts:3— index.testOptionalFields has cognitive complexity 17 (threshold 15). Drivers by points: boolean chains 9, if/else 8. 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.
index.testMixedPrimitives (cognitive 17) engine/generators/data/primitive_types/typescript/index.ts:94— index.testMixedPrimitives has cognitive complexity 17 (threshold 15). Drivers by points: if/else 9, boolean chains 8. 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.
index.testComplexUnions (cognitive 17) engine/generators/data/union_types_extended/typescript/index.ts:29— index.testComplexUnions has cognitive complexity 17 (threshold 15). Drivers by points: if/else 9, boolean chains 8. 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.
index.DiamondNode (cognitive 17) typescript/packages/playground-common/src/graph-primitives/nodes/DiamondNode/index.tsx:9— index.DiamondNode has cognitive complexity 17 (threshold 15). Drivers by points: ternaries 10, boolean chains 5, if/else 2. Most of this is not in the body itself: 4 of the 17 points are its own statements and the rest belongs to 3 function items inside it that branch (getStateStyle, a function literal at line 119, a function literal at line 105). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
route.GET (cognitive 17) REDACTED:519— route.GET has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7, ternaries 3 (6 pts), error handling 3, boolean chains 1 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
comment-thread.CommentThread (cognitive 17) typescript2/app-beps/src/components/comments/comment-thread.tsx:427— comment-thread.CommentThread has cognitive complexity 17 (threshold 15). Drivers by points: boolean chains 10, if/else 4, ternaries 2, error handling 1. Most of this is not in the body itself: 8 of the 17 points are its own statements and the rest belongs to 4 function literals inside it that branch (lines 453, 483, 479, …). 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.
export-utils.generateReadme (cognitive 17) typescript2/app-beps/src/lib/export-utils.ts:323— export-utils.generateReadme has cognitive complexity 17 (threshold 15). Drivers by points: if/else 5 (8 pts), loops 4 (8 pts), boolean chains 1 (nesting depth added 7). Of this number, 13 points are the body's own statements and 4 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.
export-utils.generateAgentContext (cognitive 17) typescript2/app-beps/src/lib/export-utils.ts:883— export-utils.generateAgentContext has cognitive complexity 17 (threshold 15). Drivers by points: ternaries 10 (12 pts), boolean chains 5 (nesting depth added 2). Of this number, 9 points are the body's own statements and 8 belong to 6 function literals inside it that branch. 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.
generated-cli.CliCommandContent (cognitive 17) typescript2/app-developer-docs/components/generated-cli.tsx:43— generated-cli.CliCommandContent has cognitive complexity 17 (threshold 15). Drivers by points: ternaries 10 (17 pts) (nesting depth added 7). Most of this is not in the body itself: 3 of the 17 points are its own statements and the rest belongs to 2 function literals inside it that branch (lines 70, 95). 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.
fetch-luma-eap.listEvents (cognitive 17) typescript2/app-product-metrics/src/jobs/fetch-luma-eap.ts:99— fetch-luma-eap.listEvents has cognitive complexity 17 (threshold 15). Drivers by points: if/else 4 (11 pts), boolean chains 3, loops 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.
send-slack-report.captureDashboardOnce (cognitive 17) typescript2/app-product-metrics/src/jobs/send-slack-report.ts:204— send-slack-report.captureDashboardOnce has cognitive complexity 17 (threshold 15). Drivers by points: if/else 9 (12 pts), ternaries 1 (2 pts), boolean chains 1, error handling 1, loops 1 (nesting depth added 4). Of this number, 12 points are the body's own statements and 5 belong to one function literal inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
route.POST (cognitive 17) REDACTED:6— route.POST has cognitive complexity 17 (threshold 15). Drivers by points: if/else 9 (12 pts), boolean chains 3, 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.
ProblemsBoard.ProblemsBoard (cognitive 17) typescript2/app-website/app/bamlcode/_components/ProblemsBoard.tsx:36— ProblemsBoard.ProblemsBoard has cognitive complexity 17 (threshold 15). Drivers by points: ternaries 8, boolean chains 4, if/else 4, loops 1. Most of this is not in the body itself: 2 of the 17 points are its own statements and the rest belongs to 8 function literals inside it that branch (lines 51, 119, 42, …). 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.
rehype-highlight-code.rehypeHighlightCode (cognitive 17) typescript2/app-website/lib/mdx/rehype-highlight-code.ts:14— rehype-highlight-code.rehypeHighlightCode has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (9 pts), boolean chains 5, ternaries 2, loops 1 (nesting depth added 2). None of this is in the body itself: all 17 points belong to 4 function literals inside it that branch (lines 22, 14, 30, …). 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.
new-post.generatePost (cognitive 17) typescript2/app-website/scripts/new-post.ts:475— new-post.generatePost has cognitive complexity 17 (threshold 15). Drivers by points: ternaries 10 (11 pts), if/else 3 (4 pts), boolean chains 1, error handling 1 (nesting depth added 2). Of this number, 12 points are the body's own statements and 5 belong to 4 function literals inside it that branch. 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.
FunctionSidebar.FunctionSidebar (cognitive 17) typescript2/pkg-playground/src/FunctionSidebar.tsx:431— FunctionSidebar.FunctionSidebar has cognitive complexity 17 (threshold 15). Drivers by points: boolean chains 11, ternaries 4, if/else 2. Of this number, 16 points are the body's own statements and 1 belongs to 2 function literals inside it that branch. 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.
run-await.awaitRunCompletion (cognitive 17) typescript2/pkg-playground/src/run-await.ts:36— run-await.awaitRunCompletion has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (10 pts), boolean chains 4, error handling 1 (2 pts), 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.
NativeCallbacks.OnResult (cognitive 16) baml_language/sdks/csharp/bridge_csharp/src/Cffi/NativeCallbacks.cs:72— NativeCallbacks.OnResult has cognitive complexity 16 (threshold 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.
PrimitiveProtocol.DecodeStreamPull (cognitive 16) baml_language/sdks/csharp/bridge_csharp/src/Proto/PrimitiveProtocol.cs:330— PrimitiveProtocol.DecodeStreamPull has cognitive complexity 16 (threshold 15). 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.
BamlValue.From (cognitive 16) baml_language/sdks/csharp/bridge_csharp/src/Values/BamlValue.cs:226— BamlValue.From has cognitive complexity 16 (threshold 15). 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.
BamlValue.TryGet (cognitive 16) baml_language/sdks/csharp/bridge_csharp/src/Values/BamlValue.cs:309— BamlValue.TryGet has cognitive complexity 16 (threshold 15). 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.
ArrayInitializer::try_print_single_line (cognitive 16) baml_language/crates/baml_fmt/src/ast/expressions.rs:4001— ArrayInitializer::try_print_single_line has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (15 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.
ObjectInitializer::try_print_single_line (cognitive 16) baml_language/crates/baml_fmt/src/ast/expressions.rs:4232— ObjectInitializer::try_print_single_line has cognitive complexity 16 (threshold 15). Drivers by points: if/else 10 (15 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.
ValueVisitor::visit_map (cognitive 16) baml_language/crates/bex_sap/src/jsonish/value.rs:372— ValueVisitor::visit_map has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (15 pts), loops 1 (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.
TypeValue::try_cast (cognitive 16) engine/baml-lib/jsonish/src/deserializer/coercer/coerce_primitive.rs:47— TypeValue::try_cast has cognitive complexity 16 (threshold 15). Drivers by points: match/switch 8 (14 pts), if/else 2 (nesting depth added 6). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own 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.
BoolTy::coerce (cognitive 16) baml_language/crates/bex_sap/src/deserializer/coercer/coerce_primitive.rs:553— BoolTy::coerce has cognitive complexity 16 (threshold 15). Drivers by points: match/switch 4 (10 pts), if/else 3 (6 pts) (nesting depth added 9). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own 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.
PromptAssembly::finish (cognitive 16) baml_language/crates/bex_vm/src/package_baml/prompt.rs:240— PromptAssembly::finish has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (12 pts), boolean chains 2, loops 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.
SwitchDispatch::hashed (cognitive 16) baml_language/crates/bex_vm_types/src/bytecode.rs:249— SwitchDispatch::hashed has cognitive complexity 16 (threshold 15). Drivers by points: loops 4 (10 pts), if/else 2 (5 pts), boolean chains 1 (nesting depth added 9). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
RecordingBuilder::seal (cognitive 16) baml_language/crates/btel_recorder/src/recording.rs:226— RecordingBuilder::seal has cognitive complexity 16 (threshold 15). Drivers by points: if/else 13 (14 pts), match/switch 2 (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.
forked_aws_config::profile::load_profiles (cognitive 16) baml_language/forks/aws-config/src/profile.rs:57— forked_aws_config::profile::load_profiles has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (10 pts), loops 2 (6 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.
MermaidGeneratorContext::render_mermaid_graph::emit (cognitive 16) engine/baml-lib/ast/src/ast/baml_vis/diagram_generator.rs:95— MermaidGeneratorContext::render_mermaid_graph::emit has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (8 pts), loops 2 (4 pts), match/switch 1 (3 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.
Stmt::fmt (cognitive 16) engine/baml-lib/ast/src/ast/stmt.rs:192— Stmt::fmt has cognitive complexity 16 (threshold 15). Drivers by points: if/else 9 (15 pts), match/switch 1 (nesting depth added 6). 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.
Expr::temporary_same_state (cognitive 16) engine/baml-lib/baml-types/src/expr.rs:337— Expr::temporary_same_state has cognitive complexity 16 (threshold 15). Drivers by points: boolean chains 11, match/switch 3 (5 pts) (nesting depth added 2). 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.
Resolvable::fmt (cognitive 16) engine/baml-lib/baml-types/src/value_expr.rs:381— Resolvable::fmt has cognitive complexity 16 (threshold 15). Drivers by points: if/else 3 (9 pts), loops 3 (6 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.
UnresolvedRolesSelection::resolve (cognitive 16) engine/baml-lib/llm-client/src/clientspec.rs:325— UnresolvedRolesSelection::resolve has cognitive complexity 16 (threshold 15). Drivers by points: if/else 3 (8 pts), loops 2 (4 pts), match/switch 3 (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.
App::try_reload (cognitive 16) engine/baml-runtime/src/optimize/tui.rs:220— App::try_reload has cognitive complexity 16 (threshold 15). Drivers by points: if/else 10 (13 pts), loops 2 (3 pts) (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
TypeBuilder::fmt (cognitive 16) engine/baml-runtime/src/type_builder/mod.rs:382— TypeBuilder::fmt has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (12 pts), loops 2 (4 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
WasmFunction::run_test_with_expr_events (cognitive 16) engine/baml-schema-wasm/src/runtime_wasm/mod.rs:2625— WasmFunction::run_test_with_expr_events has cognitive complexity 16 (threshold 15). Drivers by points: match/switch 4 (8 pts), if/else 5, loops 3 (nesting depth added 4). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own 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.
ProtoReader.armMatchesValue (cognitive 16) baml_language/sdks/java/baml_bridge/src/main/java/baml_bridge/internal/ProtoReader.java:1415— ProtoReader.armMatchesValue has cognitive complexity 16 (threshold 15). Drivers by points: boolean chains 9, if/else 3 (5 pts), loops 1 (2 pts) (nesting depth added 3). 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.
ProtoReader.selfTypeArms (cognitive 16) baml_language/sdks/java/baml_bridge/src/main/java/baml_bridge/internal/ProtoReader.java:810— ProtoReader.selfTypeArms has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (12 pts), loops 2 (4 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
cli.check (cognitive 16) tools/bctl_src/oncall/cli.py:48— cli.check has cognitive complexity 16 (threshold 15). Drivers by points: ternaries 2 (6 pts), if/else 5, loops 2 (4 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.
parser._emit_body (cognitive 16) tools/bctl_src/oncall/parser.py:221— parser._emit_body has cognitive complexity 16 (threshold 15). Drivers by points: loops 7 (10 pts), if/else 2 (6 pts) (nesting depth added 7). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
bump-version.main (cognitive 16) tools/bump-version.py:86— bump-version.main has cognitive complexity 16 (threshold 15). Drivers by points: if/else 12 (15 pts), ternaries 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.
notify-release-failure.main (cognitive 16) tools/notify-release-failure.py:169— notify-release-failure.main has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (7 pts), boolean chains 3, error handling 3, ternaries 2 (3 pts) (nesting depth added 3). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
btel_query_smoke.main (cognitive 16) baml_language/tools/btel_query_smoke.py:264— btel_query_smoke.main has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (6 pts), boolean chains 4, loops 3, ternaries 2, error handling 1 (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.
index.testNumberEdgeCases (cognitive 16) engine/generators/data/edge_cases/typescript/index.ts:170— index.testNumberEdgeCases has cognitive complexity 16 (threshold 15). Drivers by points: if/else 10, boolean chains 6. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
BamlRuntime.getBAMLFiles (cognitive 16) typescript/packages/playground-common/src/sdk/runtime/BamlRuntime.ts:717— BamlRuntime.getBAMLFiles has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (8 pts), boolean chains 3, loops 2, ternaries 1 (2 pts), error handling 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.
route.POST (cognitive 16) REDACTED:95— route.POST has cognitive complexity 16 (threshold 15). Drivers by points: if/else 9, ternaries 2 (3 pts), boolean chains 2, error handling 2 (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.
route.GET (cognitive 16) typescript2/app-beps/src/app/api/auth/github/callback/route.ts:53— route.GET has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (8 pts), boolean chains 5, error handling 2, ternaries 1 (nesting depth added 1). Of this number, 15 points are the body's own statements and 1 belongs to one function literal inside it that branches. 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.
bep-user-stance.BepUserStance (cognitive 16) typescript2/app-beps/src/components/bep/bep-user-stance.tsx:59— bep-user-stance.BepUserStance has cognitive complexity 16 (threshold 15). Drivers by points: boolean chains 13, error handling 1, if/else 1, ternaries 1. Of this number, 12 points are the body's own statements and 4 belong to 4 function items inside it that branch. 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.
issue-form.IssueForm (cognitive 16) typescript2/app-beps/src/components/issues/issue-form.tsx:34— issue-form.IssueForm has cognitive complexity 16 (threshold 15). Drivers by points: boolean chains 8, if/else 3, ternaries 3, error handling 1, loops 1. Of this number, 8 points are the body's own statements and 8 belong to 3 function items inside it that branch. 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.
heading-utils.extractHeadings (cognitive 16) typescript2/app-beps/src/lib/heading-utils.ts:39— heading-utils.extractHeadings has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (13 pts), ternaries 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.
generated-version-switcher.GeneratedVersionSwitcher (cognitive 16) typescript2/app-developer-docs/components/generated-version-switcher.tsx:20— generated-version-switcher.GeneratedVersionSwitcher has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (7 pts), ternaries 4 (6 pts), boolean chains 2, error handling 1 (nesting depth added 3). Most of this is not in the body itself: 2 of the 16 points are its own statements and the rest belongs to 6 function items inside it that branch (openMenu, a function literal at line 41, a function literal at line 103, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
issue-detail.IssueDetail (cognitive 16) typescript2/app-feedback/src/components/issues/issue-detail.tsx:64— issue-detail.IssueDetail has cognitive complexity 16 (threshold 15). Drivers by points: boolean chains 12, ternaries 4. 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.
discord.loadGuildMemberCounts (cognitive 16) typescript2/app-product-metrics/src/clients/discord.ts:51— discord.loadGuildMemberCounts has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (12 pts), loops 2 (3 pts), boolean chains 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
fetch-zoom-six-weeks.lumaEvents (cognitive 16) typescript2/app-product-metrics/scripts/fetch-zoom-six-weeks.ts:69— fetch-zoom-six-weeks.lumaEvents has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (10 pts), boolean chains 3, 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.
PlaygroundProvider.loadPersistedFiles (cognitive 16) typescript2/app-promptfiddle/src/playground/PlaygroundProvider.tsx:41— PlaygroundProvider.loadPersistedFiles has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (11 pts), boolean chains 3, error handling 2 (nesting depth added 3). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
app.Reveal (cognitive 16) typescript2/app-type-quiz/src/app.tsx:274— app.Reveal has cognitive complexity 16 (threshold 15). Drivers by points: boolean chains 9, ternaries 3 (4 pts), if/else 2, error handling 1 (nesting depth added 1). Of this number, 9 points are the body's own statements and 7 belong to 4 function literals inside it that branch. 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.
terminal.TermBlock (cognitive 16) typescript2/app-website/app/atb/_components/terminal.tsx:124— terminal.TermBlock has cognitive complexity 16 (threshold 15). Drivers by points: ternaries 5 (9 pts), boolean chains 6, loops 1 (nesting depth added 4). Of this number, 14 points are the body's own statements and 2 belong to 2 function literals 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.
baml-editor.registerLensProvider (cognitive 16) typescript2/app-website/app/learn2/_editor/baml-editor.tsx:119— baml-editor.registerLensProvider has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8, ternaries 5, boolean chains 3. Most of this is not in the body itself: 1 of the 16 points is its own statement and the rest belongs to 8 function literals inside it that branch (lines 125, 173, 259, …). 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.
lost-events.Field (cognitive 16) typescript2/app-website/app/what-is-baml/_components/lost-events.tsx:33— lost-events.Field has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (8 pts), ternaries 4 (5 pts), loops 2 (3 pts) (nesting depth added 4). Most of this is not in the body itself: 2 of the 16 points are its own statements and the rest belongs to 4 function literals inside it that branch (lines 55, 42, 84, …). 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.
perspective-slider.CompactPerspectivePanel (cognitive 16) REDACTED:1087— perspective-slider.CompactPerspectivePanel has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8, ternaries 5, boolean chains 3. Most of this is not in the body itself: 7 of the 16 points are its own statements and the rest belongs to 3 function items inside it that branch (onKeyDown, a function literal at line 1093, a function literal at line 1117). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
scroll-video.ScrollVideo (cognitive 16) typescript2/app-website/components/landing/scroll-video.tsx:11— scroll-video.ScrollVideo has cognitive complexity 16 (threshold 15). Drivers by points: if/else 12, error handling 1 (2 pts), boolean chains 1, ternaries 1 (nesting depth added 1). Most of this is not in the body itself: 1 of the 16 points is its own statement and the rest belongs to 5 function literals inside it that branch (lines 37, 21, 65, …). 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.
project-label.projectLabels (cognitive 16) typescript2/pkg-playground/src/project-label.ts:98— project-label.projectLabels has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (8 pts), loops 3 (4 pts), boolean chains 2, ternaries 1 (2 pts) (nesting depth added 6). Of this number, 13 points are the body's own statements and 3 belong to one function literal inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
TelemetryView.ContextTreeRows (cognitive 16) typescript2/pkg-playground/src/telemetry/TelemetryView.tsx:2985— TelemetryView.ContextTreeRows has cognitive complexity 16 (threshold 15). Drivers by points: boolean chains 8, ternaries 6 (7 pts), if/else 1 (nesting depth added 1). Of this number, 15 points are the body's own statements and 1 belongs to one function literal inside it that branches. 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.
D4 · Code Duplication· Near-duplicate member family (6 members, 25 shared lines) · ×1
Near-duplicate member family (6 members, 25 shared lines) baml_language/crates/baml_fmt/src/ast/attributes.rs:383— baml_language/crates/baml_fmt/src/ast/attributes.rs:383-430 | baml_language/crates/baml_fmt/src/ast/declarations.rs:2941-2991 | baml_language/crates/baml_fmt/src/ast/expressions.rs:3044-3091 | baml_language/crates/baml_fmt/src/ast/expressions.rs:4232-4289 | baml_language/crates/baml_fmt/src/ast/expressions.rs:4520-4594 | baml_language/crates/baml_fmt/src/ast/types.rs:1208-1273 — These 6 members are variants of one another: a block of 25 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
D4 · Code Duplication· Near-duplicate member family (5 members, 15 shared lines) · ×1
Near-duplicate member family (5 members, 15 shared lines) engine/baml_cffi_macros/src/lib.rs:912— engine/baml_cffi_macros/src/lib.rs:912-944 | engine/baml_cffi_macros/src/lib.rs:975-1007 | engine/baml_cffi_macros/src/lib.rs:1009-1041 | engine/baml_cffi_macros/src/lib.rs:1043-1092 | engine/baml_cffi_macros/src/lib.rs:1094-1126 — These 5 members are variants of one another: a block of 15 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
D4 · Code Duplication· Near-duplicate member family (4 members, 22 shared lines) · ×1
Near-duplicate member family (4 members, 22 shared lines) engine/generators/languages/go/src/ir_to_go/mod.rs:18— engine/generators/languages/go/src/ir_to_go/mod.rs:18-200 | engine/generators/languages/go/src/ir_to_go/mod.rs:202-325 | engine/generators/languages/rust/src/ir_to_rust/mod.rs:28-218 | engine/generators/languages/rust/src/ir_to_rust/mod.rs:224-355 — These 4 members are variants of one another: a block of 22 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
Near-duplicate member pair (169 shared lines) baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs:186— baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs:186-374 | engine/baml-lib/jsonish/src/jsonish/parser/fixing_parser/json_parse_state.rs:214-401 — These two members are variants of one another: 169 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Near-duplicate member pair (90 shared lines) engine/baml-runtime/src/internal/llm_client/orchestrator/call.rs:61— engine/baml-runtime/src/internal/llm_client/orchestrator/call.rs:61-190 | engine/baml-runtime/src/internal/llm_client/orchestrator/stream.rs:173-546 — These two members are variants of one another: 90 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Near-duplicate member pair (88 shared lines) baml_language/crates/baml_compiler2_mir/src/lower.rs:4970— baml_language/crates/baml_compiler2_mir/src/lower.rs:4970-5305 | baml_language/crates/baml_compiler2_mir/src/lower.rs:5527-5813 — These two members are variants of one another: 88 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Near-duplicate member pair (80 shared lines) baml_language/crates/bridge_wasm/src/runs.rs:643— baml_language/crates/bridge_wasm/src/runs.rs:643-751 | baml_language/crates/bridge_wasm/src/runs.rs:763-872 — 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.
Near-duplicate member pair (78 shared lines) engine/baml-lib/baml-core/src/validate/validation_pipeline/validations/functions.rs:12— engine/baml-lib/baml-core/src/validate/validation_pipeline/validations/functions.rs:12-149 | engine/baml-lib/baml-core/src/validate/validation_pipeline/validations/template_strings.rs:9-119 — These two members are variants of one another: 78 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Near-duplicate member pair (69 shared lines) baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs:383— baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs:383-487 | engine/baml-lib/jsonish/src/jsonish/parser/fixing_parser/json_parse_state.rs:410-517 — These two members are variants of one another: 69 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Near-duplicate member pair (65 shared lines) engine/generators/languages/python/src/watchers.rs:147— engine/generators/languages/python/src/watchers.rs:147-241 | engine/generators/languages/typescript/src/watchers.rs:143-229 — These two members are variants of one another: 65 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Near-duplicate member pair (58 shared lines) baml_language/crates/baml_builtins2_codegen/src/codegen_io.rs:1547— baml_language/crates/baml_builtins2_codegen/src/codegen_io.rs:1547-1708 | baml_language/crates/baml_builtins2_codegen/src/codegen_io.rs:1932-2081 — These two members are variants of one another: 58 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Near-duplicate member pair (57 shared lines) baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:6930— baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:6930-7173 | baml_language/crates/baml_compiler2_hir_ty/src/infer.rs:10006-10177 — These two members are variants of one another: 57 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Near-duplicate member pair (56 shared lines) engine/baml-lib/baml-types/src/baml_value.rs:108— engine/baml-lib/baml-types/src/baml_value.rs:108-179 | engine/baml-lib/baml-types/src/baml_value.rs:905-978 — These two members are variants of one another: 56 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Near-duplicate member pair (55 shared lines) baml_language/crates/bridge_ctypes/src/value_encode.rs:26— baml_language/crates/bridge_ctypes/src/value_encode.rs:26-225 | baml_language/crates/bridge_ctypes/src/value_encode.rs:243-386 — These two members are variants of one another: 55 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Near-duplicate member pair (49 shared lines) baml_language/sdks/csharp/sdkgen_csharp/src/semantic.rs:3737— baml_language/sdks/csharp/sdkgen_csharp/src/semantic.rs:3737-3856 | baml_language/sdks/csharp/sdkgen_csharp/src/semantic.rs:3858-3991 — These two members are variants of one another: 49 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Near-duplicate member pair (36 shared lines) baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs:735— baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs:735-856 | engine/baml-lib/jsonish/src/jsonish/parser/fixing_parser/json_parse_state.rs:769-898 — These two members are variants of one another: 36 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Near-duplicate member pair (31 shared lines) engine/generators/languages/python/src/ir_to_py/mod.rs:17— engine/generators/languages/python/src/ir_to_py/mod.rs:17-133 | engine/generators/languages/python/src/ir_to_py/mod.rs:135-220 — These two members are variants of one another: 31 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Near-duplicate member pair (23 shared lines) baml_language/crates/bridge_wasm/src/wasm_env.rs:68— baml_language/crates/bridge_wasm/src/wasm_env.rs:68-136 | baml_language/crates/bridge_wasm/src/wasm_io.rs:89-156 — These two members are variants of one another: 23 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Near-duplicate member pair (21 shared lines) engine/baml-lib/jsonish/src/deserializer/coercer/coerce_primitive.rs:189— engine/baml-lib/jsonish/src/deserializer/coercer/coerce_primitive.rs:189-247 | engine/baml-lib/jsonish/src/deserializer/coercer/coerce_primitive.rs:285-341 — These two members are variants of one another: 21 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication· Edited copy of a member (33 corresponding lines) · ×1
Edited copy of a member (33 corresponding lines) baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs:126— baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs:126-163 | baml_language/crates/baml_type/src/unify.rs:287-344 — These two members are one piece of code written twice and then edited apart: 33 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (34 corresponding lines) · ×1
Edited copy of a member (34 corresponding lines) baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs:729— baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs:729-765 | baml_language/crates/baml_type/src/unify.rs:1258-1314 — These two members are one piece of code written twice and then edited apart: 34 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (61 corresponding lines) · ×1
Edited copy of a member (61 corresponding lines) engine/baml-lib/baml-core/src/ir/ir_helpers/mod.rs:816— engine/baml-lib/baml-core/src/ir/ir_helpers/mod.rs:816-880 | engine/baml-lib/baml-core/src/ir/ir_helpers/mod.rs:882-947 — These two members are one piece of code written twice and then edited apart: 61 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (32 corresponding lines) · ×1
Edited copy of a member (32 corresponding lines) baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:4103— baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:4103-4139 | baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:4188-4224 — These two members are one piece of code written twice and then edited apart: 32 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (23 corresponding lines) · ×1
Edited copy of a member (23 corresponding lines) baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:2654— baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:2654-2690 | baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:6032-6065 — These two members are one piece of code written twice and then edited apart: 23 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (20 corresponding lines) · ×1
Edited copy of a member (20 corresponding lines) baml_language/crates/bex_vm/src/package_reflect/reflect.rs:486— baml_language/crates/bex_vm/src/package_reflect/reflect.rs:486-512 | baml_language/crates/bex_vm/src/type_context.rs:65-95 — These two members are one piece of code written twice and then edited apart: 20 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (7 corresponding lines) · ×1
Edited copy of a member (7 corresponding lines) engine/baml-lib/ast/src/ast/expression.rs:369— engine/baml-lib/ast/src/ast/expression.rs:369-379 | engine/baml-lib/ast/src/ast/expression.rs:381-390 — These two members are one piece of code written twice and then edited apart: 7 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Members sharing a duplicated core (8 members, 50+ identical tokens) · ×1
Members sharing a duplicated core (8 members, 50+ identical tokens) baml_language/crates/baml_compiler2_visualization/src/control_flow/from_ast.rs:302— baml_language/crates/baml_compiler2_visualization/src/control_flow/from_ast.rs:302-376 | baml_language/crates/baml_compiler2_visualization/src/control_flow/from_ast.rs:378-413 | baml_language/crates/baml_compiler2_visualization/src/control_flow/from_ast.rs:415-444 | baml_language/crates/baml_compiler2_visualization/src/control_flow/from_ast.rs:453-497 | baml_language/crates/baml_compiler2_visualization/src/control_flow/from_ast.rs:516-551 | engine/baml-runtime/src/control_flow.rs:597-667 | engine/baml-runtime/src/control_flow.rs:669-703 | engine/baml-runtime/src/control_flow.rs:705-740 — These 8 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 8 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 8 times.
Duplicated block (141 lines × 2) baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs:585— baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs:585-725 | engine/baml-lib/jsonish/src/jsonish/parser/fixing_parser/json_parse_state.rs:620-760 — before extracting anything, compare `baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs` and `engine/baml-lib/jsonish/src/jsonish/parser/fixing_parser/json_parse_state.rs` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 575 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, 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 (92–96 lines × 2) baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs:259— baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs:259-354 | engine/baml-lib/jsonish/src/jsonish/parser/fixing_parser/json_parse_state.rs:289-380 — before extracting anything, compare `baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs` and `engine/baml-lib/jsonish/src/jsonish/parser/fixing_parser/json_parse_state.rs` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 575 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, 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 (85 lines × 2) engine/baml-schema-wasm/src/runtime_wasm/mod.rs:1487— engine/baml-schema-wasm/src/runtime_wasm/mod.rs:1487-1571 | engine/language_server/src/baml_project/mod.rs:887-971 — before extracting anything, compare `engine/baml-schema-wasm/src/runtime_wasm/mod.rs` and `engine/language_server/src/baml_project/mod.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 125 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (62–69 lines × 2) baml_language/sdks/csharp/bridge_csharp/src/Cffi/NativeApi.cs:128— baml_language/sdks/csharp/bridge_csharp/src/Cffi/NativeApi.cs:128-196 | baml_language/sdks/csharp/bridge_csharp/src/Cffi/NativeApi.cs:209-270 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `baml_language/sdks/csharp/bridge_csharp/src/Cffi/NativeApi.cs:128` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (44–66 lines × 2) baml_language/crates/baml_compiler2_mir/src/lower.rs:5229— baml_language/crates/baml_compiler2_mir/src/lower.rs:5229-5294 | baml_language/crates/baml_compiler2_mir/src/lower.rs:5758-5801 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (62 lines × 2) baml_language/crates/bex_sap/src/jsonish/parser/dedent.rs:8— baml_language/crates/bex_sap/src/jsonish/parser/dedent.rs:8-69 | engine/bstd/src/dedent.rs:7-68 — 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 (59 lines × 2) baml_language/crates/bex_sap/src/deserializer/deserialize_flags.rs:181— baml_language/crates/bex_sap/src/deserializer/deserialize_flags.rs:181-239 | engine/baml-lib/jsonish/src/deserializer/deserialize_flags.rs:190-248 — before extracting anything, compare `baml_language/crates/bex_sap/src/deserializer/deserialize_flags.rs` and `engine/baml-lib/jsonish/src/deserializer/deserialize_flags.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 127 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, 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 (58 lines × 2) baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs:290— baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs:290-347 | baml_language/crates/baml_type/src/unify.rs:602-659 — before extracting anything, compare `baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs` and `baml_language/crates/baml_type/src/unify.rs` as WHOLE FILES: this scan already matched 21 separate duplicated blocks between them, totalling at least 418 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, 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 (57 lines × 3) engine/baml-lib/baml-types/src/baml_value.rs:555— engine/baml-lib/baml-types/src/baml_value.rs:555-611 | engine/baml-lib/baml-types/src/baml_value.rs:694-750 | engine/baml-lib/baml-types/src/baml_value.rs:830-886 — 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 (48–50 lines × 2) baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs:626— baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs:626-673 | baml_language/crates/baml_type/src/unify.rs:1152-1201 — before extracting anything, compare `baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs` and `baml_language/crates/baml_type/src/unify.rs` as WHOLE FILES: this scan already matched 21 separate duplicated blocks between them, totalling at least 418 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, 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 (49 lines × 2) baml_language/crates/bex_events/src/history/mod.rs:747— baml_language/crates/bex_events/src/history/mod.rs:747-795 | baml_language/crates/bex_events/src/run.rs:1570-1618 — 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 (43–48 lines × 2) baml_language/crates/baml_compiler2_ast/src/lower_cst.rs:2165— baml_language/crates/baml_compiler2_ast/src/lower_cst.rs:2165-2212 | baml_language/crates/baml_compiler2_ast/src/lower_cst.rs:2239-2281 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (47 lines × 2) baml_language/sdks/python/rust/sdkgen_python_pydantic2/src/leaf.rs:308— baml_language/sdks/python/rust/sdkgen_python_pydantic2/src/leaf.rs:308-354 | baml_language/sdks/python/rust/sdkgen_python_pydantic2/src/leaf.rs:404-450 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (45 lines × 3) engine/baml-lib/baml-core/src/ir/ir_helpers/mod.rs:770— engine/baml-lib/baml-core/src/ir/ir_helpers/mod.rs:770-814 | engine/baml-lib/baml-core/src/ir/ir_helpers/mod.rs:836-880 | engine/baml-lib/baml-core/src/ir/ir_helpers/mod.rs:903-947 — 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 (34–45 lines × 2) baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs:256— baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs:256-289 | baml_language/crates/baml_type/src/unify.rs:557-601 — before extracting anything, compare `baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs` and `baml_language/crates/baml_type/src/unify.rs` as WHOLE FILES: this scan already matched 21 separate duplicated blocks between them, totalling at least 418 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, 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 (45 lines × 2) baml_language/crates/baml_compiler2_mir/src/optimize.rs:155— baml_language/crates/baml_compiler2_mir/src/optimize.rs:155-199 | baml_language/crates/baml_compiler2_mir/src/optimize.rs:227-271 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (44–45 lines × 2) baml_language/crates/baml_fmt/src/ast/pattern.rs:947— baml_language/crates/baml_fmt/src/ast/pattern.rs:947-990 | baml_language/crates/baml_fmt/src/ast/types.rs:373-417 — before extracting anything, compare `baml_language/crates/baml_fmt/src/ast/pattern.rs` and `baml_language/crates/baml_fmt/src/ast/types.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 55 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the 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 (43 lines × 2) engine/generators/languages/go/src/ir_to_go/mod.rs:158— engine/generators/languages/go/src/ir_to_go/mod.rs:158-200 | engine/generators/languages/rust/src/ir_to_rust/mod.rs:176-218 — before extracting anything, compare `engine/generators/languages/go/src/ir_to_go/mod.rs` and `engine/generators/languages/rust/src/ir_to_rust/mod.rs` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 208 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, 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 (42 lines × 2) baml_language/crates/baml_compiler2_visualization/src/control_flow/mod.rs:397— baml_language/crates/baml_compiler2_visualization/src/control_flow/mod.rs:397-438 | engine/baml-runtime/src/control_flow.rs:936-977 — before extracting anything, compare `baml_language/crates/baml_compiler2_visualization/src/control_flow/mod.rs` and `engine/baml-runtime/src/control_flow.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 94 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, 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 (31–40 lines × 2) baml_language/crates/baml_compiler2_hir_ty/src/lower.rs:839— baml_language/crates/baml_compiler2_hir_ty/src/lower.rs:839-869 | baml_language/crates/baml_compiler2_hir_ty/src/lower.rs:950-989 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (39–40 lines × 2) engine/baml-lib/baml-core/src/validate/validation_pipeline/validations/functions.rs:83— engine/baml-lib/baml-core/src/validate/validation_pipeline/validations/functions.rs:83-121 | engine/baml-lib/baml-core/src/validate/validation_pipeline/validations/template_strings.rs:52-91 — before extracting anything, compare `engine/baml-lib/baml-core/src/validate/validation_pipeline/validations/functions.rs` and `engine/baml-lib/baml-core/src/validate/validation_pipeline/validations/template_strings.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 89 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the 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 (38 lines × 2) engine/baml-compiler/src/watch.rs:257— engine/baml-compiler/src/watch.rs:257-294 | engine/baml-compiler/src/watch.rs:306-343 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (36 lines × 2) engine/baml-runtime/src/internal/llm_client/orchestrator/mod.rs:206— engine/baml-runtime/src/internal/llm_client/orchestrator/mod.rs:206-241 | engine/baml-runtime/src/internal/llm_client/orchestrator/mod.rs:268-303 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (32–35 lines × 4) baml_language/crates/baml_compiler2_mir/src/lower.rs:8998— baml_language/crates/baml_compiler2_mir/src/lower.rs:8998-9032 | baml_language/crates/baml_compiler2_mir/src/lower.rs:9081-9115 | baml_language/crates/baml_compiler2_mir/src/lower.rs:9142-9176 | baml_language/crates/baml_compiler2_mir/src/lower.rs:9246-9277 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (32–35 lines × 2) baml_language/crates/baml_compiler2_visualization/src/control_flow/flatten.rs:554— baml_language/crates/baml_compiler2_visualization/src/control_flow/flatten.rs:554-588 | engine/baml-runtime/src/control_flow/flatten/step3_inline_implicit_nodes.rs:45-76 — before extracting anything, compare `baml_language/crates/baml_compiler2_visualization/src/control_flow/flatten.rs` and `engine/baml-runtime/src/control_flow/flatten/step3_inline_implicit_nodes.rs` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 132 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, 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 (33–35 lines × 2) baml_language/crates/baml_fmt/src/ast/expressions.rs:1584— baml_language/crates/baml_fmt/src/ast/expressions.rs:1584-1618 | baml_language/crates/baml_fmt/src/ast/expressions.rs:1756-1788 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (28–34 lines × 2) baml_language/crates/baml_ide/src/symbol_pool.rs:269— baml_language/crates/baml_ide/src/symbol_pool.rs:269-296 | baml_language/crates/baml_ide/src/symbol_pool.rs:488-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 (29–33 lines × 2) baml_language/sdks/python/rust/sdkgen_python_pydantic2/src/lib.rs:272— baml_language/sdks/python/rust/sdkgen_python_pydantic2/src/lib.rs:272-304 | baml_language/sdks/typescript/sdkgen_typescript_shared/src/lib.rs:131-159 — 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 (32 lines × 3) baml_language/crates/bridge_wasm/src/runs.rs:671— baml_language/crates/bridge_wasm/src/runs.rs:671-702 | baml_language/crates/bridge_wasm/src/runs.rs:792-823 | baml_language/crates/bridge_wasm/src/runs.rs:1312-1343 — 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 (29–32 lines × 2) baml_language/crates/baml_compiler2_mir/src/lower.rs:5005— baml_language/crates/baml_compiler2_mir/src/lower.rs:5005-5036 | baml_language/crates/baml_compiler2_mir/src/lower.rs:5559-5587 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (31–32 lines × 2) baml_language/crates/baml_fmt/src/ast/attributes.rs:347— baml_language/crates/baml_fmt/src/ast/attributes.rs:347-377 | baml_language/crates/baml_fmt/src/ast/expressions.rs:2956-2987 — before extracting anything, compare `baml_language/crates/baml_fmt/src/ast/attributes.rs` and `baml_language/crates/baml_fmt/src/ast/expressions.rs` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 143 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the 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 (25–31 lines × 2) baml_language/crates/bex_engine/src/lib.rs:6536— baml_language/crates/bex_engine/src/lib.rs:6536-6566 | baml_language/crates/bex_engine/src/lib.rs:6627-6651 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (28–30 lines × 2) baml_language/sdks/csharp/bridge_csharp/src/Generated/V1/BamlGeneratedCanonicalCodecs.cs:173— baml_language/sdks/csharp/bridge_csharp/src/Generated/V1/BamlGeneratedCanonicalCodecs.cs:173-202 | baml_language/sdks/csharp/bridge_csharp/src/Values/BamlValue.cs:552-579 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `baml_language/sdks/csharp/bridge_csharp/src/Generated/V1/BamlGeneratedCanonicalCodecs.cs:173` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (30 lines × 2) engine/language_server/src/baml_project/mod.rs:641— engine/language_server/src/baml_project/mod.rs:641-670 | engine/language_server/src/baml_project/mod.rs:995-1024 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (29 lines × 3) engine/baml-lib/baml-core/src/ir/ir_helpers/error_utils.rs:23— engine/baml-lib/baml-core/src/ir/ir_helpers/error_utils.rs:23-51 | engine/baml-lib/diagnostics/src/error.rs:37-65 | engine/baml-lib/jinja/src/evaluate_type/mod.rs:44-72 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times.
Duplicated block (28 lines × 4) engine/baml-lib/baml-core/src/validate/validation_pipeline/validations/functions.rs:112— engine/baml-lib/baml-core/src/validate/validation_pipeline/validations/functions.rs:112-139 | engine/baml-lib/baml-core/src/validate/validation_pipeline/validations/template_strings.rs:82-109 | engine/baml-lib/baml-core/src/validate/validation_pipeline/validations/types.rs:152-179 | engine/baml-lib/baml-core/src/validate/validation_pipeline/validations/types.rs:198-225 — before extracting anything, compare `engine/baml-lib/baml-core/src/validate/validation_pipeline/validations/functions.rs` and `engine/baml-lib/baml-core/src/validate/validation_pipeline/validations/template_strings.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 89 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the 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 (28 lines × 3) baml_language/crates/baml_compiler2_visualization/src/control_flow/mod.rs:266— baml_language/crates/baml_compiler2_visualization/src/control_flow/mod.rs:266-293 | engine/baml-compiler/src/viz_builder.rs:27-54 | engine/baml-runtime/src/control_flow.rs:185-212 — before extracting anything, compare `baml_language/crates/baml_compiler2_visualization/src/control_flow/mod.rs` and `engine/baml-runtime/src/control_flow.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 94 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, 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 (23–28 lines × 2) baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs:478— baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs:478-500 | baml_language/crates/baml_type/src/unify.rs:842-869 — before extracting anything, compare `baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs` and `baml_language/crates/baml_type/src/unify.rs` as WHOLE FILES: this scan already matched 21 separate duplicated blocks between them, totalling at least 418 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, 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 (27–28 lines × 2) baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs:187— baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs:187-213 | engine/baml-lib/jsonish/src/jsonish/parser/fixing_parser/json_parse_state.rs:215-242 — before extracting anything, compare `baml_language/crates/bex_sap/src/jsonish/parser/fixing_parser/json_parse_state.rs` and `engine/baml-lib/jsonish/src/jsonish/parser/fixing_parser/json_parse_state.rs` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 575 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, 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 (26–28 lines × 2) engine/baml-lib/baml-core/src/ir/ir_helpers/mod.rs:424— engine/baml-lib/baml-core/src/ir/ir_helpers/mod.rs:424-451 | engine/language_server/src/baml_project/mod.rs:1560-1585 — 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 (27 lines × 3) engine/baml-lib/ast/src/parser/parse_expr.rs:390— engine/baml-lib/ast/src/parser/parse_expr.rs:390-416 | engine/baml-lib/ast/src/parser/parse_expr.rs:420-446 | engine/baml-lib/ast/src/parser/parse_expr.rs:450-476 — 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 (25–27 lines × 2) engine/generators/languages/typescript/src/ir_to_ts/mod.rs:75— engine/generators/languages/typescript/src/ir_to_ts/mod.rs:75-101 | engine/generators/languages/typescript/src/ir_to_ts/mod.rs:165-189 — both copies are in the same file, so extract the block into 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–26 lines × 2) baml_language/crates/baml_compiler2_hir/src/builder.rs:501— baml_language/crates/baml_compiler2_hir/src/builder.rs:501-516 | baml_language/crates/baml_compiler2_hir/src/builder.rs:546-571 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (25–26 lines × 2) baml_language/crates/bex_sap/src/jsonish/parser/markdown_parser.rs:87— baml_language/crates/bex_sap/src/jsonish/parser/markdown_parser.rs:87-111 | engine/baml-lib/jsonish/src/jsonish/parser/markdown_parser.rs:92-117 — 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 (19–26 lines × 2) engine/baml-compiler/src/codegen.rs:590— engine/baml-compiler/src/codegen.rs:590-608 | engine/baml-compiler/src/codegen.rs:652-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 (21–25 lines × 2) baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs:1081— baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs:1081-1101 | baml_language/crates/baml_compiler2_hir_ty/src/interfaces/coherence.rs:314-338 — before extracting anything, compare `baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs` and `baml_language/crates/baml_compiler2_hir_ty/src/interfaces/coherence.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 61 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (18–25 lines × 2) baml_language/crates/bridge_ctypes/src/value_encode.rs:178— baml_language/crates/bridge_ctypes/src/value_encode.rs:178-195 | baml_language/crates/bridge_ctypes/src/value_encode.rs:345-369 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (23–25 lines × 2) engine/generators/languages/typescript/src/lib.rs:180— engine/generators/languages/typescript/src/lib.rs:180-202 | engine/generators/languages/typescript/src/lib.rs:284-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 (19–24 lines × 2) baml_language/crates/baml_fmt/src/ast/statements.rs:290— baml_language/crates/baml_fmt/src/ast/statements.rs:290-313 | baml_language/crates/baml_fmt/src/ast/statements.rs:418-436 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (24 lines × 2) baml_language/crates/baml_lsp_server/src/playground_http.rs:78— baml_language/crates/baml_lsp_server/src/playground_http.rs:78-101 | baml_language/crates/baml_lsp_server/src/playground_http.rs:129-152 — both copies are in the same file, so extract the block into 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–24 lines × 2) engine/baml-runtime/src/optimize/gepa_runtime.rs:101— engine/baml-runtime/src/optimize/gepa_runtime.rs:101-124 | engine/baml-runtime/src/optimize/gepa_runtime.rs:362-382 — both copies are in the same file, so extract the block into 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–23 lines × 2) baml_language/crates/baml_builtins2_codegen/src/codegen_io.rs:1661— baml_language/crates/baml_builtins2_codegen/src/codegen_io.rs:1661-1683 | baml_language/crates/baml_builtins2_codegen/src/codegen_io.rs:2040-2058 — both copies are in the same file, so extract the block into 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–23 lines × 2) baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:2357— baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:2357-2379 | baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:2819-2839 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (22 lines × 4) baml_language/crates/baml_type/src/normalize.rs:772— baml_language/crates/baml_type/src/normalize.rs:772-793 | baml_language/crates/baml_type/src/normalize.rs:1475-1496 | baml_language/crates/baml_type/src/normalize.rs:2476-2497 | baml_language/crates/baml_type/src/normalize.rs:2637-2658 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (19–22 lines × 4) languages/rust/baml/src/runtime.rs:98— languages/rust/baml/src/runtime.rs:98-119 | languages/rust/baml/src/runtime.rs:177-195 | languages/rust/baml/src/runtime.rs:221-242 | languages/rust/baml/src/runtime.rs:299-319 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (21–22 lines × 3) baml_language/crates/bex_vm/src/debug.rs:228— baml_language/crates/bex_vm/src/debug.rs:228-249 | baml_language/crates/bex_vm/src/debug.rs:409-430 | baml_language/crates/bex_vm_types/src/bytecode.rs:2591-2611 — 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 (22 lines × 3) baml_language/crates/bridge_wasm/src/runs.rs:730— baml_language/crates/bridge_wasm/src/runs.rs:730-751 | baml_language/crates/bridge_wasm/src/runs.rs:851-872 | baml_language/crates/bridge_wasm/src/runs.rs:1364-1385 — 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 (14–22 lines × 2) baml_language/crates/sys_native/src/shell.rs:94— baml_language/crates/sys_native/src/shell.rs:94-107 | baml_language/crates/sys_native/src/shell.rs:136-157 — both copies are in the same file, so extract the block into 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–20 lines × 3) baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:1132— baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:1132-1151 | baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:1185-1204 | baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:1270-1288 — 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 (16–20 lines × 2) baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:3929— baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:3929-3948 | baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:4159-4174 — both copies are in the same file, so extract the block into 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–20 lines × 2) baml_language/crates/baml_fmt/src/ast/pattern.rs:457— baml_language/crates/baml_fmt/src/ast/pattern.rs:457-473 | baml_language/crates/baml_fmt/src/ast/pattern.rs:661-680 — both copies are in the same file, so extract the block into 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–19 lines × 4) baml_language/crates/baml_compiler2_mir/src/lower.rs:7790— baml_language/crates/baml_compiler2_mir/src/lower.rs:7790-7808 | baml_language/crates/baml_compiler2_mir/src/lower.rs:7842-7858 | baml_language/crates/baml_compiler2_mir/src/lower.rs:7926-7942 | baml_language/crates/baml_compiler2_mir/src/lower.rs:8177-8193 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (19 lines × 3) baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:4427— baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:4427-4445 | baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:4601-4619 | baml_language/crates/baml_compiler2_ast/src/lower_expr_body.rs:4684-4702 — 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 (14–19 lines × 3) baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs:334— baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs:334-347 | baml_language/crates/baml_compiler2_hir_ty/src/interfaces.rs:1054-1072 | baml_language/crates/baml_type/src/unify.rs:646-659 — before extracting anything, compare `baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs` and `baml_language/crates/baml_type/src/unify.rs` as WHOLE FILES: this scan already matched 21 separate duplicated blocks between them, totalling at least 418 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (12–19 lines × 2) baml_language/crates/baml_compiler2_mir/src/lower.rs:12016— baml_language/crates/baml_compiler2_mir/src/lower.rs:12016-12027 | baml_language/crates/baml_compiler2_mir/src/lower.rs:12076-12094 — both copies are in the same file, so extract the block into 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–19 lines × 2) engine/baml-compiler/src/thir.rs:315— engine/baml-compiler/src/thir.rs:315-329 | engine/baml-lib/baml-types/src/expr.rs:260-278 — before extracting anything, compare `engine/baml-compiler/src/thir.rs` and `engine/baml-lib/baml-types/src/expr.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 69 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, 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 (15–18 lines × 4) baml_language/crates/baml_compiler_parser/src/parser.rs:5582— baml_language/crates/baml_compiler_parser/src/parser.rs:5582-5596 | baml_language/crates/baml_compiler_parser/src/parser.rs:5614-5628 | baml_language/crates/baml_compiler_parser/src/parser.rs:6493-6510 | baml_language/crates/baml_compiler_parser/src/parser.rs:7009-7023 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (11–18 lines × 2) baml_language/crates/baml_compiler2_hir_ty/src/infer/pat.rs:949— baml_language/crates/baml_compiler2_hir_ty/src/infer/pat.rs:949-966 | baml_language/crates/baml_compiler2_hir_ty/src/infer/pat.rs:1500-1510 — both copies are in the same file, so extract the block into 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–18 lines × 2) languages/rust/baml/src/args.rs:269— languages/rust/baml/src/args.rs:269-281 | languages/rust/baml/src/args.rs:427-444 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (16–17 lines × 4) baml_language/crates/bex_vm/src/package_reflect/graft.rs:1118— baml_language/crates/bex_vm/src/package_reflect/graft.rs:1118-1134 | baml_language/crates/bex_vm/src/package_reflect/graft.rs:1285-1300 | baml_language/crates/bex_vm_types/src/types/object.rs:179-194 | baml_language/crates/bex_vm_types/src/types/object.rs:212-227 — 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.
Duplicated block (12–17 lines × 2) baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs:359— baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs:359-370 | baml_language/crates/baml_type/src/unify.rs:669-685 — before extracting anything, compare `baml_language/crates/baml_compiler2_hir_ty/src/coherence.rs` and `baml_language/crates/baml_type/src/unify.rs` as WHOLE FILES: this scan already matched 21 separate duplicated blocks between them, totalling at least 418 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, 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 (15–17 lines × 2) baml_language/crates/bex_heap/src/gc.rs:311— baml_language/crates/bex_heap/src/gc.rs:311-327 | baml_language/crates/bex_heap/src/gc.rs:356-370 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (11–17 lines × 2) baml_language/sdks/typescript/sdkgen_typescript_shared/src/translate_ty.rs:98— baml_language/sdks/typescript/sdkgen_typescript_shared/src/translate_ty.rs:98-114 | baml_language/sdks/typescript/sdkgen_typescript_shared/src/translate_ty.rs:361-371 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (2–17 lines × 5) engine/baml-schema-wasm/src/runtime_wasm/mod.rs:2093— engine/baml-schema-wasm/src/runtime_wasm/mod.rs:2093-2094 | engine/baml-schema-wasm/src/runtime_wasm/mod.rs:2468-2484 | engine/baml-schema-wasm/src/runtime_wasm/mod.rs:2574-2590 | engine/baml-schema-wasm/src/runtime_wasm/mod.rs:2851-2852 | engine/baml-schema-wasm/src/runtime_wasm/mod.rs:3070-3071 — 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 (14–17 lines × 2) engine/generators/languages/typescript/src/lib.rs:216— engine/generators/languages/typescript/src/lib.rs:216-229 | engine/generators/languages/typescript/src/lib.rs:322-338 — both copies are in the same file, so extract the block into 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–16 lines × 3) baml_language/crates/baml_cli/src/pack_command.rs:591— baml_language/crates/baml_cli/src/pack_command.rs:591-606 | baml_language/crates/baml_cli/src/run_command.rs:885-899 | baml_language/crates/baml_cli/src/test_command.rs:380-393 — before extracting anything, compare `baml_language/crates/baml_cli/src/pack_command.rs` and `baml_language/crates/baml_cli/src/run_command.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 50 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (9–16 lines × 2) baml_language/crates/bex_vm/src/vm.rs:9054— baml_language/crates/bex_vm/src/vm.rs:9054-9062 | baml_language/crates/bex_vm/src/vm.rs:9080-9095 — both copies are in the same file, so extract the block into 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 × 24) baml_language/crates/btel_records/src/lib.rs:820— baml_language/crates/btel_records/src/lib.rs:820-834 | baml_language/crates/btel_records/src/lib.rs:841-855 | baml_language/crates/btel_records/src/lib.rs:862-876 | baml_language/crates/btel_records/src/lib.rs:883-897 | baml_language/crates/btel_records/src/lib.rs:904-918 | baml_language/crates/btel_records/src/lib.rs:925-939 | baml_language/crates/btel_records/src/lib.rs:946-960 | baml_language/crates/btel_records/src/lib.rs:967-981 | baml_language/crates/btel_records/src/lib.rs:988-1002 | baml_language/crates/btel_records/src/lib.rs:1010-1024 | baml_language/crates/btel_records/src/lib.rs:1031-1045 | baml_language/crates/btel_records/src/lib.rs:1053-1067 | baml_language/crates/btel_records/src/lib.rs:1074-1088 | baml_language/crates/btel_records/src/lib.rs:1096-1110 | baml_language/crates/btel_records/src/lib.rs:1117-1131 | baml_language/crates/btel_records/src/lib.rs:1139-1153 | baml_language/crates/btel_records/src/lib.rs:1160-1174 | baml_language/crates/btel_records/src/lib.rs:1181-1195 | baml_language/crates/btel_records/src/lib.rs:1202-1216 | baml_language/crates/btel_records/src/lib.rs:1223-1237 | baml_language/crates/btel_records/src/lib.rs:1244-1258 | baml_language/crates/btel_records/src/lib.rs:1266-1280 | baml_language/crates/btel_records/src/lib.rs:1287-1301 | baml_language/crates/btel_records/src/lib.rs:1309-1323 — all 24 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (14–15 lines × 7) languages/rust/baml/src/runtime.rs:92— languages/rust/baml/src/runtime.rs:92-106 | languages/rust/baml/src/runtime.rs:171-184 | languages/rust/baml/src/runtime.rs:215-229 | languages/rust/baml/src/runtime.rs:293-307 | languages/rust/baml/src/runtime.rs:361-375 | languages/rust/baml/src/runtime.rs:461-475 | languages/rust/baml/src/runtime.rs:507-521 — all 7 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (15 lines × 5) baml_language/crates/baml_fmt/src/ast/attributes.rs:356— baml_language/crates/baml_fmt/src/ast/attributes.rs:356-370 | baml_language/crates/baml_fmt/src/ast/expressions.rs:2965-2979 | baml_language/crates/baml_fmt/src/ast/expressions.rs:4161-4175 | baml_language/crates/baml_fmt/src/ast/expressions.rs:4419-4433 | baml_language/crates/baml_fmt/src/ast/types.rs:1173-1187 — before extracting anything, compare `baml_language/crates/baml_fmt/src/ast/attributes.rs` and `baml_language/crates/baml_fmt/src/ast/expressions.rs` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 143 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (14–15 lines × 3) baml_language/crates/bex_vm/src/package_baml/array.rs:421— baml_language/crates/bex_vm/src/package_baml/array.rs:421-434 | baml_language/crates/bex_vm/src/package_baml/array.rs:461-475 | baml_language/crates/bex_vm/src/package_baml/array.rs:677-690 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (13–15 lines × 2) baml_language/crates/baml_compiler2_hir_ty/src/throw_facts.rs:105— baml_language/crates/baml_compiler2_hir_ty/src/throw_facts.rs:105-117 | baml_language/crates/baml_compiler2_hir_ty/src/throw_facts.rs:140-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 (9–15 lines × 2) baml_language/crates/baml_ide/src/tokens/index.rs:157— baml_language/crates/baml_ide/src/tokens/index.rs:157-171 | baml_language/crates/baml_ide/src/usages.rs:301-309 — 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 (11–14 lines × 7) baml_language/crates/baml_compiler2_emit/src/analysis.rs:917— baml_language/crates/baml_compiler2_emit/src/analysis.rs:917-930 | baml_language/crates/baml_compiler2_emit/src/analysis.rs:940-950 | baml_language/crates/baml_compiler2_emit/src/analysis.rs:963-973 | baml_language/crates/baml_compiler2_emit/src/analysis.rs:976-986 | baml_language/crates/baml_compiler2_emit/src/analysis.rs:994-1004 | baml_language/crates/baml_compiler2_emit/src/analysis.rs:1012-1022 | baml_language/crates/baml_compiler2_emit/src/analysis.rs:1037-1047 — all 7 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (14 lines × 6) baml_language/crates/baml_fmt/src/ast/attributes.rs:406— baml_language/crates/baml_fmt/src/ast/attributes.rs:406-419 | baml_language/crates/baml_fmt/src/ast/declarations.rs:2965-2978 | baml_language/crates/baml_fmt/src/ast/expressions.rs:3067-3080 | baml_language/crates/baml_fmt/src/ast/expressions.rs:4263-4276 | baml_language/crates/baml_fmt/src/ast/expressions.rs:4569-4582 | baml_language/crates/baml_fmt/src/ast/types.rs:1231-1244 — before extracting anything, compare `baml_language/crates/baml_fmt/src/ast/attributes.rs` and `baml_language/crates/baml_fmt/src/ast/declarations.rs` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 70 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (13 lines × 6) engine/baml-schema-wasm/src/runtime_wasm/mod.rs:1612— engine/baml-schema-wasm/src/runtime_wasm/mod.rs:1612-1624 | engine/baml-schema-wasm/src/runtime_wasm/mod.rs:1632-1644 | engine/baml-schema-wasm/src/runtime_wasm/mod.rs:1652-1664 | engine/language_server/src/baml_project/mod.rs:523-535 | engine/language_server/src/baml_project/mod.rs:541-553 | engine/language_server/src/baml_project/mod.rs:559-571 — before extracting anything, compare `engine/baml-schema-wasm/src/runtime_wasm/mod.rs` and `engine/language_server/src/baml_project/mod.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 125 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (12–13 lines × 3) baml_language/crates/baml_fmt/src/ast/declarations.rs:1292— baml_language/crates/baml_fmt/src/ast/declarations.rs:1292-1304 | baml_language/crates/baml_fmt/src/ast/declarations.rs:1908-1919 | baml_language/crates/baml_fmt/src/ast/declarations.rs:2113-2125 — 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–13 lines × 2) baml_language/crates/baml_compiler2_mir/src/lower.rs:6871— baml_language/crates/baml_compiler2_mir/src/lower.rs:6871-6883 | baml_language/crates/baml_compiler2_mir/src/lower.rs:12344-12351 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (3–13 lines × 3) baml_language/crates/bex_vm/src/debug.rs:599— baml_language/crates/bex_vm/src/debug.rs:599-611 | baml_language/crates/bex_vm/src/debug.rs:1183-1185 | engine/baml-vm/src/debug.rs:320-332 — before extracting anything, compare `baml_language/crates/bex_vm/src/debug.rs` and `engine/baml-vm/src/debug.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 57 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (11–12 lines × 8) baml_language/crates/baml_fmt/src/ast/attributes.rs:389— baml_language/crates/baml_fmt/src/ast/attributes.rs:389-399 | baml_language/crates/baml_fmt/src/ast/declarations.rs:508-518 | baml_language/crates/baml_fmt/src/ast/declarations.rs:2947-2957 | baml_language/crates/baml_fmt/src/ast/expressions.rs:3050-3060 | baml_language/crates/baml_fmt/src/ast/expressions.rs:4007-4018 | baml_language/crates/baml_fmt/src/ast/expressions.rs:4246-4256 | baml_language/crates/baml_fmt/src/ast/expressions.rs:4552-4562 | baml_language/crates/baml_fmt/src/ast/types.rs:1214-1224 — before extracting anything, compare `baml_language/crates/baml_fmt/src/ast/attributes.rs` and `baml_language/crates/baml_fmt/src/ast/declarations.rs` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 70 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the 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–12 lines × 3) baml_language/crates/baml_compiler_parser/src/parser.rs:732— baml_language/crates/baml_compiler_parser/src/parser.rs:732-742 | baml_language/crates/baml_compiler_parser/src/parser.rs:946-957 | baml_language/crates/baml_compiler_parser/src/parser.rs:3999-4009 — 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–12 lines × 3) languages/rust/baml-macros/src/baml_serde.rs:48— languages/rust/baml-macros/src/baml_serde.rs:48-59 | languages/rust/baml-macros/src/baml_serde.rs:65-76 | languages/rust/baml-macros/src/baml_serde.rs:81-90 — 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–11 lines × 6) baml_language/crates/baml_fmt/src/ast/attributes.rs:402— baml_language/crates/baml_fmt/src/ast/attributes.rs:402-411 | baml_language/crates/baml_fmt/src/ast/expressions.rs:3063-3072 | baml_language/crates/baml_fmt/src/ast/expressions.rs:3134-3144 | baml_language/crates/baml_fmt/src/ast/expressions.rs:4259-4268 | baml_language/crates/baml_fmt/src/ast/expressions.rs:4565-4574 | baml_language/crates/baml_fmt/src/ast/types.rs:1227-1236 — before extracting anything, compare `baml_language/crates/baml_fmt/src/ast/attributes.rs` and `baml_language/crates/baml_fmt/src/ast/expressions.rs` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 143 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (10–11 lines × 5) baml_language/crates/baml_compiler2_mir/src/lower.rs:7641— baml_language/crates/baml_compiler2_mir/src/lower.rs:7641-7651 | baml_language/crates/baml_compiler2_mir/src/lower.rs:7821-7830 | baml_language/crates/baml_compiler2_mir/src/lower.rs:7869-7878 | baml_language/crates/baml_compiler2_mir/src/lower.rs:7953-7962 | baml_language/crates/baml_compiler2_mir/src/lower.rs:8204-8213 — 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 (10–11 lines × 4) engine/baml-runtime/src/internal/llm_client/primitive/request.rs:262— engine/baml-runtime/src/internal/llm_client/primitive/request.rs:262-272 | engine/baml-runtime/src/internal/llm_client/primitive/request.rs:289-298 | engine/baml-runtime/src/internal/llm_client/primitive/request.rs:318-328 | engine/baml-runtime/src/internal/llm_client/primitive/request.rs:347-356 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (8–11 lines × 3) baml_language/crates/baml_compiler2_hir_ty/src/interfaces/impl_rules.rs:1870— baml_language/crates/baml_compiler2_hir_ty/src/interfaces/impl_rules.rs:1870-1877 | baml_language/crates/baml_compiler2_hir_ty/src/interfaces/impl_rules.rs:1902-1909 | baml_language/crates/baml_compiler2_hir_ty/src/interfaces/impl_rules.rs:1951-1961 — 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–11 lines × 3) engine/baml-lib/baml-core/src/ir/repr.rs:2584— engine/baml-lib/baml-core/src/ir/repr.rs:2584-2594 | engine/baml-lib/baml-core/src/ir/repr.rs:2603-2612 | engine/baml-lib/baml-core/src/ir/repr.rs:2636-2646 — 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 × 7) baml_language/crates/baml_fmt/src/ast/attributes.rs:421— baml_language/crates/baml_fmt/src/ast/attributes.rs:421-430 | baml_language/crates/baml_fmt/src/ast/declarations.rs:538-547 | baml_language/crates/baml_fmt/src/ast/expressions.rs:870-879 | baml_language/crates/baml_fmt/src/ast/expressions.rs:1983-1992 | baml_language/crates/baml_fmt/src/ast/expressions.rs:3082-3091 | baml_language/crates/baml_fmt/src/ast/statements.rs:896-905 | baml_language/crates/baml_fmt/src/ast/types.rs:225-234 — before extracting anything, compare `baml_language/crates/baml_fmt/src/ast/attributes.rs` and `baml_language/crates/baml_fmt/src/ast/declarations.rs` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 70 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the 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 (8–10 lines × 6) baml_language/crates/baml_fmt/src/ast/declarations.rs:1193— baml_language/crates/baml_fmt/src/ast/declarations.rs:1193-1202 | baml_language/crates/baml_fmt/src/ast/declarations.rs:1830-1837 | baml_language/crates/baml_fmt/src/ast/expressions.rs:1913-1921 | baml_language/crates/baml_fmt/src/ast/expressions.rs:2530-2537 | baml_language/crates/baml_fmt/src/ast/expressions.rs:4090-4097 | baml_language/crates/baml_fmt/src/ast/expressions.rs:4339-4346 — before extracting anything, compare `baml_language/crates/baml_fmt/src/ast/declarations.rs` and `baml_language/crates/baml_fmt/src/ast/expressions.rs` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 124 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (9–10 lines × 3) baml_language/crates/baml_compiler2_hir_ty/src/interfaces/impl_rules.rs:1866— baml_language/crates/baml_compiler2_hir_ty/src/interfaces/impl_rules.rs:1866-1874 | baml_language/crates/baml_compiler2_hir_ty/src/interfaces/impl_rules.rs:1946-1955 | baml_language/crates/baml_compiler2_hir_ty/src/interfaces/impl_rules.rs:2149-2157 — 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–10 lines × 3) engine/baml-runtime/src/optimize/applier.rs:118— engine/baml-runtime/src/optimize/applier.rs:118-127 | engine/baml-runtime/src/optimize/applier.rs:235-242 | engine/baml-runtime/src/optimize/applier.rs:468-475 — 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 × 14) engine/baml-schema-wasm/src/runtime_wasm/mod.rs:1490— engine/baml-schema-wasm/src/runtime_wasm/mod.rs:1490-1498 | engine/baml-schema-wasm/src/runtime_wasm/mod.rs:1503-1511 | engine/baml-schema-wasm/src/runtime_wasm/mod.rs:1516-1524 | engine/baml-schema-wasm/src/runtime_wasm/mod.rs:1530-1538 | engine/baml-schema-wasm/src/runtime_wasm/mod.rs:1544-1553 | engine/baml-schema-wasm/src/runtime_wasm/mod.rs:1559-1567 | engine/baml-schema-wasm/src/runtime_wasm/mod.rs:1572-1580 | engine/language_server/src/baml_project/mod.rs:890-898 | engine/language_server/src/baml_project/mod.rs:903-911 | engine/language_server/src/baml_project/mod.rs:916-924 | engine/language_server/src/baml_project/mod.rs:930-938 | engine/language_server/src/baml_project/mod.rs:944-953 | engine/language_server/src/baml_project/mod.rs:959-967 | engine/language_server/src/baml_project/mod.rs:972-980 — before extracting anything, compare `engine/baml-schema-wasm/src/runtime_wasm/mod.rs` and `engine/language_server/src/baml_project/mod.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 125 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (8–9 lines × 6) baml_language/crates/bex_vm/src/vm.rs:8055— baml_language/crates/bex_vm/src/vm.rs:8055-8063 | baml_language/crates/bex_vm/src/vm.rs:9732-9739 | baml_language/crates/bex_vm/src/vm.rs:9758-9766 | baml_language/crates/bex_vm/src/vm.rs:9797-9804 | baml_language/crates/bex_vm/src/vm.rs:9831-9838 | baml_language/crates/bex_vm/src/vm.rs:9856-9863 — all 6 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (6–9 lines × 4) baml_language/crates/baml_fmt/src/ast/pattern.rs:284— baml_language/crates/baml_fmt/src/ast/pattern.rs:284-289 | baml_language/crates/baml_fmt/src/ast/pattern.rs:573-578 | baml_language/crates/baml_fmt/src/ast/pattern.rs:747-752 | baml_language/crates/baml_fmt/src/ast/pattern.rs:1093-1101 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (6–9 lines × 2) baml_language/crates/baml_fmt/src/ast/declarations.rs:187— baml_language/crates/baml_fmt/src/ast/declarations.rs:187-195 | baml_language/crates/baml_fmt/src/ast/interfaces.rs:29-34 — before extracting anything, compare `baml_language/crates/baml_fmt/src/ast/declarations.rs` and `baml_language/crates/baml_fmt/src/ast/interfaces.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 32 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (5–9 lines × 2) engine/baml-compiler/src/thir.rs:465— engine/baml-compiler/src/thir.rs:465-469 | engine/baml-lib/baml-types/src/expr.rs:505-513 — before extracting anything, compare `engine/baml-compiler/src/thir.rs` and `engine/baml-lib/baml-types/src/expr.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 69 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, 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 × 18) baml_language/crates/btel_recorder/src/lib.rs:535— baml_language/crates/btel_recorder/src/lib.rs:535-542 | baml_language/crates/btel_recorder/src/lib.rs:560-567 | baml_language/crates/btel_recorder/src/lib.rs:585-592 | baml_language/crates/btel_recorder/src/lib.rs:610-617 | baml_language/crates/btel_recorder/src/lib.rs:635-642 | baml_language/crates/btel_recorder/src/lib.rs:660-667 | baml_language/crates/btel_recorder/src/lib.rs:685-692 | baml_language/crates/btel_recorder/src/lib.rs:710-717 | baml_language/crates/btel_recorder/src/lib.rs:735-742 | baml_language/crates/btel_recorder/src/lib.rs:786-793 | baml_language/crates/btel_recorder/src/lib.rs:836-843 | baml_language/crates/btel_recorder/src/lib.rs:887-894 | baml_language/crates/btel_recorder/src/lib.rs:937-944 | baml_language/crates/btel_recorder/src/lib.rs:962-969 | baml_language/crates/btel_recorder/src/lib.rs:987-994 | baml_language/crates/btel_recorder/src/lib.rs:1012-1019 | baml_language/crates/btel_recorder/src/lib.rs:1037-1044 | baml_language/crates/btel_recorder/src/lib.rs:1088-1095 — all 18 copies are in the same file, so extract the block into one function there and call 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 × 7) baml_language/crates/bex_events/src/run.rs:1075— baml_language/crates/bex_events/src/run.rs:1075-1082 | baml_language/crates/bex_events/src/run.rs:1114-1121 | baml_language/crates/bex_events/src/run.rs:1150-1157 | baml_language/crates/bex_events/src/run.rs:1182-1189 | baml_language/crates/bex_events/src/run.rs:1212-1219 | baml_language/crates/bex_events/src/run.rs:1239-1246 | baml_language/crates/bex_events/src/run.rs:1272-1279 — all 7 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (8 lines × 6) baml_language/crates/btel_recorder/src/lib.rs:761— baml_language/crates/btel_recorder/src/lib.rs:761-768 | baml_language/crates/btel_recorder/src/lib.rs:811-818 | baml_language/crates/btel_recorder/src/lib.rs:862-869 | baml_language/crates/btel_recorder/src/lib.rs:912-919 | baml_language/crates/btel_recorder/src/lib.rs:1063-1070 | baml_language/crates/btel_recorder/src/lib.rs:1113-1120 — all 6 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (7–8 lines × 4) engine/baml-runtime/src/internal/llm_client/primitive/anthropic/anthropic_client.rs:178— engine/baml-runtime/src/internal/llm_client/primitive/anthropic/anthropic_client.rs:178-184 | engine/baml-runtime/src/internal/llm_client/primitive/aws/aws_client.rs:517-524 | engine/baml-runtime/src/internal/llm_client/primitive/google/googleai_client.rs:122-128 | engine/baml-runtime/src/internal/llm_client/primitive/vertex/vertex_client.rs:146-152 — before extracting anything, compare `engine/baml-runtime/src/internal/llm_client/primitive/anthropic/anthropic_client.rs` and `engine/baml-runtime/src/internal/llm_client/primitive/google/googleai_client.rs` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 79 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (7 lines × 8) engine/generators/languages/go/src/ir_to_go/mod.rs:113— engine/generators/languages/go/src/ir_to_go/mod.rs:113-119 | engine/generators/languages/go/src/ir_to_go/mod.rs:144-150 | engine/generators/languages/go/src/ir_to_go/mod.rs:274-280 | engine/generators/languages/go/src/ir_to_go/mod.rs:292-298 | engine/generators/languages/rust/src/ir_to_rust/mod.rs:131-137 | engine/generators/languages/rust/src/ir_to_rust/mod.rs:162-168 | engine/generators/languages/rust/src/ir_to_rust/mod.rs:304-310 | engine/generators/languages/rust/src/ir_to_rust/mod.rs:322-328 — before extracting anything, compare `engine/generators/languages/go/src/ir_to_go/mod.rs` and `engine/generators/languages/rust/src/ir_to_rust/mod.rs` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 208 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
Duplicated block (7 lines × 7) baml_language/crates/bex_vm/src/vm.rs:8058— baml_language/crates/bex_vm/src/vm.rs:8058-8064 | baml_language/crates/bex_vm/src/vm.rs:8065-8071 | baml_language/crates/bex_vm/src/vm.rs:9734-9740 | baml_language/crates/bex_vm/src/vm.rs:9761-9767 | baml_language/crates/bex_vm/src/vm.rs:9799-9805 | baml_language/crates/bex_vm/src/vm.rs:9833-9839 | baml_language/crates/bex_vm/src/vm.rs:9858-9864 — all 7 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (6 lines × 6) baml_language/crates/baml_fmt/src/ast/declarations.rs:1830— baml_language/crates/baml_fmt/src/ast/declarations.rs:1830-1836 | baml_language/crates/baml_fmt/src/ast/expressions.rs:1913-1920 | baml_language/crates/baml_fmt/src/ast/expressions.rs:2530-2536 | baml_language/crates/baml_fmt/src/ast/expressions.rs:4090-4096 | baml_language/crates/baml_fmt/src/ast/expressions.rs:4339-4345 | baml_language/crates/baml_fmt/src/ast/pattern.rs:385-390 — before extracting anything, compare `baml_language/crates/baml_fmt/src/ast/declarations.rs` and `baml_language/crates/baml_fmt/src/ast/expressions.rs` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 124 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the 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–6 lines × 5) engine/baml-lib/llm-client/src/clients/helpers.rs:557— engine/baml-lib/llm-client/src/clients/helpers.rs:557-561 | engine/baml-lib/llm-client/src/clients/helpers.rs:581-585 | engine/baml-lib/llm-client/src/clients/helpers.rs:605-610 | engine/baml-lib/llm-client/src/clients/helpers.rs:628-632 | engine/baml-lib/llm-client/src/clients/helpers.rs:652-656 — 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 (4–6 lines × 3) baml_language/crates/baml_compiler2_mir/src/lower.rs:9045— baml_language/crates/baml_compiler2_mir/src/lower.rs:9045-9050 | baml_language/crates/baml_compiler2_mir/src/lower.rs:9124-9127 | baml_language/crates/baml_compiler2_mir/src/lower.rs:9186-9191 — 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–5 lines × 10) engine/baml_cffi_macros/src/lib.rs:860— engine/baml_cffi_macros/src/lib.rs:860-864 | engine/baml_cffi_macros/src/lib.rs:877-880 | engine/baml_cffi_macros/src/lib.rs:896-900 | engine/baml_cffi_macros/src/lib.rs:915-919 | engine/baml_cffi_macros/src/lib.rs:949-953 | engine/baml_cffi_macros/src/lib.rs:978-982 | engine/baml_cffi_macros/src/lib.rs:1012-1016 | engine/baml_cffi_macros/src/lib.rs:1046-1050 | engine/baml_cffi_macros/src/lib.rs:1097-1101 | engine/baml_cffi_macros/src/lib.rs:1131-1135 — all 10 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (3–5 lines × 3) engine/baml-lib/llm-client/src/clients/anthropic.rs:157— engine/baml-lib/llm-client/src/clients/anthropic.rs:157-161 | engine/baml-lib/llm-client/src/clients/aws_bedrock.rs:402-404 | engine/baml-lib/llm-client/src/clients/openai.rs:206-210 — 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 (5 lines × 16) baml_language/crates/baml_fmt/src/ast/attributes.rs:434— baml_language/crates/baml_fmt/src/ast/attributes.rs:434-438 | baml_language/crates/baml_fmt/src/ast/declarations.rs:551-555 | baml_language/crates/baml_fmt/src/ast/declarations.rs:1496-1500 | baml_language/crates/baml_fmt/src/ast/declarations.rs:2296-2300 | baml_language/crates/baml_fmt/src/ast/declarations.rs:2995-2999 | baml_language/crates/baml_fmt/src/ast/expressions.rs:3390-3394 | baml_language/crates/baml_fmt/src/ast/expressions.rs:5698-5702 | baml_language/crates/baml_fmt/src/ast/pattern.rs:525-529 | baml_language/crates/baml_fmt/src/ast/pattern.rs:760-764 | baml_language/crates/baml_fmt/src/ast/pattern.rs:1039-1043 | baml_language/crates/baml_fmt/src/ast/statements.rs:909-913 | baml_language/crates/baml_fmt/src/ast/statements.rs:1074-1078 | baml_language/crates/baml_fmt/src/ast/types.rs:238-242 | baml_language/crates/baml_fmt/src/ast/types.rs:421-425 | baml_language/crates/baml_fmt/src/ast/types.rs:1083-1087 | baml_language/crates/baml_fmt/src/ast/types.rs:1277-1281 — before extracting anything, compare `baml_language/crates/baml_fmt/src/ast/attributes.rs` and `baml_language/crates/baml_fmt/src/ast/declarations.rs` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 70 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (9 lines × 5) engine/generators/languages/go/src/utils.rs:1— engine/generators/languages/go/src/utils.rs:1-9 | engine/generators/languages/python/src/utils.rs:1-9 | engine/generators/languages/ruby/src/utils.rs:1-9 | engine/generators/languages/rust/src/utils.rs:1-9 | engine/generators/languages/typescript/src/utils.rs:1-9 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 5 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 5 times.
Duplicated block (9 lines × 7) baml_language/crates/bridge_wasm/src/wasm_io_glob.rs:59— baml_language/crates/bridge_wasm/src/wasm_io_glob.rs:59-67 | baml_language/crates/sys_native/src/io_impls.rs:442-450 | baml_language/crates/sys_native/src/io_impls.rs:1130-1138 | baml_language/crates/sys_native/src/io_impls.rs:1456-1465 | baml_language/crates/sys_native/src/io_impls.rs:2064-2073 | baml_language/crates/sys_native/src/io_impls.rs:2093-2102 | baml_language/crates/sys_native/src/io_impls.rs:2106-2115 — there are 7 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 7 sites; resolving a subset leaves the remainder to drift apart.
Duplicated block (29–30 lines × 2) baml_language/sdks/python/src/baml_bridge/__init__.py:419— baml_language/sdks/python/src/baml_bridge/__init__.py:419-448 | baml_language/sdks/python/src/baml_bridge/__init__.py:460-488 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (20 lines × 3) scripts/ffi-debug/analyze_ffi.py:298— scripts/ffi-debug/analyze_ffi.py:298-317 | scripts/ffi-debug/analyze_ffi.py:327-346 | scripts/ffi-debug/analyze_ffi.py:365-384 — 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 (14–19 lines × 2) scripts/ffi-debug/analyze_ffi.py:197— scripts/ffi-debug/analyze_ffi.py:197-210 | scripts/ffi-debug/analyze_ffi.py:220-238 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (4–10 lines × 6) scripts/ffi-debug/analyze_ffi.py:656— scripts/ffi-debug/analyze_ffi.py:656-659 | scripts/ffi-debug/analyze_ffi.py:660-663 | scripts/ffi-debug/analyze_ffi.py:668-671 | scripts/ffi-debug/analyze_ffi.py:676-685 | scripts/ffi-debug/analyze_ffi.py:690-699 | scripts/ffi-debug/analyze_ffi.py:700-706 — 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. 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, `scripts/ffi-debug/analyze_ffi.py:671` calls `set_ylabel`, `n` and `scripts/ffi-debug/analyze_ffi.py:659` does not — after which the two agree again for 5 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (8–9 lines × 3) scripts/ffi-debug/analyze_ffi.py:102— scripts/ffi-debug/analyze_ffi.py:102-110 | scripts/ffi-debug/analyze_ffi.py:111-118 | scripts/ffi-debug/analyze_ffi.py:120-127 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (6–7 lines × 4) scripts/ffi-debug/analyze_ffi.py:297— scripts/ffi-debug/analyze_ffi.py:297-302 | scripts/ffi-debug/analyze_ffi.py:325-331 | scripts/ffi-debug/analyze_ffi.py:354-359 | scripts/ffi-debug/analyze_ffi.py:364-369 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (12 lines × 9) engine/generators/data/array_types/python/main.py:143— engine/generators/data/array_types/python/main.py:143-157 | engine/generators/data/edge_cases/python/main.py:202-216 | engine/generators/data/literal_types/python/main.py:66-79 | engine/generators/data/map_types/python/main.py:162-175 | engine/generators/data/mixed_complex_types/python/main.py:231-242 | engine/generators/data/nested_structures/python/main.py:237-249 | engine/generators/data/optional_nullable/python/main.py:153-166 | engine/generators/data/primitive_types/python/main.py:80-93 | engine/generators/data/union_types_extended/python/main.py:133-145 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 9 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 9 times.
Duplicated block (2–5 lines × 13) baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:87— baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:87-91 | baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:183-187 | baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:193-194 | baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:290-294 | baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:301-302 | baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:408-412 | baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:420-421 | baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:537-541 | baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:550-551 | baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:677-681 | baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:691-692 | baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:828-832 | baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:843-844 — all 13 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:87` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:405` calls `t2`, `_bamlDecode`, `t3` and `baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:86` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (5 lines × 7) baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:82— baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:82-86 | baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:177-181 | baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:283-287 | baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:400-404 | baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:528-532 | baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:667-671 | baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:817-821 — all 7 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:82` it does not close everything it opens, so those 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, `baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:182` calls `t2`, `_bamlDecode` and `baml_language/sdks/swift/Sources/BamlBridge/BamlUnions.swift:87` 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.
Near-duplicate member pair (30 shared lines) engine/generators/utils/test_harness/src/lib.rs:107— engine/generators/utils/test_harness/src/lib.rs:107-184 | engine/generators/utils/test_harness/src/lib.rs:186-301 — These two members are variants of one another: 30 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
Duplicated block (13–16 lines × 2) baml_language/sdk_tests/codegen/src/lib.rs:226— baml_language/sdk_tests/codegen/src/lib.rs:226-238 | baml_language/sdk_tests/codegen/src/lib.rs:269-284 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (28–29 lines × 2) baml_language/forks/aws-config-systest/run-e2e.py:440— baml_language/forks/aws-config-systest/run-e2e.py:440-467 | baml_language/forks/google-cloud-auth-systest/run-e2e.py:273-301 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (37–58 lines × 2) integ-tests/ruby/test_functions.rb:366— integ-tests/ruby/test_functions.rb:366-402 | integ-tests/ruby/test_functions.rb:404-461 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `integ-tests/ruby/test_functions.rb:366` it does not close everything it opens, so those 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.
Unstable project sys_auth — sys_auth has instability 0.83 with 1 dependents.
P12 · CI test-gate honesty· Runner config excludes tests no gate runs · ×1
Runner config excludes tests no gate runs typescript2/app-vscode-webview/vitest.config.ts:48— `src/**/*.browser.test.{ts,tsx}` removes 2 test(s) in 1 file(s) (e.g. `typescript2/app-vscode-webview/src/App.browser.test.tsx`) from what vitest collects, and no other runner or CI command runs them — they are dead tests. Run them (another runner, project or job), or delete them.
Duplication concentrated across 3 sibling directories (82 clone groups) typescript/packages/ui/src/components/carousel.tsx:3— 82 duplicated blocks under the repository root have copies in at least two of the sibling directories baml_language, typescript, typescript2 — 58 of them are reported below, and 24 are counted here but not reported individually: those copies match on shape but no longer clear R10's bar for an individually reported row — either they kept neither their own names nor their values, or what was copied is too small to stand on its own (it reports near-exact duplication only, and only of substantial extent). What this row states is the concentration, which the detector measured over all 82 and which does not depend on how exactly each block's copies still match. That concentration is one structural fact, not 82 local ones: the siblings replicate behaviour none of them owns, which is the shape of a missing shared module — a common library every sibling imports — rather than 82 separate extractions. Check first whether the siblings are deliberately standalone deliverables (scaffold templates, demo apps that must stay copy-pasteable); where they are, the duplication is the design and the per-block rows are the ones to act on.
Duplication concentrated across 12 sibling directories (44 clone groups) typescript2/app-beps/src/components/ui/select.tsx:3— 44 duplicated blocks under typescript2/ have copies in at least two of the sibling directories app-beps, app-developer-docs, app-feedback, app-type-quiz, app-vscode-ext, app-vscode-webview (+6 more sibling(s) not listed) — 20 of them are reported below, and 24 are counted here but not reported individually: those copies match on shape but no longer clear R10's bar for an individually reported row — either they kept neither their own names nor their values, or what was copied is too small to stand on its own (it reports near-exact duplication only, and only of substantial extent). What this row states is the concentration, which the detector measured over all 44 and which does not depend on how exactly each block's copies still match. That concentration is one structural fact, not 44 local ones: the siblings replicate behaviour none of them owns, which is the shape of a missing shared module — a common library every sibling imports — rather than 44 separate extractions. Check first whether the siblings are deliberately standalone deliverables (scaffold templates, demo apps that must stay copy-pasteable); where they are, the duplication is the design and the per-block rows are the ones to act on.
Duplication concentrated across 12 sibling directories (21 clone groups) typescript2/app-website/app/learn2/_deck/Deck.tsx:3— 21 duplicated blocks under typescript2/app-website/app/ have copies in at least two of the sibling directories atb, baml-intro, bamlcode, eap, fight-slop-with-slop, learn2 (+6 more sibling(s) not listed) — 9 of them are reported below, and 12 are counted here but not reported individually: those copies match on shape but no longer clear R10's bar for an individually reported row — either they kept neither their own names nor their values, or what was copied is too small to stand on its own (it reports near-exact duplication only, and only of substantial extent). What this row states is the concentration, which the detector measured over all 21 and which does not depend on how exactly each block's copies still match. That concentration is one structural fact, not 21 local ones: the siblings replicate behaviour none of them owns, which is the shape of a missing shared module — a common library every sibling imports — rather than 21 separate extractions. Check first whether the siblings are deliberately standalone deliverables (scaffold templates, demo apps that must stay copy-pasteable); where they are, the duplication is the design and the per-block rows are the ones to act on.
Duplication concentrated across 9 sibling directories (19 clone groups) engine/generators/data/edge_cases/typescript/index.ts:213— 19 duplicated blocks under engine/generators/data/ have copies in at least two of the sibling directories array_types, edge_cases, literal_types, map_types, mixed_complex_types, nested_structures (+3 more sibling(s) not listed) — 8 of them are reported below, and 11 are counted here but not reported individually: those copies match on shape but no longer clear R10's bar for an individually reported row — either they kept neither their own names nor their values, or what was copied is too small to stand on its own (it reports near-exact duplication only, and only of substantial extent). What this row states is the concentration, which the detector measured over all 19 and which does not depend on how exactly each block's copies still match. That concentration is one structural fact, not 19 local ones: the siblings replicate behaviour none of them owns, which is the shape of a missing shared module — a common library every sibling imports — rather than 19 separate extractions. Check first whether the siblings are deliberately standalone deliverables (scaffold templates, demo apps that must stay copy-pasteable); where they are, the duplication is the design and the per-block rows are the ones to act on.
Duplication concentrated across 3 sibling directories (13 clone groups) typescript2/app-website/app/blog/_components/newsletter-form.tsx:4— 13 duplicated blocks under typescript2/app-website/ have copies in at least two of the sibling directories app, components, lib — 6 of them are reported below, and 7 are counted here but not reported individually: those copies match on shape but no longer clear R10's bar for an individually reported row — either they kept neither their own names nor their values, or what was copied is too small to stand on its own (it reports near-exact duplication only, and only of substantial extent). What this row states is the concentration, which the detector measured over all 13 and which does not depend on how exactly each block's copies still match. That concentration is one structural fact, not 13 local ones: the siblings replicate behaviour none of them owns, which is the shape of a missing shared module — a common library every sibling imports — rather than 13 separate extractions. Check first whether the siblings are deliberately standalone deliverables (scaffold templates, demo apps that must stay copy-pasteable); where they are, the duplication is the design and the per-block rows are the ones to act on.
Duplication concentrated across 6 sibling directories (13 clone groups) typescript2/app-website/app/atb/_components/runs-table.tsx:50— 13 duplicated blocks under typescript2/app-website/app/atb/ have copies in at least two of the sibling directories _components, agents, arena, builds, issues, runs — 10 of them are reported below, and 3 are counted here but not reported individually: those copies match on shape but no longer clear R10's bar for an individually reported row — either they kept neither their own names nor their values, or what was copied is too small to stand on its own (it reports near-exact duplication only, and only of substantial extent). What this row states is the concentration, which the detector measured over all 13 and which does not depend on how exactly each block's copies still match. That concentration is one structural fact, not 13 local ones: the siblings replicate behaviour none of them owns, which is the shape of a missing shared module — a common library every sibling imports — rather than 13 separate extractions. Check first whether the siblings are deliberately standalone deliverables (scaffold templates, demo apps that must stay copy-pasteable); where they are, the duplication is the design and the per-block rows are the ones to act on.
Duplication concentrated across 5 sibling directories (10 clone groups) typescript2/app-beps/src/components/decisions/decision-form.tsx:73— 10 of the duplicated blocks reported below have copies in at least two of the sibling directories bep, comments, decisions, issues, ui under typescript2/app-beps/src/components/. That concentration is one structural fact, not 10 local ones: the siblings replicate behaviour none of them owns, which is the shape of a missing shared module — a common library every sibling imports — rather than 10 separate extractions. Check first whether the siblings are deliberately standalone deliverables (scaffold templates, demo apps that must stay copy-pasteable); where they are, the duplication is the design and the per-block rows are the ones to act on.
Duplication concentrated across 4 sibling directories (7 clone groups) typescript2/app-beps/src/app/api/agent/beps/[number]/comments/route.ts:95— 7 duplicated blocks under typescript2/app-beps/src/ have copies in at least two of the sibling directories app, components, hooks, lib — 5 of them are reported below, and 2 are counted here but not reported individually: those copies match on shape but no longer clear R10's bar for an individually reported row — either they kept neither their own names nor their values, or what was copied is too small to stand on its own (it reports near-exact duplication only, and only of substantial extent). What this row states is the concentration, which the detector measured over all 7 and which does not depend on how exactly each block's copies still match. That concentration is one structural fact, not 7 local ones: the siblings replicate behaviour none of them owns, which is the shape of a missing shared module — a common library every sibling imports — rather than 7 separate extractions. Check first whether the siblings are deliberately standalone deliverables (scaffold templates, demo apps that must stay copy-pasteable); where they are, the duplication is the design and the per-block rows are the ones to act on.
Duplication concentrated across 2 sibling directories (5 clone groups) typescript/apps/vscode-ext/src/webview-to-vscode-rpc.ts:1— 5 of the duplicated blocks reported below have copies in at least two of the sibling directories apps, packages under typescript/. That concentration is one structural fact, not 5 local ones: the siblings replicate behaviour none of them owns, which is the shape of a missing shared module — a common library every sibling imports — rather than 5 separate extractions. Check first whether the siblings are deliberately standalone deliverables (scaffold templates, demo apps that must stay copy-pasteable); where they are, the duplication is the design and the per-block rows are the ones to act on.
Wholesale file copy (178 identical lines × 2 files) typescript2/app-website/app/blog/_components/newsletter-form.tsx:4— typescript2/app-website/app/blog/_components/newsletter-form.tsx:4 · typescript2/app-website/components/NewsletterForm.tsx:3 — these 2 files are line-for-line copies of one another — 178 lines are identical, in the same order, in every one of them — so this is one fact about the file set, not a block to extract. An edit made to one file and not the others changes behaviour silently, which is the failure a wholesale copy guarantees. Pick one file as the single source and derive the others from it (re-export it, spread it into the local overrides each variant genuinely needs, or generate the copies at build time) — the few lines that differ between the files are exactly the part each variant should still own. Check first whether the copies are deliberately standalone deliverables (a translation file seeded from its sibling and waiting to be translated); where they are, the duplication is the design, and the honest move is to mark the seeded file as untranslated rather than to let it pass as done.
Duplicated block (152 lines × 2 locations) typescript2/app-promptfiddle/src/playground/vfs.ts:147— typescript2/app-promptfiddle/src/playground/vfs.ts:147 · typescript2/app-website/playground/vfs.ts:159 — the 2 copies are spread across 2 files, 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.
R10 · Code Duplication· Duplicated block with local edits (147 matched lines × 2 locations) · ×1
Duplicated block with local edits (147 matched lines × 2 locations) typescript2/app-promptfiddle/src/playground/baml-lsp-worker.ts:856— typescript2/app-promptfiddle/src/playground/baml-lsp-worker.ts:856 · typescript2/app-website/playground/baml-worker.ts:641 — the two spans are one implementation copied and then locally edited — 773 tokens are still identical, in the same order in both files, 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 (141 matched lines × 2 locations) · ×1
Duplicated block with local edits (141 matched lines × 2 locations) REDACTED:15— REDACTED:15 · REDACTED:188 — the two spans are one implementation copied and then locally edited — 712 tokens are still identical, in the same order in both files, 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 (140 matched lines × 2 locations) · ×1
Duplicated block with local edits (140 matched lines × 2 locations) typescript2/app-beps/convex/decisions.ts:8— typescript2/app-beps/convex/decisions.ts:8 · typescript2/app-beps/convex/issues.ts:8 — the two spans are one implementation copied and then locally edited — 998 tokens are still identical, in the same order in both files, with only local edits between them. The copies have already begun to drift, which is this row's finding: an edit made to one and not the other changes behaviour silently. Diff the two spans first to learn what genuinely differs, then extract the shared core into one module both sites use, passing the differences in as parameters — or, if one copy exists only because the other could not be imported from its context, make one of them the single source the other is generated or re-exported from. If one copy is no longer reachable, delete it rather than letting it shadow the live one.
Duplicated block (138 lines × 2 locations) typescript/packages/playground-common/src/features/detail-panel/components/DetailPanel.tsx:324— typescript/packages/playground-common/src/features/detail-panel/components/DetailPanel.tsx:324 · typescript/packages/playground-common/src/features/detail-panel/components/DetailPanel.tsx:654 — all 2 copies are in the same file, and the SHAPE of this repetition could not be determined. It is not a run of declarations, a listing, a declaration header, a type body or a slice through a construct — and it was not measured as a run of executable statements either, so this row cannot tell you whether a function can stand where these lines are. Read the two spans before acting, because the move is opposite in the two cases. Where they are statements, the ordinary answer holds: give the shared part one home and call it from each site. Where they turn out to be declarations, a literal's entries, or the cases of an enumeration, there is no call site to call anything from, and collapsing them would delete what each copy pins — a shared base type, a generated set, or one exported constant each site refers to is the move instead, and sometimes the honest answer is that there is nothing to extract at all. Reported because the copies drift apart the first time only one of them is edited, which is true whichever of those they are.
Wholesale file copy (128 identical lines × 2 files) typescript/packages/ui/src/components/carousel.tsx:3— typescript/packages/ui/src/components/carousel.tsx:3 · typescript2/app-website/components/ui/carousel.tsx:4 — these 2 files are line-for-line copies of one another — 128 lines are identical, in the same order, in every one of them — so this is one fact about the file set, not a block to extract. An edit made to one file and not the others changes behaviour silently, which is the failure a wholesale copy guarantees. Pick one file as the single source and derive the others from it (re-export it, spread it into the local overrides each variant genuinely needs, or generate the copies at build time) — the few lines that differ between the files are exactly the part each variant should still own. Check first whether the copies are deliberately standalone deliverables (a translation file seeded from its sibling and waiting to be translated); where they are, the duplication is the design, and the honest move is to mark the seeded file as untranslated rather than to let it pass as done.
R10 · Code Duplication· Duplicated block with local edits (118 matched lines × 2 locations) · ×1
Duplicated block with local edits (118 matched lines × 2 locations) engine/language_client_typescript/errors.js:148— engine/language_client_typescript/errors.js:148 · engine/language_client_typescript/typescript_src/errors.ts:194 — the two spans are one implementation copied and then locally edited — 635 tokens are still identical, in the same order in both files, with only local edits between them. The copies have already begun to drift, which is this row's finding: an edit made to one and not the other changes behaviour silently. Diff the two spans first to learn what genuinely differs, then extract the shared core into one module both sites use, passing the differences in as parameters — or, if one copy exists only because the other could not be imported from its context, make one of them the single source the other is generated or re-exported from. If one copy is no longer reachable, delete it rather than letting it shadow the live one.
Duplicated block (116 lines × 2 locations) typescript/packages/ui/src/components/context-menu.tsx:110— typescript/packages/ui/src/components/context-menu.tsx:110 · typescript/packages/ui/src/components/menubar.tsx:87 — the 2 copies are spread across 2 files, 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.
R10 · Code Duplication· Duplicated block with local edits (116 matched lines × 2 locations) · ×1
Duplicated block with local edits (116 matched lines × 2 locations) typescript2/app-beps/src/components/comments/comment-feed-view.tsx:225— typescript2/app-beps/src/components/comments/comment-feed-view.tsx:225 · typescript2/app-beps/src/components/comments/comment-feed-view.tsx:565 — the two spans are one implementation copied and then locally edited — 675 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.
Wholesale file copy (106 identical lines × 2 files) typescript2/app-beps/src/components/ui/select.tsx:3— typescript2/app-beps/src/components/ui/select.tsx:3 · typescript2/app-feedback/src/components/ui/select.tsx:3 — these 2 files are line-for-line copies of one another — 106 lines are identical, in the same order, in every one of them — so this is one fact about the file set, not a block to extract. An edit made to one file and not the others changes behaviour silently, which is the failure a wholesale copy guarantees. Pick one file as the single source and derive the others from it (re-export it, spread it into the local overrides each variant genuinely needs, or generate the copies at build time) — the few lines that differ between the files are exactly the part each variant should still own. Check first whether the copies are deliberately standalone deliverables (a translation file seeded from its sibling and waiting to be translated); where they are, the duplication is the design, and the honest move is to mark the seeded file as untranslated rather than to let it pass as done.
R10 · Code Duplication· Duplicated block with local edits (95 matched lines × 2 locations) · ×1
Duplicated block with local edits (95 matched lines × 2 locations) typescript2/app-beps/src/components/bep/bep-list.tsx:47— typescript2/app-beps/src/components/bep/bep-list.tsx:47 · typescript2/app-feedback/src/components/issues/issue-list.tsx:114 — the two spans are one implementation copied and then locally edited — 555 tokens are still identical, in the same order in both files, with only local edits between them. The copies have already begun to drift, which is this row's finding: an edit made to one and not the other changes behaviour silently. Diff the two spans first to learn what genuinely differs, then extract the shared core into one module both sites use, passing the differences in as parameters — or, if one copy exists only because the other could not be imported from its context, make one of them the single source the other is generated or re-exported from. If one copy is no longer reachable, delete it rather than letting it shadow the live one.
Duplicated block (93 lines × 2 locations) typescript/packages/playground-common/src/features/detail-panel/components/DetailPanel.tsx:200— typescript/packages/playground-common/src/features/detail-panel/components/DetailPanel.tsx:200 · typescript/packages/playground-common/src/features/detail-panel/components/DetailPanel.tsx:534 — 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.
Wholesale file copy (92 identical lines × 2 files) typescript/apps/vscode-ext/src/webview-to-vscode-rpc.ts:1— typescript/apps/vscode-ext/src/webview-to-vscode-rpc.ts:1 · typescript/packages/playground-common/src/shared/baml-project-panel/webview-to-vscode-rpc.ts:1 — these 2 files are line-for-line copies of one another — 92 lines are identical, in the same order, in every one of them — so this is one fact about the file set, not a block to extract. An edit made to one file and not the others changes behaviour silently, which is the failure a wholesale copy guarantees. Pick one file as the single source and derive the others from it (re-export it, spread it into the local overrides each variant genuinely needs, or generate the copies at build time) — the few lines that differ between the files are exactly the part each variant should still own. Check first whether the copies are deliberately standalone deliverables (a translation file seeded from its sibling and waiting to be translated); where they are, the duplication is the design, and the honest move is to mark the seeded file as untranslated rather than to let it pass as done.
Duplicated block (91 lines × 2 locations) typescript2/app-promptfiddle/src/playground/baml-lsp-worker.ts:280— typescript2/app-promptfiddle/src/playground/baml-lsp-worker.ts:280 · typescript2/app-website/playground/baml-worker.ts:123 — the 2 copies are spread across 2 files, 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.
Wholesale file copy (84 identical lines × 2 files) typescript2/app-website/app/learn2/_deck/Deck.tsx:3— typescript2/app-website/app/learn2/_deck/Deck.tsx:3 · typescript2/app-website/app/learn3/_deck/Deck.tsx:3 — these 2 files are line-for-line copies of one another — 84 lines are identical, in the same order, in every one of them — so this is one fact about the file set, not a block to extract. An edit made to one file and not the others changes behaviour silently, which is the failure a wholesale copy guarantees. Pick one file as the single source and derive the others from it (re-export it, spread it into the local overrides each variant genuinely needs, or generate the copies at build time) — the few lines that differ between the files are exactly the part each variant should still own. Check first whether the copies are deliberately standalone deliverables (a translation file seeded from its sibling and waiting to be translated); where they are, the duplication is the design, and the honest move is to mark the seeded file as untranslated rather than to let it pass as done.
Wholesale file copy (80 identical lines × 2 files) typescript/packages/ui/src/components/select.tsx:3— typescript/packages/ui/src/components/select.tsx:3 · typescript2/app-website/components/ui/select.tsx:4 — these 2 files are line-for-line copies of one another — 80 lines are identical, in the same order, in every one of them — so this is one fact about the file set, not a block to extract. An edit made to one file and not the others changes behaviour silently, which is the failure a wholesale copy guarantees. Pick one file as the single source and derive the others from it (re-export it, spread it into the local overrides each variant genuinely needs, or generate the copies at build time) — the few lines that differ between the files are exactly the part each variant should still own. Check first whether the copies are deliberately standalone deliverables (a translation file seeded from its sibling and waiting to be translated); where they are, the duplication is the design, and the honest move is to mark the seeded file as untranslated rather than to let it pass as done.
R10 · Code Duplication· Duplicated block with local edits (73 matched lines × 2 locations) · ×1
Duplicated block with local edits (73 matched lines × 2 locations) typescript2/app-beps/src/components/decisions/decision-card.tsx:176— typescript2/app-beps/src/components/decisions/decision-card.tsx:176 · typescript2/app-beps/src/components/issues/issue-card.tsx:218 — the two spans are one implementation copied and then locally edited — 360 tokens are still identical, in the same order in both files, 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 (71 matched lines × 2 locations) · ×1
Duplicated block with local edits (71 matched lines × 2 locations) typescript2/app-developer-docs/app/baml/packages/[version]/[[...fqn]]/page.tsx:30— typescript2/app-developer-docs/app/baml/packages/[version]/[[...fqn]]/page.tsx:30 · typescript2/app-developer-docs/app/cli/[version]/[[...path]]/page.tsx:28 — the two spans are one implementation copied and then locally edited — 469 tokens are still identical, in the same order in both files, with only local edits between them. The copies have already begun to drift, which is this row's finding: an edit made to one and not the other changes behaviour silently. Diff the two spans first to learn what genuinely differs, then extract the shared core into one module both sites use, passing the differences in as parameters — or, if one copy exists only because the other could not be imported from its context, make one of them the single source the other is generated or re-exported from. If one copy is no longer reachable, delete it rather than letting it shadow the live one.
Duplicated block (70 lines × 2 locations) typescript/apps/vscode-ext/src/panels/vscode-to-webview-rpc.ts:4— typescript/apps/vscode-ext/src/panels/vscode-to-webview-rpc.ts:4 · typescript/packages/playground-common/src/baml_wasm_web/vscode-to-webview-rpc.ts:4 — the 2 copies are spread across 2 files, and the CITED SPAN is a run of DECLARATIONS inside a construct — the members of a type, or the entries of an object or array literal — with no statement anywhere in it. Do not read this as an extract-a-helper row: nothing here executes, so there is no call site, and a call expression cannot stand where a member declaration or a literal's entry was. What repeats is a SHAPE, and which shape decides the move. Where the copies declare the same members, the repetition is a missing common ancestor: give it a base type, an interface both extend, a generic instantiated twice, or — where the copies are a literal's entries rather than a type's members — one shared constant each site spreads or refers to, so the set is written once. Where they declare DIFFERENT members and only the form is shared — a decorator and its options, an annotation, a registration table's keys — the form is prescribed by a framework or a schema rather than copied, and the only collapse available is to generate the declarations from that schema; where you do not own the generator, this is the cost of the framework and there is nothing to extract. Check which of the two it is before acting: these copies still drift apart the first time only one of them is edited, which is why the repetition is reported, but the sentence to act on is not the same in both cases.
Duplicated block (68 lines × 2 locations) typescript2/app-promptfiddle/src/playground/vfs.ts:13— typescript2/app-promptfiddle/src/playground/vfs.ts:13 · typescript2/app-website/playground/vfs.ts:12 — the 2 copies are spread across 2 files, 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.
Wholesale file copy (67 identical lines × 2 files) typescript2/app-beps/src/components/ui/theme-toggle.tsx:3— typescript2/app-beps/src/components/ui/theme-toggle.tsx:3 · typescript2/app-feedback/src/components/ui/theme-toggle.tsx:3 — these 2 files are line-for-line copies of one another — 67 lines are identical, in the same order, in every one of them — so this is one fact about the file set, not a block to extract. An edit made to one file and not the others changes behaviour silently, which is the failure a wholesale copy guarantees. Pick one file as the single source and derive the others from it (re-export it, spread it into the local overrides each variant genuinely needs, or generate the copies at build time) — the few lines that differ between the files are exactly the part each variant should still own. Check first whether the copies are deliberately standalone deliverables (a translation file seeded from its sibling and waiting to be translated); where they are, the duplication is the design, and the honest move is to mark the seeded file as untranslated rather than to let it pass as done.
R10 · Code Duplication· Duplicated block with local edits (66 matched lines × 2 locations) · ×1
Duplicated block with local edits (66 matched lines × 2 locations) engine/language_client_typescript/stream.js:65— engine/language_client_typescript/stream.js:65 · engine/language_client_typescript/typescript_src/stream.ts:81 — the two spans are one implementation copied and then locally edited — 384 tokens are still identical, in the same order in both files, with only local edits between them. The copies have already begun to drift, which is this row's finding: an edit made to one and not the other changes behaviour silently. Diff the two spans first to learn what genuinely differs, then extract the shared core into one module both sites use, passing the differences in as parameters — or, if one copy exists only because the other could not be imported from its context, make one of them the single source the other is generated or re-exported from. If one copy is no longer reachable, delete it rather than letting it shadow the live one.
Duplicated block (65 lines × 2 locations) typescript2/app-beps/src/components/ui/card.tsx:5— typescript2/app-beps/src/components/ui/card.tsx:5 · typescript2/app-feedback/src/components/ui/card.tsx:5 — the 2 copies are spread across 2 directories, so the shared home is a decision rather than an obvious spot: check first whether one of them already owns this behaviour, and otherwise put the extracted module somewhere all of the sites already reach rather than making one of them depend on another.
Duplicated block (61 lines × 4 locations) engine/language_client_typescript/audio.js:2— engine/language_client_typescript/audio.js:2 · engine/language_client_typescript/image.js:2 · engine/language_client_typescript/pdf.js:2 · engine/language_client_typescript/video.js:2 — the 4 copies sit in sibling files in one directory, so check first whether one of them (or an existing module there) already owns this behaviour and the others should call it; otherwise extract it into one module in that directory and have each site call it. There is one copy in each of 4 separate files rather than several in one place, so check first whether these are sibling modules that each declare their own version of one shape — one per entity, per provider, per language. Where they are, no single extracted module collapses them: each module still has to be written, and what recurs is the TEMPLATE. The moves that do collapse a template are to generate these modules from the set they enumerate, or to replace the repeated construction with one factory each site calls with its own values — and where the set is the point, each module pinning one distinct thing, the repetition IS the enumeration and there is nothing to delete.
R10 · Code Duplication· Duplicated block with local edits (61 matched lines × 2 locations) · ×1
Duplicated block with local edits (61 matched lines × 2 locations) typescript2/app-website/convex/discord.ts:48— typescript2/app-website/convex/discord.ts:48 · typescript2/app-website/convex/loops.ts:83 — the two spans are one implementation copied and then locally edited — 388 tokens are still identical, in the same order in both files, 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.
Complex function ExecutionPanel (cyclomatic 105, cognitive 85) typescript2/pkg-playground/src/ExecutionPanel.tsx:494— ExecutionPanel has cyclomatic complexity 105 and cognitive complexity 85; 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 sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function BepRouteShell (cyclomatic 103, cognitive 97) typescript2/app-beps/src/components/bep/bep-route-shell.tsx:74— BepRouteShell has cyclomatic complexity 103 and cognitive complexity 97; 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 sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function onmessage (cyclomatic 96, cognitive 137) typescript2/app-website/playground/baml-worker.ts:394— onmessage has cyclomatic complexity 96 and cognitive complexity 137; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function onmessage (cyclomatic 88, cognitive 130) typescript2/app-promptfiddle/src/playground/baml-lsp-worker.ts:567— onmessage has cyclomatic complexity 88 and cognitive complexity 130; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function (anonymous) (cyclomatic 56, cognitive 49) typescript2/pkg-playground/src/ExecutionPanel.tsx:1108— (anonymous) has cyclomatic complexity 56 and cognitive complexity 49; 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 sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function WebviewMedia (cyclomatic 50, cognitive 48) typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/prompt-preview/webview-media.tsx:138— WebviewMedia has cyclomatic complexity 50 and cognitive complexity 48; 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 sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function OverviewTab (cyclomatic 47, cognitive 41) typescript2/pkg-playground/src/telemetry/TelemetryView.tsx:915— OverviewTab has cyclomatic complexity 47 and cognitive complexity 41; 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 sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function App (cyclomatic 46, cognitive 66) typescript2/app-speedtest/src/App.tsx:63— App has cyclomatic complexity 46 and cognitive complexity 66; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function RunPage (cyclomatic 45, cognitive 42) typescript2/app-website/app/atb/runs/[id]/page.tsx:27— RunPage has cyclomatic complexity 45 and cognitive complexity 42; 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 sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function testKitchenSink (cyclomatic 44, cognitive 42) engine/generators/data/mixed_complex_types/typescript/index.ts:3— testKitchenSink has cyclomatic complexity 44 and cognitive complexity 42; 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 sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function (anonymous) (cyclomatic 43, cognitive 61) typescript2/pkg-playground/src/run-store-client.ts:244— (anonymous) has cyclomatic complexity 43 and cognitive complexity 61; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function BepImportDialog (cyclomatic 39, cognitive 37) typescript2/app-beps/src/components/bep/bep-import-dialog.tsx:59— BepImportDialog has cyclomatic complexity 39 and cognitive complexity 37; 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 sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function fromServer (cyclomatic 39, cognitive 28) typescript2/pkg-playground/src/ports/WebSocketRuntimePort.ts:463— fromServer has cyclomatic complexity 39 and cognitive complexity 28; 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 sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function walkLibFile (cyclomatic 38, cognitive 81) tools/stdlib-matrix/extractors/ts-surface.mjs:337— walkLibFile has cyclomatic complexity 38 and cognitive complexity 81; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function (anonymous) (cyclomatic 35, cognitive 48) typescript2/app-product-metrics/src/http.ts:94— (anonymous) has cyclomatic complexity 35 and cognitive complexity 48; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function testSimpleNested (cyclomatic 34, cognitive 33) engine/generators/data/nested_structures/typescript/index.ts:3— testSimpleNested has cyclomatic complexity 34 and cognitive complexity 33; 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 sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function ContextInspector (cyclomatic 34, cognitive 32) typescript2/pkg-playground/src/telemetry/TelemetryView.tsx:3192— ContextInspector has cyclomatic complexity 34 and cognitive complexity 32; 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 sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function matches (cyclomatic 34, cognitive 27) typescript2/pkg-playground/src/args-form-model.ts:232— matches has cyclomatic complexity 34 and cognitive complexity 27; 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 sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function parseWatchValue (cyclomatic 33, cognitive 79) typescript/packages/playground-common/src/sdk/sdk.ts:1036— parseWatchValue has cyclomatic complexity 33 and cognitive complexity 79; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function (anonymous) (cyclomatic 32, cognitive 51) typescript2/app-website/components/HistoryOfLanguages/useParticleEngine.ts:89— (anonymous) has cyclomatic complexity 32 and cognitive complexity 51; 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· typescript2/pkg-playground/src/ExecutionPanel.tsx · ×1
typescript2/pkg-playground/src/ExecutionPanel.tsx: 3614 lines of code typescript2/pkg-playground/src/ExecutionPanel.tsx:1— typescript2/pkg-playground/src/ExecutionPanel.tsx has 3614 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· typescript2/pkg-playground/src/telemetry/TelemetryView.tsx · ×1
typescript2/pkg-playground/src/telemetry/TelemetryView.tsx: 3339 lines of code typescript2/pkg-playground/src/telemetry/TelemetryView.tsx:1— typescript2/pkg-playground/src/telemetry/TelemetryView.tsx has 3339 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· typescript2/app-website/components/icons.tsx · ×1
typescript2/app-website/components/icons.tsx: 2463 lines of code typescript2/app-website/components/icons.tsx:1— typescript2/app-website/components/icons.tsx has 2463 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· typescript2/pkg-grammar/src/baml.ts · ×1
typescript2/pkg-grammar/src/baml.ts: 2425 lines of code typescript2/pkg-grammar/src/baml.ts:1— typescript2/pkg-grammar/src/baml.ts has 2425 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
REDACTED: 1701 lines of code REDACTED:1— REDACTED has 1701 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· typescript2/app-website/components/landing/vs-client.tsx · ×1
typescript2/app-website/components/landing/vs-client.tsx: 1656 lines of code typescript2/app-website/components/landing/vs-client.tsx:1— typescript2/app-website/components/landing/vs-client.tsx has 1656 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· typescript/packages/playground-common/src/sdk/sdk.ts · ×1
typescript/packages/playground-common/src/sdk/sdk.ts: 1337 lines of code typescript/packages/playground-common/src/sdk/sdk.ts:1— typescript/packages/playground-common/src/sdk/sdk.ts has 1337 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· typescript2/pkg-editor/src/MonacoEditor.tsx · ×1
typescript2/pkg-editor/src/MonacoEditor.tsx: 1316 lines of code typescript2/pkg-editor/src/MonacoEditor.tsx:1— typescript2/pkg-editor/src/MonacoEditor.tsx has 1316 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· typescript2/app-website/app/baml-intro/_components/article.tsx · ×1
typescript2/app-website/app/baml-intro/_components/article.tsx: 1263 lines of code typescript2/app-website/app/baml-intro/_components/article.tsx:1— typescript2/app-website/app/baml-intro/_components/article.tsx has 1263 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· typescript2/app-website/components/landing/incremental-adoption.tsx · ×1
typescript2/app-website/components/landing/incremental-adoption.tsx: 1217 lines of code typescript2/app-website/components/landing/incremental-adoption.tsx:1— typescript2/app-website/components/landing/incremental-adoption.tsx has 1217 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· typescript2/pkg-playground/src/worker-protocol.ts · ×1
typescript2/pkg-playground/src/worker-protocol.ts: 1186 lines of code typescript2/pkg-playground/src/worker-protocol.ts:1— typescript2/pkg-playground/src/worker-protocol.ts has 1186 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· typescript2/pkg-grammar-treesitter/grammar.js · ×1
typescript2/pkg-grammar-treesitter/grammar.js: 1161 lines of code typescript2/pkg-grammar-treesitter/grammar.js:1— typescript2/pkg-grammar-treesitter/grammar.js has 1161 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· typescript2/app-website/lib/mdx/bfcl/_components/TestResultsTable.tsx · ×1
typescript2/app-website/lib/mdx/bfcl/_components/TestResultsTable.tsx: 1131 lines of code typescript2/app-website/lib/mdx/bfcl/_components/TestResultsTable.tsx:1— typescript2/app-website/lib/mdx/bfcl/_components/TestResultsTable.tsx has 1131 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· typescript2/app-website/app/learn4/_components/story.tsx · ×1
typescript2/app-website/app/learn4/_components/story.tsx: 1118 lines of code typescript2/app-website/app/learn4/_components/story.tsx:1— typescript2/app-website/app/learn4/_components/story.tsx has 1118 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· typescript2/pkg-playground/src/telemetry/evidence.ts · ×1
typescript2/pkg-playground/src/telemetry/evidence.ts: 1064 lines of code typescript2/pkg-playground/src/telemetry/evidence.ts:1— typescript2/pkg-playground/src/telemetry/evidence.ts has 1064 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· typescript/packages/playground-common/src/sdk/runtime/BamlRuntime.ts · ×1
typescript/packages/playground-common/src/sdk/runtime/BamlRuntime.ts: 1050 lines of code typescript/packages/playground-common/src/sdk/runtime/BamlRuntime.ts:1— typescript/packages/playground-common/src/sdk/runtime/BamlRuntime.ts has 1050 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· typescript2/app-beps/src/components/bep/bep-route-shell.tsx · ×1
typescript2/app-beps/src/components/bep/bep-route-shell.tsx: 1044 lines of code typescript2/app-beps/src/components/bep/bep-route-shell.tsx:1— typescript2/app-beps/src/components/bep/bep-route-shell.tsx has 1044 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· typescript/apps/vscode-ext/src/plugins/language-server-client/index.ts · ×1
typescript/apps/vscode-ext/src/plugins/language-server-client/index.ts: 979 lines of code typescript/apps/vscode-ext/src/plugins/language-server-client/index.ts:1— typescript/apps/vscode-ext/src/plugins/language-server-client/index.ts has 979 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· typescript2/app-website/app/learn2/_deck/slides.tsx · ×1
typescript2/app-website/app/learn2/_deck/slides.tsx: 979 lines of code typescript2/app-website/app/learn2/_deck/slides.tsx:1— typescript2/app-website/app/learn2/_deck/slides.tsx has 979 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· typescript2/app-website/components/landing/variant-home.tsx · ×1
typescript2/app-website/components/landing/variant-home.tsx: 962 lines of code typescript2/app-website/components/landing/variant-home.tsx:1— typescript2/app-website/components/landing/variant-home.tsx has 962 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· typescript2/app-beps/src/components/comments/comment-feed-view.tsx · ×1
typescript2/app-beps/src/components/comments/comment-feed-view.tsx: 941 lines of code typescript2/app-beps/src/components/comments/comment-feed-view.tsx:1— typescript2/app-beps/src/components/comments/comment-feed-view.tsx has 941 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· typescript2/app-beps/src/components/comments/comment-sidebar.tsx · ×1
typescript2/app-beps/src/components/comments/comment-sidebar.tsx: 906 lines of code typescript2/app-beps/src/components/comments/comment-sidebar.tsx:1— typescript2/app-beps/src/components/comments/comment-sidebar.tsx has 906 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· typescript2/app-website/app/learn3/_deck/slides.tsx · ×1
typescript2/app-website/app/learn3/_deck/slides.tsx: 896 lines of code typescript2/app-website/app/learn3/_deck/slides.tsx:1— typescript2/app-website/app/learn3/_deck/slides.tsx has 896 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· typescript2/app-beps/src/lib/export-utils.ts · ×1
typescript2/app-beps/src/lib/export-utils.ts: 873 lines of code typescript2/app-beps/src/lib/export-utils.ts:1— typescript2/app-beps/src/lib/export-utils.ts has 873 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· typescript2/app-type-quiz/src/app.tsx · ×1
typescript2/app-type-quiz/src/app.tsx: 820 lines of code typescript2/app-type-quiz/src/app.tsx:1— typescript2/app-type-quiz/src/app.tsx has 820 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· typescript/packages/playground-common/src/sdk/atoms/core.atoms.ts · ×1
typescript/packages/playground-common/src/sdk/atoms/core.atoms.ts: 818 lines of code typescript/packages/playground-common/src/sdk/atoms/core.atoms.ts:1— typescript/packages/playground-common/src/sdk/atoms/core.atoms.ts has 818 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· typescript2/pkg-playground/src/graph/GraphView.tsx · ×1
typescript2/pkg-playground/src/graph/GraphView.tsx: 817 lines of code typescript2/pkg-playground/src/graph/GraphView.tsx:1— typescript2/pkg-playground/src/graph/GraphView.tsx has 817 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· typescript2/app-website/app/what-is-baml/page.tsx · ×1
typescript2/app-website/app/what-is-baml/page.tsx: 805 lines of code typescript2/app-website/app/what-is-baml/page.tsx:1— typescript2/app-website/app/what-is-baml/page.tsx has 805 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/prompt-preview/webview-media.tsx · ×1
typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/prompt-preview/webview-media.tsx: 800 lines of code typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/prompt-preview/webview-media.tsx:1— typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/prompt-preview/webview-media.tsx has 800 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· typescript/packages/playground-common/src/features/detail-panel/components/DetailPanel.tsx · ×1
typescript/packages/playground-common/src/features/detail-panel/components/DetailPanel.tsx: 793 lines of code typescript/packages/playground-common/src/features/detail-panel/components/DetailPanel.tsx:1— typescript/packages/playground-common/src/features/detail-panel/components/DetailPanel.tsx has 793 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· typescript2/app-website/app/learn2/_lib/baml-monarch.ts · ×1
typescript2/app-website/app/learn2/_lib/baml-monarch.ts: 792 lines of code typescript2/app-website/app/learn2/_lib/baml-monarch.ts:1— typescript2/app-website/app/learn2/_lib/baml-monarch.ts has 792 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· typescript2/app-website/app/baml-intro/_components/TenetsAccordion.tsx · ×1
typescript2/app-website/app/baml-intro/_components/TenetsAccordion.tsx: 789 lines of code typescript2/app-website/app/baml-intro/_components/TenetsAccordion.tsx:1— typescript2/app-website/app/baml-intro/_components/TenetsAccordion.tsx has 789 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· typescript2/app-beps/convex/beps.ts · ×1
typescript2/app-beps/convex/beps.ts: 775 lines of code typescript2/app-beps/convex/beps.ts:1— typescript2/app-beps/convex/beps.ts has 775 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· typescript2/app-website/app/baml-intro/_components/snippets.ts · ×1
typescript2/app-website/app/baml-intro/_components/snippets.ts: 763 lines of code typescript2/app-website/app/baml-intro/_components/snippets.ts:1— typescript2/app-website/app/baml-intro/_components/snippets.ts has 763 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· typescript2/app-website/app/_lib/config.tsx · ×1
typescript2/app-website/app/_lib/config.tsx: 755 lines of code typescript2/app-website/app/_lib/config.tsx:1— typescript2/app-website/app/_lib/config.tsx has 755 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· typescript/packages/playground-common/src/sdk/mock-config/config.ts · ×1
typescript/packages/playground-common/src/sdk/mock-config/config.ts: 751 lines of code typescript/packages/playground-common/src/sdk/mock-config/config.ts:1— typescript/packages/playground-common/src/sdk/mock-config/config.ts has 751 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
REDACTED: 727 lines of code REDACTED:1— REDACTED has 727 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· typescript2/pkg-playground/src/ArgsForm.tsx · ×1
typescript2/pkg-playground/src/ArgsForm.tsx: 714 lines of code typescript2/pkg-playground/src/ArgsForm.tsx:1— typescript2/pkg-playground/src/ArgsForm.tsx has 714 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· typescript/packages/ui/src/components/sidebar.tsx · ×1
typescript/packages/ui/src/components/sidebar.tsx: 673 lines of code typescript/packages/ui/src/components/sidebar.tsx:1— typescript/packages/ui/src/components/sidebar.tsx has 673 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· typescript2/pkg-playground/src/FunctionSidebar.tsx · ×1
typescript2/pkg-playground/src/FunctionSidebar.tsx: 671 lines of code typescript2/pkg-playground/src/FunctionSidebar.tsx:1— typescript2/pkg-playground/src/FunctionSidebar.tsx has 671 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
Dead file (~1783 LoC) REDACTED— no import path from any entry point (371 application, 97 tooling, 220 test roots considered), and no other file in the scanned tree imports it — nothing in-repo names this module at all, which is the strongest form of this claim the import graph can make
Dead file (~1762 LoC) typescript2/app-website/components/landing/vs-client.tsx— no import path from any entry point (371 application, 97 tooling, 220 test roots considered), and no other file in the scanned tree imports it — nothing in-repo names this module at all, which is the strongest form of this claim the import graph can make
Dead file (~1335 LoC) typescript2/pkg-grammar-treesitter/grammar.js— no import path from any entry point (371 application, 97 tooling, 220 test roots considered), and no other file in the scanned tree imports it — nothing in-repo names this module at all, which is the strongest form of this claim the import graph can make
Dead file (~1286 LoC) typescript2/app-website/components/landing/incremental-adoption.tsx— no import path from any entry point (371 application, 97 tooling, 220 test roots considered), and no other file in the scanned tree imports it — nothing in-repo names this module at all, which is the strongest form of this claim the import graph can make
Dead file (~1229 LoC) typescript2/app-website/app/learn4/_components/story.tsx— no import path from any entry point (371 application, 97 tooling, 220 test roots considered), and no other file in the scanned tree imports it — nothing in-repo names this module at all, which is the strongest form of this claim the import graph can make
Dead file (~1074 LoC) typescript2/app-website/app/learn2/_deck/slides.tsx— no import path from any entry point (371 application, 97 tooling, 220 test roots considered), but 1 in-repo import(s) from 1 other file(s) do name it (typescript2/app-website/app/learn2/_deck/Deck.tsx) — every one of those referrers is itself unreachable, so this file is dead only as a member of that cluster: if any referrer is in fact alive, this row falls with it
Dead file (~992 LoC) typescript2/app-website/components/landing/variant-home.tsx— no import path from any entry point (371 application, 97 tooling, 220 test roots considered), and no other file in the scanned tree imports it — nothing in-repo names this module at all, which is the strongest form of this claim the import graph can make
Dead file (~974 LoC) typescript2/app-website/app/learn3/_deck/slides.tsx— no import path from any entry point (371 application, 97 tooling, 220 test roots considered), but 1 in-repo import(s) from 1 other file(s) do name it (typescript2/app-website/app/learn3/_deck/Deck.tsx) — every one of those referrers is itself unreachable, so this file is dead only as a member of that cluster: if any referrer is in fact alive, this row falls with it
Dead file (~560 LoC) typescript/packages/playground-common/src/graph-primitives/edges/EdgeController/smart-edge.ts— no import path from any entry point (371 application, 97 tooling, 220 test roots considered), but 2 in-repo import(s) from 2 other file(s) do name it (typescript/packages/playground-common/src/graph-primitives/edges/EdgeController/index.tsx, typescript/packages/playground-common/src/graph-primitives/edges/EdgeController/useEdgeDraggable.tsx) — every one of those referrers is itself unreachable, so this file is dead only as a member of that cluster: if any referrer is in fact alive, this row falls with it
Dead file (~515 LoC) typescript2/app-developer-docs/tools/oxlint/anti-slop/shared/dictionary-types.ts— no import path from any entry point (371 application, 97 tooling, 220 test roots considered), but 2 in-repo import(s) from 2 other file(s) do name it (typescript2/app-developer-docs/tools/oxlint/anti-slop/rules/no-known-value-widening.ts, typescript2/app-developer-docs/tools/oxlint/anti-slop/rules/no-unsafe-dictionary-type.ts) — every one of those referrers is itself unreachable, so this file is dead only as a member of that cluster: if any referrer is in fact alive, this row falls with it
Dead file (~493 LoC) typescript2/app-website/components/landing/language-fanout.tsx— no import path from any entry point (371 application, 97 tooling, 220 test roots considered), and no other file in the scanned tree imports it — nothing in-repo names this module at all, which is the strongest form of this claim the import graph can make
Dead file (~427 LoC) typescript2/app-developer-docs/tools/oxlint/anti-slop/rules/no-known-value-widening.ts— no import path from any entry point (371 application, 97 tooling, 220 test roots considered), but 1 in-repo import(s) from 1 other file(s) do name it (typescript2/app-developer-docs/tools/oxlint/anti-slop/index.ts) — every one of those referrers is itself unreachable, so this file is dead only as a member of that cluster: if any referrer is in fact alive, this row falls with it
Dead file (~415 LoC) typescript2/app-website/components/magicui/text-animate.tsx— no import path from any entry point (371 application, 97 tooling, 220 test roots considered), and no other file in the scanned tree imports it — nothing in-repo names this module at all, which is the strongest form of this claim the import graph can make
Dead file (~392 LoC) typescript2/app-website/components/magicui/file-tree.tsx— no import path from any entry point (371 application, 97 tooling, 220 test roots considered), and no other file in the scanned tree imports it — nothing in-repo names this module at all, which is the strongest form of this claim the import graph can make
Dead file (~384 LoC) typescript2/app-website/components/ParticleImage.tsx— no import path from any entry point (371 application, 97 tooling, 220 test roots considered), but 2 in-repo import(s) from 2 other file(s) do name it (typescript2/app-website/components/HistoryOfLanguages/ParticleCanvas.tsx, typescript2/app-website/components/landing/story-timeline.tsx) — every one of those referrers is itself unreachable, so this file is dead only as a member of that cluster: if any referrer is in fact alive, this row falls with it
Dead file (~366 LoC) typescript2/app-developer-docs/tools/oxlint/anti-slop/rules/no-widen-then-assert.ts— no import path from any entry point (371 application, 97 tooling, 220 test roots considered), but 1 in-repo import(s) from 1 other file(s) do name it (typescript2/app-developer-docs/tools/oxlint/anti-slop/index.ts) — every one of those referrers is itself unreachable, so this file is dead only as a member of that cluster: if any referrer is in fact alive, this row falls with it
Dead file (~349 LoC) typescript2/app-website/components/landing/why-a-language.tsx— no import path from any entry point (371 application, 97 tooling, 220 test roots considered), and no other file in the scanned tree imports it — nothing in-repo names this module at all, which is the strongest form of this claim the import graph can make
Dead file (~340 LoC) typescript2/app-website/components/HistoryOfLanguages/shapes.ts— no import path from any entry point (371 application, 97 tooling, 220 test roots considered), but 4 in-repo import(s) from 3 other file(s) do name it (typescript2/app-website/components/HistoryOfLanguages/ParticleCanvas.tsx, typescript2/app-website/components/HistoryOfLanguages/constants.ts, typescript2/app-website/components/HistoryOfLanguages/useParticleEngine.ts) — every one of those referrers is itself unreachable, so this file is dead only as a member of that cluster: if any referrer is in fact alive, this row falls with it
Dead file (~330 LoC) typescript2/app-website/components/landing/story-timeline.tsx— no import path from any entry point (371 application, 97 tooling, 220 test roots considered), and no other file in the scanned tree imports it — nothing in-repo names this module at all, which is the strongest form of this claim the import graph can make
Dead file (~322 LoC) typescript2/app-website/components/landing/feature-animations/parser-animation.tsx— no import path from any entry point (371 application, 97 tooling, 220 test roots considered), but 1 in-repo import(s) from 1 other file(s) do name it (typescript2/app-website/components/landing/feature-animations/index.tsx) — every one of those referrers is itself unreachable, so this file is dead only as a member of that cluster: if any referrer is in fact alive, this row falls with it
Dead file (~289 LoC) typescript2/app-website/components/landing/feature-animations/typed-errors-animation.tsx— no import path from any entry point (371 application, 97 tooling, 220 test roots considered), but 1 in-repo import(s) from 1 other file(s) do name it (typescript2/app-website/components/landing/feature-animations/index.tsx) — every one of those referrers is itself unreachable, so this file is dead only as a member of that cluster: if any referrer is in fact alive, this row falls with it
Dead file (~285 LoC) typescript2/app-website/app/blog/_components/newsletter-form.tsx— no import path from any entry point (371 application, 97 tooling, 220 test roots considered), and no other file in the scanned tree imports it — nothing in-repo names this module at all, which is the strongest form of this claim the import graph can make
Dead file (~284 LoC) typescript2/app-website/components/landing/feature-animations/streaming-animation.tsx— no import path from any entry point (371 application, 97 tooling, 220 test roots considered), but 1 in-repo import(s) from 1 other file(s) do name it (typescript2/app-website/components/landing/feature-animations/index.tsx) — every one of those referrers is itself unreachable, so this file is dead only as a member of that cluster: if any referrer is in fact alive, this row falls with it
Dead file (~279 LoC) typescript2/app-website/playground/BamlPlayground.tsx— no import path from any entry point (371 application, 97 tooling, 220 test roots considered), but 1 in-repo import(s) from 1 other file(s) do name it (typescript2/app-website/components/landing/playground-showcase.tsx) — every one of those referrers is itself unreachable, so this file is dead only as a member of that cluster: if any referrer is in fact alive, this row falls with it
Dead file (~276 LoC) typescript2/app-website/components/landing/feature-animations/describe-animation.tsx— no import path from any entry point (371 application, 97 tooling, 220 test roots considered), but 1 in-repo import(s) from 1 other file(s) do name it (typescript2/app-website/components/landing/feature-animations/index.tsx) — every one of those referrers is itself unreachable, so this file is dead only as a member of that cluster: if any referrer is in fact alive, this row falls with it
Dead file (~271 LoC) typescript2/app-website/app/podcast/_components/episode-modal.tsx— no import path from any entry point (371 application, 97 tooling, 220 test roots considered), and no other file in the scanned tree imports it — nothing in-repo names this module at all, which is the strongest form of this claim the import graph can make
Dead file (~270 LoC) typescript2/app-website/components/magicui/particles.tsx— no import path from any entry point (371 application, 97 tooling, 220 test roots considered), and no other file in the scanned tree imports it — nothing in-repo names this module at all, which is the strongest form of this claim the import graph can make
Dead file (~260 LoC) typescript2/app-website/components/landing/hero-section.tsx— no import path from any entry point (371 application, 97 tooling, 220 test roots considered), and no other file in the scanned tree imports it — nothing in-repo names this module at all, which is the strongest form of this claim the import graph can make
Dead file (~250 LoC) typescript2/app-developer-docs/tools/oxlint/anti-slop/shared/type-alias-resolution.ts— no import path from any entry point (371 application, 97 tooling, 220 test roots considered), but 5 in-repo import(s) from 5 other file(s) do name it (typescript2/app-developer-docs/tools/oxlint/anti-slop/rules/no-object-parameters.ts, typescript2/app-developer-docs/tools/oxlint/anti-slop/rules/no-unknown-returns.ts, typescript2/app-developer-docs/tools/oxlint/anti-slop/rules/no-unknown-type-aliases.ts and 2 more) — every one of those referrers is itself unreachable, so this file is dead only as a member of that cluster: if any referrer is in fact alive, this row falls with it
Dead file (~241 LoC) typescript2/app-website/components/HistoryOfLanguages/useParticleEngine.ts— no import path from any entry point (371 application, 97 tooling, 220 test roots considered), but 2 in-repo import(s) from 1 other file(s) do name it (typescript2/app-website/components/HistoryOfLanguages/ParticleCanvas.tsx) — every one of those referrers is itself unreachable, so this file is dead only as a member of that cluster: if any referrer is in fact alive, this row falls with it
Dead file (~235 LoC) typescript2/app-website/components/landing/hero-playground-mockup.tsx— no import path from any entry point (371 application, 97 tooling, 220 test roots considered), and no other file in the scanned tree imports it — nothing in-repo names this module at all, which is the strongest form of this claim the import graph can make
Dead file (~225 LoC) typescript2/app-website/playground/homepage-example.ts— no import path from any entry point (371 application, 97 tooling, 220 test roots considered), but 2 in-repo import(s) from 2 other file(s) do name it (typescript2/app-website/components/landing/variant-home.tsx, typescript2/app-website/playground/BamlPlayground.tsx) — every one of those referrers is itself unreachable, so this file is dead only as a member of that cluster: if any referrer is in fact alive, this row falls with it
Dead file (~224 LoC) typescript2/app-website/app/learn3/_components/MetricsDag.tsx— no import path from any entry point (371 application, 97 tooling, 220 test roots considered), but 2 in-repo import(s) from 2 other file(s) do name it (typescript2/app-website/app/learn3/_deck/slides.tsx, typescript2/app-website/app/learn4/_components/story.tsx) — every one of those referrers is itself unreachable, so this file is dead only as a member of that cluster: if any referrer is in fact alive, this row falls with it
Dead file (~213 LoC) typescript2/app-website/components/landing/feature-animations/tests-animation.tsx— no import path from any entry point (371 application, 97 tooling, 220 test roots considered), but 1 in-repo import(s) from 1 other file(s) do name it (typescript2/app-website/components/landing/feature-animations/index.tsx) — every one of those referrers is itself unreachable, so this file is dead only as a member of that cluster: if any referrer is in fact alive, this row falls with it
Unused dependency 'vercel' — Declared in the root REDACTED but never imported anywhere in that package or its workspace members — no static import reaches it. Usually that is dead weight and attack surface, but two shapes are indistinguishable from source and are NOT dead: an optional or native peer that another dependency loads dynamically at runtime, and a package a build, docs or test step installs and invokes separately. Confirm which of the three this is before removing it.
Unused dependency 'wrangler' — Declared in baml_language/sdks/typescript/bridge_typescript_web/REDACTED but never imported anywhere in that package or its workspace members — no static import reaches it. Usually that is dead weight and attack surface, but two shapes are indistinguishable from source and are NOT dead: an optional or native peer that another dependency loads dynamically at runtime, and a package a build, docs or test step installs and invokes separately. Confirm which of the three this is before removing it.
Unused dependency 'npm-run-all2' — Declared in engine/language_client_typescript/REDACTED 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.
SC1 · Supply-chain hygiene· NuGet dependencies are not locked · ×1
NuGet dependencies are not locked — No packages.lock.json and no central package management — restores aren't reproducible or pinned (SSDF PW.4.4). Enable <RestorePackagesWithLockFile>true</RestorePackagesWithLockFile> (commit the lockfile) or adopt Directory.Packages.props. Advisory — never scored.
Orphaned file engine/baml-runtime/src/optimize/schema_extractor.rs:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file engine/baml-runtime/src/internal/llm_client/primitive/vertex/types.rs:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/prompt-preview/test-panel/components/EnhancedErrorRenderer.tsx:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file engine/baml-runtime/src/test_constraints.rs:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file engine/baml-runtime/src/optimize/storage.rs:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file engine/baml-runtime/src/optimize/gepa_runtime.rs:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file integ-tests/react/src/components/network-timeline/index.tsx:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file integ-tests/react/src/lib/store.ts:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file engine/baml-runtime/src/optimize/candidate.rs:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file engine/language_server/src/server/schedule/thread/priority.rs:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file engine/baml-runtime/src/internal/llm_client/primitive/google/types.rs:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file engine/language_server/src/baml_source_file/line_index.rs:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file engine/generators/languages/python/src/watchers.rs:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file engine/generators/languages/typescript/src/watchers.rs:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file engine/baml-compiler/src/watch/watch_event.rs:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file engine/language_server/src/baml_source_file/newlines.rs:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file engine/language_server/src/baml_text_size/range.rs:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/side-bar/function-item.tsx:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file integ-tests/react/src/components/test-client/response-card.tsx:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file engine/language_server/src/edit/range.rs:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file engine/language_server/src/baml_source_file/mod.rs:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file engine/language_server/src/server/client.rs:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file integ-tests/react/src/components/test-client/tab-config-menu.tsx:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file engine/baml-lib/ast/src/ast/baml_vis/diagram_generator.rs:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Orphaned file engine/language_server/src/session/settings.rs:1— No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
Duplicated predicate baml_language/sdk_tests/crates/csharp/host_callables/Program.cs:407— `HostValueRegistry.Shared.EntryCount == 0 && HostValueRegistry.Shared.InvocationCount == 0 && NativeCallbacks.PendingCount == 0` appears character-identically in 2 files — baml_language/sdk_tests/crates/csharp/host_callables/Program.cs, baml_language/sdk_tests/crates/csharp/primitive_edges/Program.cs. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate baml_language/sdks/go/baml_go/runtime.go:259— `math.IsNaN(parsed) || math.IsInf(parsed, 0)` appears character-identically in 2 files — baml_language/sdks/go/baml_go/runtime.go, baml_language/sdks/go/baml_go/value.go. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate baml_language/sdks/go/baml_go/host_callable.go:325— `name == "" || name[0] < 'A' || name[0] > 'Z'` appears character-identically in 2 files — baml_language/sdks/go/baml_go/host_callable.go, REDACTED. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate baml_language/sdks/java/baml_bridge/src/main/java/baml_bridge/internal/NativeLibraryLoader.java:135— `n.contains("linux") || n.contains("nix") || n.contains("nux")` appears character-identically in 2 files — baml_language/sdks/java/baml_bridge/src/main/java/baml_bridge/internal/NativeLibraryLoader.java, baml_language/sdks/java/gradle-plugin/src/main/java/com/boundaryml/baml/gradle/BamlPlugin.java. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate baml_language/sdks/java/baml_bridge/src/main/java/baml_bridge/internal/NativeLibraryLoader.java:129— `n.contains("mac") || n.contains("darwin") || n.contains("osx")` appears character-identically in 2 files — baml_language/sdks/java/baml_bridge/src/main/java/baml_bridge/internal/NativeLibraryLoader.java, baml_language/sdks/java/gradle-plugin/src/main/java/com/boundaryml/baml/gradle/BamlPlugin.java. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate typescript2/app-developer-docs/tools/oxlint/anti-slop/rules/no-module-mocking.ts:52— `!("property" in callee) || !("object" in callee) || !("computed" in callee)` appears character-identically in 2 files — typescript2/app-developer-docs/tools/oxlint/anti-slop/rules/no-module-mocking.ts, typescript2/app-developer-docs/tools/oxlint/anti-slop/shared/reflect-method.ts. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate typescript2/app-product-metrics/src/external-data.ts:41— `!Number.isFinite(date.getTime()) || date.toISOString().slice(0, 10) !== value` appears character-identically in 2 files — typescript2/app-product-metrics/src/external-data.ts, typescript2/app-product-metrics/src/jobs/aggregate-weekly-metric.ts. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate typescript2/app-product-metrics/scripts/backfill-six-weeks.ts:57— `!Number.isSafeInteger(value) || value < 0` appears character-identically in 2 files — typescript2/app-product-metrics/scripts/backfill-six-weeks.ts, typescript2/app-product-metrics/src/jobs/aggregate-weekly-metric.ts. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate REDACTED:133— `!body.content || typeof body.content !== "string"` appears character-identically in 2 files — REDACTED, REDACTED. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/prompt-preview/prompt-preview-curl.tsx:117— `!searchQuery || searchQuery.trim() === ''` appears character-identically in 2 files — typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/prompt-preview/prompt-preview-curl.tsx, typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/prompt-preview/render-text.tsx. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate typescript/packages/playground-common/src/shared/baml-project-panel/atomWithDebounce.ts:40— `!shouldDebounceOnReset && nextValue === initialValue` appears character-identically in 2 files — typescript/packages/playground-common/src/shared/baml-project-panel/atomWithDebounce.ts, typescript2/app-website/lib/mdx/baml-block/baml-project-panel/atomWithDebounce.ts. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate typescript/packages/playground-common/src/graph-primitives/nodes/BaseNode/index.tsx:122— `!stateStyle || typeof stateStyle === 'object' && !('active' in stateStyle)` appears character-identically in 3 files — typescript/packages/playground-common/src/graph-primitives/nodes/BaseNode/index.tsx, typescript/packages/playground-common/src/graph-primitives/nodes/DiamondNode/index.tsx, typescript/packages/playground-common/src/graph-primitives/nodes/LLMNode/index.tsx. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate typescript2/app-product-metrics/scripts/fetch-zoom-six-weeks.ts:42— `!tokenResponse.ok || typeof tokenBody.access_token !== 'string'` appears character-identically in 2 files — typescript2/app-product-metrics/scripts/fetch-zoom-six-weeks.ts, typescript2/app-product-metrics/src/clients/zoom.ts. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate typescript2/app-product-metrics/src/clients/discord.ts:22— `!value || typeof value !== 'object' || Array.isArray(value)` appears character-identically in 5 files — typescript2/app-product-metrics/src/clients/discord.ts, typescript2/app-product-metrics/src/clients/zoom.ts, typescript2/app-product-metrics/src/external-data.ts, typescript2/app-product-metrics/src/jobs/aggregate-weekly-metric.ts. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate typescript/packages/playground-common/src/shared/baml-project-panel/codemirror-panel/code-mirror-viewer.tsx:417— `(e.metaKey || e.ctrlKey) && e.key === 's'` appears character-identically in 2 files — typescript/packages/playground-common/src/shared/baml-project-panel/codemirror-panel/code-mirror-viewer.tsx, typescript2/app-website/lib/mdx/baml-block/baml-project-panel/codemirror-panel/code-mirror-viewer.tsx. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate typescript/packages/playground-common/src/features/graph/layout/edge/edge.ts:201— `(p1.x === p2.x && p3.y === p4.y) || (p1.y === p2.y && p3.x === p4.x)` appears character-identically in 2 files — typescript/packages/playground-common/src/features/graph/layout/edge/edge.ts, typescript2/pkg-playground/src/graph/edges/BaseEdge.tsx. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate typescript2/app-website/components/HistoryOfLanguages/CodeMorph.tsx:27— `/^".*"$/.test(token) || /^#"$/.test(token) || /^"#$/.test(token)` appears character-identically in 2 files — typescript2/app-website/components/HistoryOfLanguages/CodeMorph.tsx, typescript2/app-website/components/HistoryOfLanguages/ParticleCanvas.tsx. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate typescript2/app-developer-docs/components/book-chapter.tsx:41— `Number.parseFloat( getComputedStyle(document.documentElement).scrollPaddingTop, ) || 0` appears character-identically in 2 files — typescript2/app-developer-docs/components/book-chapter.tsx, typescript2/app-developer-docs/components/docs-toc.tsx. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate typescript2/app-developer-docs/tools/oxlint/anti-slop/rules/no-known-value-widening.ts:224— `annotation === null || annotation === undefined` appears character-identically in 4 files — typescript2/app-developer-docs/tools/oxlint/anti-slop/rules/no-known-value-widening.ts, typescript2/app-developer-docs/tools/oxlint/anti-slop/rules/no-object-parameters.ts, typescript2/app-developer-docs/tools/oxlint/anti-slop/rules/no-unknown-parameters.ts, typescript2/app-developer-docs/tools/oxlint/anti-slop/rules/no-unknown-returns.ts. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate typescript2/app-developer-docs/tools/oxlint/anti-slop/shared/dictionary-types.ts:170— `argument === null || argument === undefined` appears character-identically in 2 files — typescript2/app-developer-docs/tools/oxlint/anti-slop/shared/dictionary-types.ts, typescript2/app-developer-docs/tools/oxlint/anti-slop/shared/type-alias-resolution.ts. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate typescript2/pkg-playground/src/renderers/PromptAst.tsx:18— `baml == null || typeof baml !== 'object'` appears character-identically in 2 files — typescript2/pkg-playground/src/renderers/PromptAst.tsx, typescript2/pkg-playground/src/result-renderers.ts. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate typescript2/app-developer-docs/lib/generated-content/document-projector.ts:372— `block.page.page_kind === 'package' || block.page.page_kind === 'namespace'` appears character-identically in 2 files — typescript2/app-developer-docs/lib/generated-content/document-projector.ts, typescript2/app-developer-docs/lib/generated-content/verify.ts. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate typescript2/app-beps/src/components/decisions/decision-form.tsx:58— `c._id !== sourceCommentId && !c.parentId && !c.resolved` appears character-identically in 2 files — typescript2/app-beps/src/components/decisions/decision-form.tsx, typescript2/app-beps/src/components/issues/issue-form.tsx. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate typescript2/app-website/app/blog/[slug]/page.tsx:121— `category.toLowerCase() === 'launch week' || category === 'LaunchWeek'` appears character-identically in 2 files — typescript2/app-website/app/blog/[slug]/page.tsx, typescript2/app-website/app/blog/_components/category-filter.tsx. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate typescript2/app-developer-docs/tools/oxlint/anti-slop/rules/no-known-value-widening.ts:231— `current !== null && current.type !== "Program"` appears character-identically in 5 files — typescript2/app-developer-docs/tools/oxlint/anti-slop/rules/no-known-value-widening.ts, typescript2/app-developer-docs/tools/oxlint/anti-slop/rules/no-runtime-typeof.ts, typescript2/app-developer-docs/tools/oxlint/anti-slop/rules/no-unsafe-dictionary-type.ts, typescript2/app-developer-docs/tools/oxlint/anti-slop/rules/no-widen-then-assert.ts. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Silent fallback default on Err languages/rust/baml/src/lib.rs:201— `version` turns every `Err` into `"unknown".to_string()` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or propagate it with `?`. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the arm or in the doc comment, and the row stops firing.
Silent fallback default on Err baml_language/crates/baml_cli/src/run_command.rs:1224— `parse_scripts` turns every `Err` into `HashMap::new()` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or propagate it with `?`. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the arm or in the doc comment, and the row stops firing.
Silent fallback default on Err baml_language/crates/baml_compiler2_hir_ty/src/llm_output.rs:52— `llm_output_findings` turns every `Err` into `LlmOutputFindings::default()` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or propagate it with `?`. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the arm or in the doc comment, and the row stops firing.
Silent fallback default on Err baml_language/crates/baml_compiler2_hir_ty/src/method_resolution.rs:914— `impls_for_receiver` turns every `Err` into `Vec::new()` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or propagate it with `?`. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the arm or in the doc comment, and the row stops firing.
Silent fallback default on Err baml_language/crates/bex_vm/src/package_baml/csv.rs:2154— `skipped` turns every `Err` into `Vec::new()` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or propagate it with `?`. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the arm or in the doc comment, and the row stops firing.
Silent fallback default on Err baml_language/crates/bex_vm/src/package_baml/csv.rs:2259— `fields` turns every `Err` into `Vec::new()` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or propagate it with `?`. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the arm or in the doc comment, and the row stops firing.
Silent fallback default on Err baml_language/crates/bex_vm/src/package_baml/csv.rs:2742— `_to_markdown_records` turns every `Err` into `Vec::new()` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or propagate it with `?`. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the arm or in the doc comment, and the row stops firing.
Silent fallback default on Err baml_language/crates/bex_vm/src/package_reflect/reflect.rs:1413— `classes` turns every `Err` into `IndexMap::new()` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or propagate it with `?`. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the arm or in the doc comment, and the row stops firing.
Silent fallback default on Err baml_language/crates/bex_vm/src/package_reflect/reflect.rs:1428— `enums` turns every `Err` into `IndexMap::new()` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or propagate it with `?`. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the arm or in the doc comment, and the row stops firing.
Silent fallback default on Err baml_language/crates/bex_vm/src/package_reflect/reflect.rs:1438— `interfaces` turns every `Err` into `IndexMap::new()` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or propagate it with `?`. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the arm or in the doc comment, and the row stops firing.
Silent fallback default on Err baml_language/crates/bex_vm/src/package_reflect/reflect.rs:1453— `functions` turns every `Err` into `IndexMap::new()` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or propagate it with `?`. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the arm or in the doc comment, and the row stops firing.
Silent fallback default on Err baml_language/crates/bex_vm/src/package_reflect/reflect.rs:1494— `globals` turns every `Err` into `IndexMap::new()` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or propagate it with `?`. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the arm or in the doc comment, and the row stops firing.
Silent fallback default on Err baml_language/crates/bex_vm/src/package_reflect/reflect.rs:1560— `diagnostics` turns every `Err` into `Vec::new()` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or propagate it with `?`. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the arm or in the doc comment, and the row stops firing.
Silent fallback default on Err baml_language/crates/bex_vm/src/package_reflect/reflect.rs:1899— `diagnostics` turns every `Err` into `Vec::new()` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or propagate it with `?`. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the arm or in the doc comment, and the row stops firing.
Silent fallback default on Err baml_language/crates/bex_vm/src/model_usage.rs:33— `turn_usage` turns every `Err` into `Vec::new()` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or propagate it with `?`. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the arm or in the doc comment, and the row stops firing.
Silent fallback default on Err baml_language/crates/bex_vm/src/package_baml/json/decode.rs:1958— `impossible_members` turns every `Err` into `Vec::new()` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or propagate it with `?`. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the arm or in the doc comment, and the row stops firing.
Silent fallback default on Err baml_language/crates/bex_vm/src/package_baml/json/union.rs:249— `used_keys` turns every `Err` into `0` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or propagate it with `?`. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the arm or in the doc comment, and the row stops firing.
Silent fallback default on Err baml_language/crates/bridge_wasm/src/wasm_vfs.rs:198— `entries` turns every `Err` into `Vec::new()` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or propagate it with `?`. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the arm or in the doc comment, and the row stops firing.
Silent fallback default on Err baml_language/forks/aws-sigv4/src/lib.rs:460— `unix_secs` turns every `Err` into `0` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or propagate it with `?`. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the arm or in the doc comment, and the row stops firing.
Silent fallback default on Err engine/baml-lib/baml-core/src/ir/ir_helpers/mod.rs:1045— `find_class_fields_needing_null_filler` turns every `Err` into `Ok(HashSet::new())` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or propagate it with `?`. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the arm or in the doc comment, and the row stops firing.
Silent fallback default on Err engine/language_server/src/baml_project/mod.rs:103— `list_functions` turns every `Err` into `vec![]` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or propagate it with `?`. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the arm or in the doc comment, and the row stops firing.
Silent fallback default on Err engine/language_server/src/baml_project/mod.rs:308— `list_generators` turns every `Err` into `Ok(vec![])` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or propagate it with `?`. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the arm or in the doc comment, and the row stops firing.
Silent fallback default on Err engine/vendored/minijinja/src/expression.rs:107— `undeclared_variables` turns every `Err` into `HashSet::new()` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or propagate it with `?`. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the arm or in the doc comment, and the row stops firing.
Silent fallback default on Err engine/vendored/minijinja/src/template.rs:264— `undeclared_variables` turns every `Err` into `HashSet::new()` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or propagate it with `?`. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the arm or in the doc comment, and the row stops firing.
Silent fallback default in catch baml_language/sdks/java/gradle-plugin/src/main/java/com/boundaryml/baml/gradle/BamlPlugin.java:388— `resolveVersion` swallows every exception into `return ""` — a data error becomes a silent behavior change with no trail. Log the failure or let it propagate. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment in the catch or in the Javadoc, and the row stops firing.
Silent fallback default in catch baml_language/sdks/python/src/baml_bridge/proto.py:268— `_safe_sdk_root` swallows every exception into `return ''` — a data error becomes a silent behavior change with no trail. Log the failure or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
Silent fallback default in catch typescript2/app-beps/src/components/ui/theme-toggle.tsx:43— `getStoredTheme` swallows every exception into `return "system"` — a data error becomes a silent behavior change with no trail. Log the failure or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
Silent fallback default in catch typescript2/app-developer-docs/components/docs-sidebar.tsx:54— `readOpenState` swallows every exception into `return {}` — a data error becomes a silent behavior change with no trail. Log the failure or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
Silent fallback default in catch typescript2/app-feedback/src/components/ui/theme-toggle.tsx:43— `getStoredTheme` swallows every exception into `return "system"` — a data error becomes a silent behavior change with no trail. Log the failure or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
Silent fallback default in catch typescript2/app-website/lib/mdx/baml-block/baml-project-panel/playground-panel/prompt-preview/render-part.tsx:54— `RenderPart` swallows every exception into `return false` — a data error becomes a silent behavior change with no trail. Log the failure or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
Silent fallback default in catch REDACTED:98— `readState` swallows every exception into `return {}` — a data error becomes a silent behavior change with no trail. Log the failure or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
Silent fallback default in catch typescript2/pkg-playground/src/session-store.ts:280— `readStoredEnvVars` swallows every exception into `return {}` — a data error becomes a silent behavior change with no trail. Log the failure or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
Silent fallback default in catch typescript2/pkg-playground/src/graph/GraphView.tsx:94— `storedDirection` swallows every exception into `return 'vertical'` — a data error becomes a silent behavior change with no trail. Log the failure or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
Off-boarding risk: anonymized user #1 — If anonymized user #1 becomes unavailable, 48 significant file(s) lose their only recent owner: baml_language/crates/tools_size_gate/src/output.rs, languages/rust/baml/src/raw_objects/mod.rs, languages/rust/baml/src/runtime.rs, typescript2/app-developer-docs/components/generated-reference.tsx, REDACTED, baml_language/crates/btel_bcs/src/liveness.rs, typescript2/app-beps/convex/comments.ts, typescript2/app-beps/src/app/profile/page.tsx (+40 more). Pair on, review, or document these before any departure.
Off-boarding risk: anonymized user #2 — If anonymized user #2 becomes unavailable, 22 significant file(s) lose their only recent owner: typescript2/app-product-metrics/src/jobs/send-slack-report.ts, baml_language/sdks/python/rust/sdkgen_python_pydantic2/src/utils.rs, typescript2/app-product-metrics/src/server.ts, baml_language/tools/speedtest/src/speedtest/compare.py, tools/baml_nightly_select.py, baml_language/sdks/typescript/sdkgen_typescript_shared/src/emit/typemap_file.rs, tools/notify-release-failure.py, tools/sheep-council/prepare-sheep-council-email.py (+14 more). Pair on, review, or document these before any departure.
Off-boarding risk: anonymized user #3 — If anonymized user #3 becomes unavailable, 20 significant file(s) lose their only recent owner: baml_language/crates/baml_ide/src/cfg.rs, baml_language/crates/baml_type/src/normalize/mu.rs, baml_language/crates/baml_type_macros/src/convert.rs, baml_language/crates/baml_ide/src/rename.rs, baml_language/crates/baml_type_macros/src/emit.rs, typescript2/app-stdlib-matrix/src/components/matrix-symbol.ts, typescript2/app-stdlib-matrix/src/signature.ts, typescript2/app-stdlib-matrix/src/components/matrix-app.ts (+12 more). Pair on, review, or document these before any departure.
Off-boarding risk: anonymized user #4 — If anonymized user #4 becomes unavailable, 7 significant file(s) lose their only recent owner: baml_language/crates/baml_lsp_server/src/lsp_runtime.rs, typescript2/pkg-playground/src/args-form-model.ts, typescript2/pkg-playground/src/run-store-client.ts, baml_language/crates/baml_lsp/src/position_codec.rs, typescript2/app-beps/src/components/bep/bep-submit-modal.tsx, typescript2/app-vscode-webview/src/RemoteEditorView.tsx, typescript2/pkg-editor/src/remote-backend.ts. Pair on, review, or document these before any departure.
Off-boarding risk: anonymized user #5 — If anonymized user #5 becomes unavailable, 5 significant file(s) lose their only recent owner: typescript2/app-beps/src/lib/export-utils.ts, engine/baml-rpc/src/ui/ui_function_calls.rs, engine/baml-rpc/src/ui/ui_traces.rs, engine/baml-rpc/src/ui/ui_types.rs, engine/baml-runtime/src/tracingv2/publisher/rpc_converters/errors.rs. Pair on, review, or document these before any departure.
Fat interface: SDKStorage (78 required operations) typescript/packages/playground-common/src/sdk/storage/SDKStorage.ts:44— `SDKStorage` declares 78 required operations: `setWasm`, `getWasm`, `setRuntime`, `getRuntime`, `setWorkflows`, `getWorkflows`, `setActiveWorkflowId`, `getActiveWorkflowId`, `addExecution`, `getExecutions`, `updateExecution`, `setNodeState`, `getNodeState`, `clearAllNodeStates`, `setNodeIteration`, `getNodeIteration`, `incrementNodeIteration`, `getLoopOrdinals`, `setLoopOrdinal`, `clearAllNodeIterations`, `addNodeExecution`, `getNodeExecution`, `setCacheEntry`, `getCacheEntry`, `clearCache`, `getVersion`, `setWasmRuntime`, `getWasmRuntime`, `getDiagnostics`, `getFunctions`, `getGeneratedFiles`, `setWasmPanic`, `getWasmPanic`, `setFeatureFlags`, `getFeatureFlags`, `setEnvVars`, `getEnvVars`, `setBAMLFiles`, `getBAMLFiles`, `setParsedBAMLFiles`, and 38 more. Counted over its REQUIRED operations — a method signature or a function-typed property with no `?`, once per signature; optional members and data properties are not counted, because no implementer is forced to write them. A wide interface forces every implementer and caller to depend on methods they don't use (the Interface-Segregation 'I' in SOLID). Split it into focused role-interfaces.
Fat interface: RunStoreClient (17 required operations) typescript2/pkg-playground/src/run-store-client.ts:56— `RunStoreClient` declares 17 required operations: `startRun`, `startPreviewRun`, `startTestRun`, `cancelRun`, `respondToInput`, `respondToEnv`, `listRuns`, `listHistory`, `listExecutions`, `openExecution`, `readTelemetryMedia`, `openHistory`, `snapshot`, `readValue`, `subscribe`, `unsubscribe`, `dispose`. Counted over its REQUIRED operations — a method signature or a function-typed property with no `?`, once per signature; optional members and data properties are not counted, because no implementer is forced to write them. A wide interface forces every implementer and caller to depend on methods they don't use (the Interface-Segregation 'I' in SOLID). Split it into focused role-interfaces.
Fat interface: ExecutionStore (17 required operations) typescript2/pkg-playground/src/execution-store.ts:27— `ExecutionStore` declares 17 required operations: `getSnapshot`, `subscribe`, `startRun`, `startPreviewRun`, `startTestRun`, `cancelRun`, `respondToInput`, `respondToEnv`, `listRuns`, `listHistory`, `openHistory`, `snapshotRun`, `followRun`, `applySnapshot`, `applyPatch`, `selectRun`, `dispose`. Counted over its REQUIRED operations — a method signature or a function-typed property with no `?`, once per signature; optional members and data properties are not counted, because no implementer is forced to write them. A wide interface forces every implementer and caller to depend on methods they don't use (the Interface-Segregation 'I' in SOLID). Split it into focused role-interfaces.
Documentation: no build, run or usage example baml_language/sdks/csharp/bridge_csharp/tools/Baml.BytecodeCarrierEmitter/README.md:1— `Baml.BytecodeCarrierEmitter` is an executable (`OutputType Exe`) and neither `baml_language/sdks/csharp/bridge_csharp/tools/Baml.BytecodeCarrierEmitter/README.md` nor the documents it links hold a code block or a command. Show the command that builds or runs it, or a usage snippet.
Documentation: no build, run or usage example baml_language/sdks/csharp/bridge_csharp/tools/Baml.NuGetNormalizer/README.md:1— `Baml.NuGetNormalizer` is an executable (`OutputType Exe`) and neither `baml_language/sdks/csharp/bridge_csharp/tools/Baml.NuGetNormalizer/README.md` nor the documents it links hold a code block or a command. Show the command that builds or runs it, or a usage snippet.
Documentation: no build, run or usage example languages/csharp/baml/README.md:1— `baml` is a package (`PackageId`) and neither `languages/csharp/baml/README.md` nor the documents it links hold a code block or a command. Show the command that builds or runs it, or a usage snippet.
Subsumed condition operand languages/rust/baml/tests/type_builder.rs:1858— `email.contains("john@example.com")` can never decide this `||` — every value satisfying `email.contains("john@example.com")` also satisfies `email.contains("example")`, so the `||` chain is already decided by the latter. The expression is equivalent to the chain without it, which means it is wider than it reads. Delete the dead operand, or narrow the surviving one if IT is the accident.
Subsumed condition operand integ-tests/go/test_error_handling_test.go:86— `strings.Contains(errorMsg, "connection")` can never decide this `||` — every value satisfying `strings.Contains(errorMsg, "connection")` also satisfies `strings.Contains(errorMsg, "connect")`, so the `||` chain is already decided by the latter. The expression is equivalent to the chain without it, which means it is wider than it reads. Delete the dead operand, or narrow the surviving one if IT is the accident.
Subsumed condition operand baml_language/crates/baml_compiler2_hir_ty/src/exhaustiveness.rs:2956— `s.contains("user.Pair")` can never decide this `||` — every value satisfying `s.contains("user.Pair")` also satisfies `s.contains("Pair")`, so the `||` chain is already decided by the latter. The expression is equivalent to the chain without it, which means it is wider than it reads. Delete the dead operand, or narrow the surviving one if IT is the accident.
README/code drift engine/vendored/minijinja/README.md:157— engine/vendored/minijinja/README.md links to `CONTRIBUTING.md#ai-disclosure`, but `engine/vendored/minijinja/CONTRIBUTING.md` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every REDACTED, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong.
README/code drift engine/vendored/minijinja/README.md:166— engine/vendored/minijinja/README.md links to `UPDATING.md`, but `engine/vendored/minijinja/UPDATING.md` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every REDACTED, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong.
D16 · Bus Factor· Further sole-owners (lower concentration) · ×1
Further sole-owners (lower concentration) — 4 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 (107 single-owned of 2223 analysed files in total, counted over production source files of roughly 2,400 bytes or more, excluding vendored, generated, example/demo and scaffolding-template trees and test files identified by path convention, largest first; 2223 of the 3400 production source files in this repository met that bar). They are anonymized user #6 (2 file(s)), anonymized user #7 (1 file(s)), anonymized user #8 (1 file(s)), anonymized user #9 (1 file(s)) — spread or document their files in the same way, at lower priority than the named off-boarding risks above. The files folded here: engine/baml-runtime/src/optimize/tui.rs, engine/baml-runtime/src/optimize/storage.rs, baml_language/crates/baml_compiler_diagnostics/src/runtime_type.rs, typescript2/app-website/components/site-banner.tsx, typescript/apps/fiddle-web-app/app/embed/page.tsx.
No ADRs found — No ADRs found. The recognised ADR directories in this tree were read — `typescript2/app-beps/src/app/beps/[number]/decisions`, `typescript2/app-beps/src/components/decisions` — and none of their files is a decision record (a README, index or template page does not count). 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/`.
D28 · Secrets (history)· Rotate the exposed credentials · ×1
D34 · Knowledge Freshness· Further orphaned files (smaller) · ×1
Further orphaned files (smaller) — 68 smaller file(s) also have no living knowledge — folded into the freshness score and metrics rather than raised one row each — most significant first: engine/baml-runtime/src/optimize/schema_extractor.rs, engine/baml-runtime/src/internal/llm_client/primitive/vertex/types.rs, typescript/packages/playground-common/src/shared/baml-project-panel/playground-panel/prompt-preview/test-panel/components/EnhancedErrorRenderer.tsx, engine/baml-runtime/src/test_constraints.rs, engine/baml-runtime/src/optimize/storage.rs, engine/baml-runtime/src/optimize/gepa_runtime.rs, integ-tests/react/src/components/network-timeline/index.tsx, integ-tests/react/src/lib/store.ts (and 60 more) (81 orphaned of 2223 analysed files in total, counted over production source files of roughly 2,400 bytes or more, excluding vendored, generated, example/demo and scaffolding-template trees and test files identified by path convention, largest first; 2223 of the 3400 production source files in this repository met that bar). Attach the read to the next change that touches one of them: have a second person review that change, and leave behind a short comment or test recording what the file is for, so the knowledge comes back at the cost of a change you were making anyway.
No ADRs — No Architecture Decision Records found — no conventional ADR directory, no numbered `NNNN-title` documents in any markup this check reads, and nothing ADR-shaped by content. Design rationale recorded elsewhere (a design-notes tree, a mailing list, pull-request discussion) is not visible to this check and is not re-findable per decision, so a future maintainer cannot ask why one choice was made and get an answer.
Inconsistent root namespaces — Only 6/18 projects share a common root namespace — the code's module identity is inconsistent.
PF1 · Benchmark discipline· No performance benchmarks · ×1
No performance benchmarks — No benchmark suite was found by the two searches this check runs. FIRST, a BenchmarkDotNet package reference in any project file — every project the workspace loaded, plus a walk of project files on disk that never loaded, because a benchmark suite is exactly the project a partial load drops. SECOND, a script harness: a file whose name contains `benchmark` and ends `.py`, `.sh`, `.ps1`, `.bash`, `.rb`, `.js` or `.mjs`, credited ONLY when this repository's CI text also mentions benchmarks — a harness no pipeline runs is read as a fixture, deliberately. Neither search can see a benchmark suite in another ecosystem's idiom (a Go `testing.B` file, a JMH or criterion project, a pytest-benchmark run), so this is 'no benchmark found by those two searches', not a verdict that the repository has none. Where code is performance-sensitive, a benchmark guards against silent regressions — but it's a bonus here, not a deduction.
R8 · Dependency Hygiene· Type-only dependency '@smithy/types' in production deps · ×1
Type-only dependency '@smithy/types' in production deps typescript/apps/vscode-ext/src/webview-to-vscode-rpc.ts:1— Every import is type-only — move it to devDependencies.
X2 · Cancellation propagation· Not all async methods take a CancellationToken · ×1
Not all async methods take a CancellationToken — Only 16/32 async methods accept a CancellationToken, so in-flight work can't be stopped early when the caller gives up — whatever ends it in your host (shutdown signal, timeout, abandoned request, user cancel). Thread a token through the call chain and honour it at each await and loop; where a method genuinely cannot be interrupted, omitting it is a deliberate choice — judge against your hosting model.
Nullable reference types not enabled everywhere — 17/18 NRT-eligible project(s) enable <Nullable>enable</Nullable> (projects targeting a pre-C#-8 framework are excluded — NRTs aren't available there). NRTs catch a whole class of null-deref bugs at compile time.
Null-forgiving operator (`!`) suppressions reduce the NRT score — ~49.6 `!` suppressions per 1k syntax nodes — 11527 suppression(s) across the 232167 syntax node(s) in code where nullable warnings are ENABLED, which is the only code a `!` can suppress anything in (a `!` under `#nullable disable` is inert and is not counted, and its file's nodes are not in the denominator). Each one tells the compiler to trust you about null, suppressing the very safety NRTs provide.
Silent fallback default on parse failure baml_language/sdks/java/baml_bridge/src/main/java/baml_bridge/internal/ProtoWriter.java:439— `genericUnionArmIndex` returns `-1` when `NumberFormatException` is thrown, with no log or throw — a malformed value silently becomes that default. Log the input or fail validation. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment in the catch or in the Javadoc, and the row stops firing.
Skipped (documented): todo_case tools/sdk-parity-lint/test-fixtures/typescript/fixture/customizable/sample.test.ts:7— Skipped with a documented reason — a deferral, not lazy debt: declared with it.todo — a placeholder that registers a name and runs nothing
Skipped (documented): (unnamed test) tools/sdk-parity-lint/test-fixtures/typescript/fixture/customizable/sample.test.ts:9— Skipped with a documented reason — a deferral, not lazy debt: declared with no body — a pending test the runner lists but never runs
Skipped (documented): (unnamed test) baml_language/sdk_tests/crates/typescript/function_calls/customizable/host_callables.test.ts:247— Skipped with a documented reason — a deferral, not lazy debt: declared with no body — a pending test the runner lists but never runs
Skipped (documented): (unnamed test) baml_language/sdk_tests/crates/typescript/function_calls/customizable/host_common_types.test.ts:13— Skipped with a documented reason — a deferral, not lazy debt: declared with no body — a pending test the runner lists but never runs
Skipped (documented): (unnamed test) baml_language/sdk_tests/crates/typescript/function_calls/customizable/host_common_types.test.ts:72— Skipped with a documented reason — a deferral, not lazy debt: declared with no body — a pending test the runner lists but never runs
Skipped (documented): (unnamed test) baml_language/sdk_tests/crates/typescript/function_calls/customizable/host_recording_audit.test.ts:12— Skipped with a documented reason — a deferral, not lazy debt: declared with no body — a pending test the runner lists but never runs
Skipped (documented): __FIXTURE__ baml_language/sdk_tests/codegen/src/templates/worker_startup.test.ts:24— Skipped with a documented reason — a deferral, not lazy debt: declared with no body — a pending test the runner lists but never runs
Off the main sequence: @baml/common — @baml/common: abstractness 0.00, instability 0.00, distance 1.00 — the shape a shared-kernel / building-block library has BY DESIGN — concrete and widely depended-on is what makes it useful, and this dimension does not penalise it (the distance is reported for completeness, not as a defect). Worth a look only if it has grown past one coherent kernel into an everything-bucket.
D8 · Code Coverage· Coverage read from a committed report · ×1
Coverage read from a committed report — Line coverage 19.2% — read from a committed lcov report (engine/baml-lib/baml-types/src/ir_type/lcov.info); the in-image collector couldn't run the suite (commonly external-service dependencies). A real measurement, but from a committed artifact rather than a fresh in-image run.
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.
disclosure: not applicable — No vulnerability-disclosure policy file found (SECURITY.md/.markdown/.rst/.txt at root or under .github/.forgejo/.gitea/docs, .well-known/security.txt). A coordinated-disclosure policy may live off-repo, so this is not evidenced rather than failed.
runtime-hardening: not applicable — No Kubernetes/orchestration workloads found in the repository manifests; network egress policy is a cluster-native control that may live at the platform/firewall layer, so there is nothing to assess here.
runtime-hardening: not applicable — No Kubernetes/orchestration workloads found in the repository manifests; seccomp/AppArmor/SELinux confinement is a workload-level control, so there is nothing to assess here.
runtime-hardening: not applicable — No Kubernetes/orchestration workloads found in the repository manifests; runtime threat-detection and admission-control policy are cluster-level controls, so there is nothing to assess here.
Run 01a17c5f-78b9-72b7-8a21-f7540e09f1dd · every finding is also locatable in findings.md, and the complete scoring record (with exit codes + durations) in sidecar.json.
Issues: 739 · Warnings: 5055 · Recommendations: 270 · Info: 9 — Appendix A · all findings · full markdown report.
Generated by Watchdog — deterministic code-health analysis. 27-10-2026 @ 07:59 UTC.
Downloadable artifacts
Machine-readable and reproducible from this commit + frozen rubric — drop them straight into a contract appendix, a CRA dossier, or a downstream SCA / VEX tool.