Blazingly fast cognitive complexity analysis for Python, written in Rust.
See the codeBlazingly fast cognitive complexity analysis for Python, written in Rust.
Installation • Quick Start • Integrations • Learn More • Documentation • Changelog • Complexipy Teams
Cognitive complexity measures how hard code is to understand by humans, not machines.
Unlike traditional metrics like cyclomatic complexity, cognitive complexity accounts for nesting depth and control flow patterns that affect human comprehension. Inspired by G. Ann Campbell's research at SonarSource, complexipy provides a fast, accurate implementation for Python.
Key benefits:
How is complexity calculated? Learn about the scoring algorithm, what each control structure contributes, and how nesting affects the final score.
How does this compare to Ruff's PLR0912? Understand the key differences between cyclomatic complexity (Ruff) and cognitive complexity (complexipy), and why you might want to use both.
Is this a SonarSource/Sonar product? No. complexipy is an independent project inspired by G. Ann Campbell's research, but it's not affiliated with or endorsed by SonarSource.
pip install complexipy
# or
uv add complexipy
# Analyze the current directory
complexipy .
# Set a custom threshold
complexipy . --max-complexity-allowed 10
# Show failing functions with refactor suggestions
complexipy . --failed --suggest-refactors
# Save results to JSON
complexipy . --output-format json
# Block regressions against a git reference
complexipy . --diff main
# Exclude paths with glob patterns
complexipy . --exclude "tests/**"
from complexipy import file_complexity
# Analyze a file
result = file_complexity("app.py", check_script=True)
print(f"File complexity: {result.complexity}")
for func in result.functions:
print(f"{func.name}: {func.complexity}")
- uses: rohaquinlop/complexipy-action@v2
with:
paths: .
max_complexity_allowed: 10
output_format: json
repos:
- repo: https://github.com/rohaquinlop/complexipy-pre-commit
rev: v5.1.0
hooks:
- id: complexipy
Install from the marketplace It runs the complexipy language server, so install complexipy too (uv tool install complexipy). Inlay hints, hover, and warnings update as you type.
Every editor uses complexipy lsp, a language server with inlay hints, hover, and warnings. See Editor Integration for the VS Code, Neovim, and Zed setup.
--suggest-refactorsInspired by the Cognitive Complexity research by G. Ann Campbell
complexipy is an independent project and is not affiliated with or endorsed by SonarSource
Documentation • PyPI • GitHub
Built with ❤️ by @rohaquinlop and contributors
1,566 followers · starred Apr 2026
625 followers · starred Oct 2024
114 followers · starred Nov 2025
289 followers · starred Oct 2024
Blazingly fast cognitive complexity analysis for Python, written in Rust.
See the codeBlazingly fast cognitive complexity analysis for Python, written in Rust.
Installation • Quick Start • Integrations • Learn More • Documentation • Changelog • Complexipy Teams
Cognitive complexity measures how hard code is to understand by humans, not machines.
Unlike traditional metrics like cyclomatic complexity, cognitive complexity accounts for nesting depth and control flow patterns that affect human comprehension. Inspired by G. Ann Campbell's research at SonarSource, complexipy provides a fast, accurate implementation for Python.
Key benefits:
How is complexity calculated? Learn about the scoring algorithm, what each control structure contributes, and how nesting affects the final score.
How does this compare to Ruff's PLR0912? Understand the key differences between cyclomatic complexity (Ruff) and cognitive complexity (complexipy), and why you might want to use both.
Is this a SonarSource/Sonar product? No. complexipy is an independent project inspired by G. Ann Campbell's research, but it's not affiliated with or endorsed by SonarSource.
pip install complexipy
# or
uv add complexipy
# Analyze the current directory
complexipy .
# Set a custom threshold
complexipy . --max-complexity-allowed 10
# Show failing functions with refactor suggestions
complexipy . --failed --suggest-refactors
# Save results to JSON
complexipy . --output-format json
# Block regressions against a git reference
complexipy . --diff main
# Exclude paths with glob patterns
complexipy . --exclude "tests/**"
from complexipy import file_complexity
# Analyze a file
result = file_complexity("app.py", check_script=True)
print(f"File complexity: {result.complexity}")
for func in result.functions:
print(f"{func.name}: {func.complexity}")
- uses: rohaquinlop/complexipy-action@v2
with:
paths: .
max_complexity_allowed: 10
output_format: json
repos:
- repo: https://github.com/rohaquinlop/complexipy-pre-commit
rev: v5.1.0
hooks:
- id: complexipy
Install from the marketplace It runs the complexipy language server, so install complexipy too (uv tool install complexipy). Inlay hints, hover, and warnings update as you type.
Every editor uses complexipy lsp, a language server with inlay hints, hover, and warnings. See Editor Integration for the VS Code, Neovim, and Zed setup.
--suggest-refactorsInspired by the Cognitive Complexity research by G. Ann Campbell
complexipy is an independent project and is not affiliated with or endorsed by SonarSource
Documentation • PyPI • GitHub
Built with ❤️ by @rohaquinlop and contributors
1,566 followers · starred Apr 2026
625 followers · starred Oct 2024
114 followers · starred Nov 2025
289 followers · starred Oct 2024