Repository navigation
fix(svelte): score templates per top-level block and snippet - #25
Merged
Merged
Conversation
A Svelte template was one whole-file <template> pseudo-function, so a
large page failed at line 1 with a score that grew with file size.
Each top-level {#if}/{#each}/{#await} block and every {#snippet} is now
its own unit at its opening line; the root <template> keeps only
expressions outside any block.
Raises the coverage floor to 92 per the ratchet.
6 tasks done
This was referenced Sep 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #8
A Svelte template was scored as one whole-file
<template>pseudo-function, so a large page failed at line 1 with a number that grew with file size. This takes option 1 from the issue: each top-level{#if}/{#each}/{#await}block is its own unit at its opening line, with nested blocks counting toward it and adding depth. Every{#snippet}is its own unit wherever it appears and is excluded from the enclosing block, like a nested function. Elements and{#key}are transparent. The root<template>keeps only expressions outside any unit. The rule is indocs/spec.md§Svelte, and units are found by tree-sitter node kinds.The golden fixture adds a
{#key}-wrapped{#each}holding a snippet with its own{#if}. The negative case is that the snippet's decisions are not counted in the{#each}.Re-scan: across local Svelte repos, 11 former line-1
<template>violations drop to 4, each now pointing at a block (for examplepickscribe/src/lib/views/History.svelte:140 {#if}complexity 17, depth 5). The 2675-line page from #6 no longer exists in that form. prova-clara's remaining<template>28 passes because no single block reaches 15.Coverage is 92.42% of lines, so the CI floor goes from 89 to 92 per the ratchet.
Touches template traversal in
crates/core/src/language.rs, which #7 also changes, so merge the two one after the other.Validation:
cargo test --workspace --locked --all-targets,cargo clippy --workspace --all-targets -- -D warnings,cargo llvm-cov --workspace --locked --fail-under-lines 92, PickCheck over the changed files (only the intentional over-limit fixture functions fail).