diff --git a/src/presentation/queries-cli/overview.ts b/src/presentation/queries-cli/overview.ts index 3d52675b2..62c2e1fde 100644 --- a/src/presentation/queries-cli/overview.ts +++ b/src/presentation/queries-cli/overview.ts @@ -77,6 +77,7 @@ interface ComplexityInfo { avgCognitive: number; avgCyclomatic: number; maxCognitive: number; + maxCyclomatic: number; avgMI?: number; minMI?: number; } @@ -254,7 +255,7 @@ function printComplexity(data: StatsData): void { const cx = data.complexity; const miPart = cx.avgMI != null ? ` | avg MI: ${cx.avgMI} | min MI: ${cx.minMI}` : ''; console.log( - `\nComplexity: ${cx.analyzed} functions | avg cognitive: ${cx.avgCognitive} | avg cyclomatic: ${cx.avgCyclomatic} | max cognitive: ${cx.maxCognitive}${miPart}`, + `\nComplexity: ${cx.analyzed} functions | avg cognitive: ${cx.avgCognitive} | avg cyclomatic: ${cx.avgCyclomatic} | max cognitive: ${cx.maxCognitive} | max cyclomatic: ${cx.maxCyclomatic}${miPart}`, ); } } diff --git a/tests/presentation/queries-cli.test.ts b/tests/presentation/queries-cli.test.ts index d28b555e7..6734aeac0 100644 --- a/tests/presentation/queries-cli.test.ts +++ b/tests/presentation/queries-cli.test.ts @@ -39,7 +39,7 @@ const { where, queryName, context, children, explain, implementations, interface ); const { symbolPath } = await import('../../src/presentation/queries-cli/path.js'); const { fileExports } = await import('../../src/presentation/queries-cli/exports.js'); -const { moduleMap, roles } = await import('../../src/presentation/queries-cli/overview.js'); +const { moduleMap, roles, stats } = await import('../../src/presentation/queries-cli/overview.js'); // ── Helpers ──────────────────────────────────────────────────────── let lines: any; @@ -680,3 +680,30 @@ describe('roles', () => { expect(output()).toContain('No classified symbols found'); }); }); + +// ── overview.js: stats ───────────────────────────────────────────── + +describe('stats', () => { + it('prints max cyclomatic alongside max cognitive', async () => { + mocks.statsData.mockReturnValue({ + nodes: { total: 1, byKind: { function: 1 } }, + edges: { total: 0, byKind: {} }, + files: { total: 1, languages: 1, byLanguage: { javascript: 1 } }, + cycles: { fileLevel: 0, functionLevel: 0 }, + hotspots: [], + complexity: { + analyzed: 4633, + avgCognitive: 4.1, + avgCyclomatic: 4, + maxCognitive: 74, + maxCyclomatic: 40, + avgMI: 65.1, + minMI: 24.7, + }, + }); + await stats('/db', {}); + const out = output(); + expect(out).toContain('max cognitive: 74'); + expect(out).toContain('max cyclomatic: 40'); + }); +});