Skip to content

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

Description

@carlos-alm

Summary

The human-readable codegraph stats complexity line omits maxCyclomatic, which is present in stats -j. The omission is inconsistent with how the same line treats the other two metrics.

Reproduction

On this repo (codegraph 3.16.0, full self-build):

$ codegraph stats | grep Complexity
Complexity: 4633 functions | avg cognitive: 4.1 | avg cyclomatic: 4 | max cognitive: 74 | avg MI: 65.1 | min MI: 24.7
$ codegraph stats -j | jq .complexity
{ "avgCognitive": 4.1, "avgCyclomatic": 4, "maxCognitive": 74, "maxCyclomatic": 40, ... }

maxCyclomatic: 40 is computed and exposed in JSON, but never printed.

Why it's worth fixing

The line is internally inconsistent about which extreme it reports per metric:

Metric avg max min
cognitive shown shown n/a
cyclomatic shown missing n/a
MI shown n/a shown

Cognitive gets its max, MI gets its min (the bad end for MI, since lower is worse), but cyclomatic gets only its average — so the one function at cyclomatic 40 is invisible in the default view, while the cognitive outlier at 74 is not. Average cyclomatic of 4 reads as healthy on its own.

Suggested fix

Add max cyclomatic to the text output next to max cognitive. Text and JSON should surface the same fields.

Found while writing .codegraph/basics.md health baselines during the org-wide rollout, where stats is the natural source for those numbers.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions