Skip to content
| Marketplace
Sign in
Visual Studio Code>Linters>Live Cognitive ComplexityNew to Visual Studio Code? Get it now.
Live Cognitive Complexity

Live Cognitive Complexity

yousuf360

|
17 installs
| (0) | Free
Real-time Sonar-style cognitive complexity CodeLens for methods and classes — color-coded low / medium / high with ratio and absolute scores. Java, Python, TypeScript, JavaScript, Node.js, NestJS.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Live Cognitive Complexity

Real-time Sonar-style cognitive complexity in VS Code and Cursor.

See complexity as you type, above every method and class — with color-coded low / medium / high bands, ratio %, and absolute scores.

Language support today: Java, Python, TypeScript, JavaScript (Node.js & NestJS)
Planned: Go, C#, C++, and more

Install from VS Code Marketplace · GitHub

Features

  • Method CodeLens — e.g. $(warning) medium complexity (93%) · CC: 14 $(chevron-right)
  • Class CodeLens — e.g. $(check) class complexity · sum 16 · max 14 · high 0
  • Click to expand — clicking a method CodeLens shows a lens above every contributing line, e.g. +2 for loop (nesting 2); click again to collapse
  • Status bar — complexity for the method under your cursor
  • Codicon markers on the CodeLens (absolute + ratio of Sonar threshold; worst wins)
    • $(check) — low
    • $(warning) — medium
    • $(error) — high
  • Tooltip breakdown — every increment with line, nesting, and reason
  • Works on large files (hundreds of KB)

CodeLens on sample Java methods

Status bar complexity

Install

VS Code / Cursor Marketplace

  1. Open Extensions (Cmd+Shift+X / Ctrl+Shift+X)
  2. Search Live Cognitive Complexity (or live-cognitive-complexity)
  3. Click Install

Or open: marketplace.visualstudio.com/items?itemName=yousuf360.live-cognitive-complexity

From a VSIX

git clone https://github.com/yousuf360/live-cognitive-complexity.git
cd live-cognitive-complexity
npm install
npm run compile
npx @vscode/vsce package

Then in VS Code / Cursor:

Cmd+Shift+P → Extensions: Install from VSIX... → pick live-cognitive-complexity-*.vsix

Cursor tip: Do not use the Agent CLI cursor --install-extension — that binary is not the IDE. Use Install from VSIX in the Command Palette.

Development host (F5)

  1. Open this folder in VS Code / Cursor
  2. Press F5 (Run Extension)
  3. Open samples/OrderService.java or samples/order_service.py

What it measures

Cognitive Complexity (Sonar) estimates how hard control flow is to understand:

  • if / else / elif / else if, loops, switch / match, catch / except, ternary
  • Nesting penalties
  • && / || / and / or operator sequences
  • Lambdas / nested functions increase nesting for nested code
  • List/dict/set comprehensions and generator expressions are ignored (readable shorthand)

Unlike cyclomatic complexity, it ignores “readable shorthand” and focuses on mental load.

Defaults match Sonar rule S3776 (errorThreshold = 15).

Sample results (samples/OrderService.java)

Symbol Metric
OrderService (class) sum 16, max 14, high 0
add CC 0 (low)
validate CC 2 (low)
fulfill CC 14 (medium)

Sample results (samples/order_service.py)

Symbol Metric
OrderService (class) sum 16, max 14, high 0
add CC 0 (low)
validate CC 2 (low)
fulfill CC 14 (medium)

Configuration

Setting Default Description
liveCognitiveComplexity.enabled true Master switch
liveCognitiveComplexity.showCodeLens true Method CodeLens
liveCognitiveComplexity.showClassCodeLens true Class sum / max / high
liveCognitiveComplexity.showStatusBar true Cursor method in status bar
liveCognitiveComplexity.errorThreshold 15 High band + ratio denominator
liveCognitiveComplexity.warningThreshold 10 Medium absolute lower bound
liveCognitiveComplexity.mediumRatioPercent 67 Medium ratio lower bound
liveCognitiveComplexity.excludeAnonymousClassMethods true Skip anonymous class methods (Java)
liveCognitiveComplexity.excludeEqualsHashCode true Skip equals / hashCode (Java)
liveCognitiveComplexity.excludePatterns target, build, __pycache__, .venv, … Exclude globs

Also ensure editor CodeLens is on: "editor.codeLens": true.

Requirements

  • VS Code / Cursor ^1.85.0
  • Native tree-sitter bindings (bundled in the VSIX). If load fails after a platform change: npm rebuild tree-sitter tree-sitter-java tree-sitter-python

Privacy

Analysis runs entirely on your machine. Source is not uploaded. No telemetry.

Roadmap

  • [x] Python
  • [ ] TypeScript / JavaScript
  • [ ] Go
  • [ ] Optional Problems panel diagnostics for high methods

Develop

npm install
npm test
npm run compile

License

MIT

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft