# complexipy > A Python library and CLI tool to calculate cognitive complexity of Python files and analyze code maintainability. complexipy is a Python library and command-line tool designed to calculate the cognitive complexity of Python source code. It helps developers identify complex code sections that may be difficult to understand and maintain, enabling better code quality and refactoring decisions. The tool analyzes Python files and provides detailed complexity metrics based on the cognitive complexity metric. **Key Features:** - **Cognitive Complexity Analysis** - Calculates cognitive complexity scores for Python functions and files, helping identify code that may be hard to understand or maintain - **CLI Interface** - Provides a straightforward command-line interface to analyze individual files, directories, or entire projects with customizable options - **Library Integration** - Can be imported as a Python library for programmatic access to complexity calculations within your own tools and workflows - **Detailed Reporting** - Generates comprehensive reports showing complexity scores per function, allowing targeted refactoring efforts - **Configurable Thresholds** - Set maximum complexity thresholds to enforce code quality standards and fail builds when complexity exceeds limits - **Fast Performance** - Built with Rust for high-performance analysis, capable of processing large codebases quickly - **JSON Output** - Supports JSON output format for easy integration with CI/CD pipelines and other automation tools - **Git Integration** - Can analyze only changed files in a git repository for efficient incremental analysis To get started, install complexipy using pip with `pip install complexipy`. Once installed, run `complexipy .` in your project directory to analyze all Python files. Use `complexipy --help` to see all available options including setting complexity thresholds, output formats, and filtering options. The tool can be integrated into pre-commit hooks or CI pipelines to maintain code quality standards across your team. ## Features - Cognitive complexity calculation - CLI interface - Python library integration - JSON output format - Configurable complexity thresholds - Directory and file analysis - Git integration for changed files - Fast Rust-based performance - Detailed function-level reporting ## Integrations Python, Git, CI/CD pipelines, Pre-commit hooks ## Platforms WINDOWS, MACOS, LINUX ## Pricing Open Source ## Links - Website: https://rohaquinlop.github.io/complexipy/ - Documentation: https://rohaquinlop.github.io/complexipy/ - Repository: https://github.com/rohaquinlop/complexipy - EveryDev.ai: https://www.everydev.ai/tools/complexipy