Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>Cognitive LensNew to Visual Studio Code? Get it now.
Cognitive Lens

Cognitive Lens

Ahmed Samir

|
55 installs
| (1) | Free
Shows Cognitive Complexity for TypeScript, C#, and Dart methods
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

🧠 Cognitive Lens for VS Code

Transform your coding experience with intuitive complexity visualization.

Marketplace | GitHub | Changelog


🔥 Features at a Glance

1. The HUD for your Code

  • Live Score (CodeLens): A floating score above every method tells you exactly how "braindead" easy or "nightmare" hard your code is to read. CodeLens
  • Deep Dive (Inlay Hints): Toggleable, line-specific annotations show the exact cost of every branching statement. Inlay Hints
    • Green (0-14): Accessible logic.
    • Yellow (15-24): Consider refactoring.
    • Red (25+): High cognitive load.

2. Git-Integrated Complexity

Stop regressions before they are committed. Cognitive Lens monitors your changes and displays a Delta decoration: Complexity Deltas

  • 🟢 -5: Cleaned up a mess.
  • 🔴 +2: Complexity is creeping in.

3. Smart Advice

Hover over a complex method to see the Refactoring Advisory. It breaks down the biggest complexity contributors (Nesting, Logic, Control Flow) and suggests actionable refactorings.

4. Interactive Reports

Generate a full-screen workspace dashboard with Cognitive Lens: Generate Project Report. Project Report

  • Top 10 Most Complex Methods: Find your biggest technical debt instantly.
  • Fuzzy Search: Quickly jump to any method.
  • Visual Trends: See the health of your codebase.

⚙️ Configuration

Tailor the lens to your team's standards:

Setting Default Description
cognitiveComplexity.threshold.warning 15 The score where logic becomes "Yellow".
cognitiveComplexity.threshold.error 25 The score where logic becomes "Red".
cognitiveComplexity.showCodeLens true Show scores above methods.
cognitiveComplexity.showInlayHints.details true Show +1 (if) style details.
cognitiveComplexity.showInlayHints.methodScore false Show the total score as an inlay hint.
cognitiveComplexity.showInlayHints.complexityDelta false Show the score delta as an inlay hint.
cognitiveComplexity.showGutterIcon false Traffic lights in the gutter.
cognitiveComplexity.showDiagnostics true Show warnings/errors for high complexity.
cognitiveComplexity.showComplexityDeltaDecoration true Show colored delta decoration (VS Code).
cognitiveComplexity.totalScorePrefix "Cognitive Complexity" Prefix text for the total score.

📦 Supported Languages

Language Support Level Alignment
TypeScript / TSX Full SonarJS Compatible
JavaScript / JSX Full SonarJS Compatible
C# (.cs) Full SonarSource C# Compatible
Dart Full Community Standard

🚀 Installation

  1. Open Extensions in VS Code (Ctrl+Shift+X).
  2. Search for Cognitive Lens.
  3. Click Install.

🤝 Contributing & Support

  • Found a bug? Open an Issue.
  • Want to help? PRs are welcome! Check the root README for build instructions.

Writing clean code is hard. Reading it shouldn't be.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft