fix(report): use the last CCN average in multi-file lizard XML reports - #45
Merged
Merged
Conversation
lizard --xml writes a running cumulative <average label="CCN"> after each source file's items (all as flat siblings under one <measure> element, since the format has no per-file nesting). parseLizard's .find() picked the first one, i.e. the first file's own average, silently under/over-reporting complexity for any real multi-file project. Found while scaffolding example-rust: a 4-function first file (all CCN 1) reported project complexity as 1 instead of the true 2.03 average across all 5 files / 34 functions. Confirms example-typescript's live badge is affected too. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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
parseLizardpicked the first<average label="CCN">tag in a lizard--xmlreport; for multi-file projects lizard writes a running cumulative average after each file's items (flat siblings under one<measure>element — the format has no per-file nesting), so only the last one reflects the whole project.example-rust: a 4-function first file (blocklist.rs, all CCN 1) reported project complexity as1instead of the true2.03average across all 5 files / 34 functions (verified against the<measure type="File">block'ssum(CCN)/sum(Functions)= 69/34 = 2.0294).example-typescript's live complexity badge almost certainly has the same bug — it's the only other repo currently reporting via lizard.Test plan
complexity.test.tsreproducing the real multi-file XML shape (single-function first file averaging 1.0, masking a true 5-function project average of 2.2) — fails against the old.find(), passes with.filter().at(-1).npx vitest run— 100/100 tests pass.npm run build— rebuiltdist/index.js.@v0.2.0until a new tag is cut (deliberately left for a separate decision).🤖 Generated with Claude Code