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
--jobs Worker processes for per-file metric analysis (default: auto)
--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.5.0.tar.gz (6.2 MB view details)

Uploaded Source

Built Distribution

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

vibelexity-0.5.0-py3-none-any.whl (114.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for vibelexity-0.5.0.tar.gz
Algorithm Hash digest
SHA256 4b10949828df814a8b3529fb8d36fa6b9056b999d8bf897e3c53372345cef2c9
MD5 0038f71fc6951ed8d71a990f80b709c6
BLAKE2b-256 1136115262f00ce6ff2f2a311767b09f482bd784040e0d5f3c683b33ac74330a

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for vibelexity-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 eabc900bb61a756c89bf35dffe07cf71d79591210073fa34354eca4a8fc9ec82
MD5 214abf1e5e3c9c1b1c2fdad18ae12f4a
BLAKE2b-256 9e87765aa166e883f89a48abc9c9dea5d4e959584e011cc58b24126398cfee54

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