Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/presentation/queries-cli/overview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ interface ComplexityInfo {
avgCognitive: number;
avgCyclomatic: number;
maxCognitive: number;
maxCyclomatic: number;
avgMI?: number;
minMI?: number;
}
Expand Down Expand Up @@ -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}`,
);
}
}
Expand Down
29 changes: 28 additions & 1 deletion tests/presentation/queries-cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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');
});
});
Loading