Drop compiled-artifact functions from the functions metric - #30
Merged
NullVoxPopuli merged 1 commit intoAug 7, 2026
Conversation
The build output contains functions that do not exist in the original source: decorator static blocks, <instance_members_initializer>, implicit constructors, and template scope thunks. Their source-mapped positions land on class headers or field lines, so a fully-covered class reported e.g. "4/6 functions" with an uncovered range highlighted on `extends` (issue NullVoxPopuli#29), and a file whose only "function" was such an artifact reported 0% functions (router.js). The original-source pass introduced for tree-shake detection now also prunes the functions map: every function entry whose declaration is not inside a real function span of the original source — function / arrow / method / user-written static block / <template> tag — is removed, so the functions metric counts only functions the user actually wrote. Statement, branch, and line data are untouched. Adds app/utils/tracked-box.js to the vite-app-using-v2-addon-js scenario as the issue NullVoxPopuli#29 shape: a fully-exercised class with a decorated field and one getter, asserted to report exactly 1/1 functions and 100% everywhere. Fixes NullVoxPopuli#29 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
NullVoxPopuli
approved these changes
Aug 7, 2026
Merged
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.
Fixes #29
Root cause
Your source-mapping hunch was right. Reproduced in the scenario apps by dumping the istanbul
fnMap: the compiled class output contains functions that don't exist in the original source — decorator<static_initializer>blocks,<instance_members_initializer>, implicit constructors, and gjs templatescopethunks. Their source-mapped declaration positions land on class headers and field lines. That's why a fully-covered class reports 4/6 functions with the uncovered range painted onextends Component, and whyrouter.jsin the scenario apps reported 0% functions — its only "function" was an<instance_members_initializer>with count 0, when the source contains no functions at all.Fix
The original-source pass added for tree-shake detection (#27) now also prunes the functions map: a function entry whose declaration is not inside any real function span of the original source — function/arrow/method, a user-written
static {}block, or a<template>tag — is a compiled artifact and is removed. The functions metric then counts only functions the user wrote. Statement, branch, and line data are untouched, and real uncovered functions (never-called methods, tree-shaken functions) still report as uncovered.Results in the scenario:
router.jsandapp.jsgo from 0%/50% to 100% functions;tracked-box.js(new fixture, the issue #29 shape: fully-exercised class with a decorated field and one getter) reports exactly 1/1 functions and 100% everywhere — previously it reported 3 functions with phantom entries.All 24 tests across the three scenarios pass, lint clean. (One local run flaked with a 10s browser timeout in the v2-addon scenario under 3-parallel-Chrome load — unrelated to this change; the coverage pipeline succeeded even in that run.)
🤖 Generated with Claude Code