Skip to content

fix(stats): show max cyclomatic in the text complexity summary (#2384) - #2523

Merged
carlos-alm merged 1 commit into
mainfrom
fix/issue-2384
Aug 15, 2026
Merged

fix(stats): show max cyclomatic in the text complexity summary (#2384)#2523
carlos-alm merged 1 commit into
mainfrom
fix/issue-2384

Conversation

@carlos-alm

Copy link
Copy Markdown
Contributor

Summary

The human-readable codegraph stats complexity line omitted maxCyclomatic, even though it's computed and present in stats -j. The line was internally inconsistent about which extreme it reports per metric: cognitive gets its max, MI gets its min, but cyclomatic only got its average — so a function at cyclomatic 40 was invisible in the default view while an equivalent cognitive outlier was shown.

Changes

  • Added maxCyclomatic to the ComplexityInfo interface in src/presentation/queries-cli/overview.ts (the value was already computed by both the native and JS stats paths — this was purely a presentation-layer omission).
  • printComplexity now prints max cyclomatic: N right after max cognitive: N, matching the JSON shape.

Verification

  • lint: pass
  • npx vitest run tests/presentation/queries-cli.test.ts: 31/31 pass (added a new stats test asserting both max cognitive and max cyclomatic appear in the rendered line)
  • codegraph diff-impact --staged: 2 functions changed, 2 callers affected (stats() and its CLI execute wrapper — exactly the expected surface)
  • Manually verified against this repo's own graph: Complexity: ... | max cognitive: 102 | max cyclomatic: 51 | avg MI: ...

Closes #2384

The complexity line showed avg/max cognitive and avg/min MI but only
avg cyclomatic, hiding the worst-case cyclomatic outlier that stats -j
already exposed. Text and JSON now surface the same fields.

docs check acknowledged: internal stats text-output bugfix, no
README/CLAUDE.md/ROADMAP surface area changed.

Impact: 2 functions changed, 2 affected
@greptile-apps

greptile-apps Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR adds the already-computed maximum cyclomatic complexity metric to the human-readable codegraph stats summary.

  • Extends the presentation-layer complexity shape with maxCyclomatic.
  • Prints maximum cyclomatic complexity alongside maximum cognitive complexity.
  • Adds a focused CLI rendering test for both maximum metrics.

Confidence Score: 5/5

The PR appears safe to merge with no actionable correctness or security issues identified.

Both native and JavaScript stats paths always provide maximum cyclomatic complexity for nonempty complexity results, and the updated renderer is guarded against absent complexity data.

Important Files Changed

Filename Overview
src/presentation/queries-cli/overview.ts Adds the required metric field and renders it in the default complexity summary; all runtime producers supply the value.
tests/presentation/queries-cli.test.ts Adds focused coverage confirming that maximum cognitive and cyclomatic values appear in text output.

Reviews (1): Last reviewed commit: "fix(stats): show max cyclomatic in the t..." | Re-trigger Greptile

@github-actions

Copy link
Copy Markdown
Contributor

Codegraph Impact Analysis

1 functions changed2 callers affected across 2 files

  • printComplexity in src/presentation/queries-cli/overview.ts:253 (2 transitive callers)

@carlos-alm
carlos-alm merged commit f61fab3 into main Aug 15, 2026
27 checks passed
@carlos-alm
carlos-alm deleted the fix/issue-2384 branch August 15, 2026 20:18
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 15, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(stats): text output omits maxCyclomatic while showing maxCognitive and minMI

1 participant