Skip to main content

Cognitive complexity analyzer for Python, TypeScript, and Go source files

Project description

Vibelexity

Cognitive complexity analyzer for Python, TypeScript, and Go source files.

Features

  • Cognitive Complexity: Measures how difficult code is to understand, accounting for nesting depth and control flow breaks
  • Halstead Metrics: Vocabulary volume, effort, time, and bug predictions
  • NPath Complexity: Number of acyclic execution paths through code
  • Cyclomatic Complexity: Linearly independent paths through decisions
  • Maintainability Index (MI): Composite measure of code maintainability (0-100)
  • Logic Density Index (LDI): Average nesting depth across code
  • Circular Dependencies: Detects import cycles between modules
  • Dead Code: Finds unused functions, variables, and imports
  • Code Duplication: Identifies exact and parametric clones
  • Call Graph: Generates DOT format call graphs

Installation

# Using uv (recommended)
uvx vibelexity <directory>

# Or for development
git clone https://github.com/ozozozd/vibelexity.git
cd vibelexity
uv sync
uv run vibelexity .

Usage

vibelexity <directory> [options]

Options

Option Description
--json Output results as JSON
--show-dupes Show detailed code duplication sites
--perf Show timing information for each metric
--show-dead Show all dead code violations
--show-bad-patterns Show detailed pattern violations list
--show-circulars Show circular import cycle details
--ts-module-resolution TypeScript module resolution mode (node, node16, nodenext, bundler)
--algorithm Cycle detection algorithm (dfs, tarjan)
--call-graph Generate call graph analysis (DOT format)
--show-fatties Show detailed fat files and functions list

Examples

# Analyze current directory
vibelexity .

# Analyze specific directory
vibelexity ./src

# JSON output for CI
vibelexity . --json

# Show circular import details
vibelexity . --show-circulars

# Generate call graph
vibelexity . --call-graph > graph.dot

Metrics Explained

Complexity Metrics

Metric Good Concern Critical
Cognitive Complexity ≤8 9-15 >15
Halstead Volume <500 500-1000 >1000
Cyclomatic Complexity ≤5 6-10 >10
NPath Complexity ≤50 51-200 >200
Maintainability Index (MI) ≥70 40-69 <40
Logic Density Index (LDI) ≤20 21-40 >40

Code Health Indicators

  • Circular Dependencies: Import cycles that create tight coupling
  • Dead Code: Unused functions, variables, and imports
  • Code Duplication: Exact and parameterized clones
  • Fat Functions: Functions with high complexity or many calls
  • Wide Functions: Functions with >5 parameters

Output Format

The default text output includes:

  1. Project Summary: total modules, functions, and lines of code
  2. Statistics: Average, median, P95, P99 for all metrics
  3. Circular Dependencies: Number and statistics of import cycles
  4. Pattern Violations: Code smell categories
  5. Code Duplication: Duplicate lines and functions
  6. Dead Code: Count of unused code
  7. Fatness Metrics: Fat files and functions
  8. Refactor Candidates: Top 10 functions needing refactoring

Claude Code Plugin

Use the /vibelexity slash command in Claude Code to analyze your codebase.

Installation

See vibelexity-claude-plugin for installation instructions.

Usage

In Claude Code, run:

/vibelexity

Or analyze a specific directory:

/vibelexity path/to/directory

The plugin automatically installs vibelexity if needed (prefers uvx with fallback to shell installer).

Development

# Install dependencies
uv sync

# Run tests
uv run pytest

# Run specific test
uv run pytest tests/test_cognitive/test_python.py::test_simple_function -v

# Check code style
uv run ruff check src/

# Format code
uv run ruff format src/

License

ISC

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vibelexity-0.2.0.tar.gz (433.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vibelexity-0.2.0-py3-none-any.whl (100.1 kB view details)

Uploaded Python 3

File details

Details for the file vibelexity-0.2.0.tar.gz.

File metadata

  • Download URL: vibelexity-0.2.0.tar.gz
  • Upload date:
  • Size: 433.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.7

File hashes

Hashes for vibelexity-0.2.0.tar.gz
Algorithm Hash digest
SHA256 6bc8912ce622c7a64aee16a61b22b50d30b8872e648d350ab327823789df66a2
MD5 8da90082af65ffdc9124671037a5e8d0
BLAKE2b-256 3b439742e49388206d39c98d92cc2ef5992d3d89cadba2b3b39d6a68e35a2cb6

See more details on using hashes here.

File details

Details for the file vibelexity-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: vibelexity-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 100.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.7

File hashes

Hashes for vibelexity-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0d7816c951695c636b95434bfd08fe9ffdb83ca24e84a6a5c961c1abbb67f020
MD5 74e89659f89636a2e3777a0e7d5b2c84
BLAKE2b-256 16a093f95cf2f4dbb300b07091eb45c718673537815008a698f226751cf0cb34

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page