cccc for VS Code
Shows cognitive and cyclomatic complexity for each function, using the cccc CLI (must be on PATH, or set cccc.path).
- CodeLens above each function and method
- Warnings in the Problems panel when a function exceeds the limits
- Status bar with the file's max complexity
- Complexity sidebar listing the most complex functions (click to jump; toggle sort by cognitive or cyclomatic)
- Clicking a CodeLens reveals the function in the sidebar
- Optional quick fix that asks chat to reduce a function's complexity
- Optional project-wide analysis
Files are analyzed on open and save, and again when they change on disk (git pull, checkout). With cccc.analyzeOnType, unsaved edits are analyzed too.
Limits
Precedence: an explicit cccc.maxCognitive / cccc.maxCyclomatic setting, then max-cognitive / max-cyclomatic in the nearest cccc.toml (or .cccc.toml), then the defaults (15 / 10). Set cccc.limitsFromConfig to false to ignore the file. Settings are per folder in multi-root workspaces.
Settings
| Setting |
Purpose |
cccc.scope |
file (open files) or workspace (whole project, ignored paths excluded). |
cccc.maxCognitive, cccc.maxCyclomatic |
Limits for warnings and colors. 0 disables. |
cccc.format, cccc.minComplexity |
Label template and a minimum to show. |
cccc.codeLens, cccc.inline |
Where labels appear. Inline is off by default. |
cccc.diagnostics |
Problems severity, or off. |
cccc.ext, cccc.exclude, cccc.extraArgs |
Passed to cccc as --ext, --exclude and extra flags. |
cccc.suggestFixes, cccc.fixPrompt |
The chat quick fix and its prompt. |
cccc.rescanOnChange, cccc.rescanDelay |
Rescan after disk changes, with a debounce. |
cccc.timeout |
Kill a hung cccc run. |
cccc.limitsFromConfig |
Read limits from cccc.toml. |
cccc.hotspots.count, .sortBy, .onlyOverLimit |
Contents and order of the sidebar. |
cccc.analyzeOnType |
Analyze unsaved edits (ignores cccc.toml and cccc.exclude). |
cccc.path and cccc.extraArgs are ignored in untrusted workspaces. Command: cccc: Analyze Whole Project.
In remote, WSL and container windows the extension runs on the remote side, so cccc must be installed there.
Known limits: cccc doesn't attribute closure bodies to the enclosing function, and .gitignore is only honored inside git repositories.
Develop
bun install
bun run build # bundles to out/extension.js
bun run test:unit # bun tests
bun run build:test && bun run test:integration # launches VS Code
Press F5 in VS Code to launch an Extension Development Host. Samples for every supported language are in examples/. bun run package makes a .vsix (needs vsce).