Skip to content

fix(report): use the last CCN average in multi-file lizard XML reports - #45

Merged
tbjers merged 1 commit into
mainfrom
fix/lizard-multifile-complexity-average
Jul 5, 2026
Merged

fix(report): use the last CCN average in multi-file lizard XML reports#45
tbjers merged 1 commit into
mainfrom
fix/lizard-multifile-complexity-average

Conversation

@tbjers

@tbjers tbjers commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Summary

  • parseLizard picked the first <average label="CCN"> tag in a lizard --xml report; 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.
  • Found while scaffolding example-rust: a 4-function first file (blocklist.rs, all CCN 1) reported project complexity as 1 instead of the true 2.03 average across all 5 files / 34 functions (verified against the <measure type="File"> block's sum(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

  • Added a regression test in complexity.test.ts reproducing 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 — rebuilt dist/index.js.
  • Not yet released — Action stays pinned at @v0.2.0 until a new tag is cut (deliberately left for a separate decision).

🤖 Generated with Claude Code

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>
@tbjers
tbjers merged commit 8d7f9c6 into main Jul 5, 2026
2 checks passed
@tbjers
tbjers deleted the fix/lizard-multifile-complexity-average branch July 5, 2026 02:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant