feat: add opt-in test coverage analysis tool#5383
Open
miteshashar wants to merge 1 commit intoSchemaStore:masterfrom
Open
feat: add opt-in test coverage analysis tool#5383miteshashar wants to merge 1 commit intoSchemaStore:masterfrom
miteshashar wants to merge 1 commit intoSchemaStore:masterfrom
Conversation
Add `node ./cli.js coverage` task that runs 8 coverage checks on schemas opted into the `coverage` array in schema-validation.jsonc. Supports `strict` mode for CI enforcement via object syntax. Checks: unused $defs, description coverage, test completeness, enum coverage, pattern coverage, required field coverage, default value coverage, negative test isolation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This was referenced Feb 20, 2026
Contributor
|
Super cool. @hyperupcall thoughts? |
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.
Summary
node ./cli.js coveragetask with 8 checks analyzing how thoroughly a schema's test files exercise its constraintscoveragearray inschema-validation.jsoncwith object syntax supportingstrictmode for CI enforcementvalidate.yml); onlystrict: trueschemas cause non-zero exitCoverage Checks
Checks that enforce in CI (when
strict: true)Unused
$defs— Flags$defs/definitionsentries not referenced by any$ref. Dead definitions bloat schema size and confuse contributors who assume they're in use.Description Coverage — Flags properties missing a
descriptionfield. Descriptions power language server tooltips and editor autocomplete — without them, users get no guidance when editing config files.Test Completeness — Checks that every top-level schema property appears in at least one positive test. Properties without test coverage can silently break across schema updates since no test validates them.
Enum Coverage — Checks that each enum value has positive test coverage and at least one invalid value in negative tests. Missing positive coverage means valid options are untested; missing negative coverage means the schema may silently accept typos.
Pattern Coverage — Checks that each
patternconstraint has a matching positive test and a violating negative test. Untested patterns can contain regex bugs that either reject valid input or accept invalid input without anyone noticing.Default Value Coverage — Checks that positive tests include non-default values for properties with
default. Tests using only the default don't prove the property works with other values — a broken type constraint on a defaulted field would go undetected.Heuristic checks (advisory only, never block CI)
Required Field Coverage — Checks that negative tests omit required fields, verifying the schema actually rejects incomplete input. Uses name-based matching (not path-aware), so returns
warnto avoid false positives from repeated property names at different depths.Negative Test Isolation — Flags negative test files that test multiple unrelated violation types simultaneously. Mixed-violation tests make it unclear which constraint the test is verifying, and a single fix can accidentally make the file pass for the wrong reason.
Demo Output
Running against
claude-code-settings.jsonon current master (before any test improvements):Test plan
node ./cli.js checkpasses (existing checks unaffected)node ./cli.js coverageruns with empty coverage array (no-op)node ./cli.js coverage --schema-name=<schema>.jsonworks for opted-in schemasstrict: truecauses exit(1) on failures;strict: false(default) exits 0🤖 Generated with Claude Code
Related
This tool's output was used to fix coverage for Claude Code Settings in #5385.