flake8-cognitive-complexity
An extension for flake8 that validates cognitive functions complexity
What it is and what it does
flake8-cognitive-complexity is a flake8 linter plugin that measures cognitive complexity—a metric for how difficult a piece of code is to understand—introduced by G. Ann Campbell and used by SonarSource and CodeClimate. It analyzes Python functions and reports violations when complexity exceeds a threshold you set, defaulting to 7. The plugin integrates directly into flake8's workflow and emits error code CCR001 when a function's cognitive complexity is too high.
The package has no runtime dependencies and works by analyzing control flow in your code. However, it is abandoned: the last release was 2020-08-01 and the last commit to the repository was 2021-02-24. This means it may not be compatible with recent versions of flake8 or Python versions beyond 3.8, and bugs or incompatibilities will not be fixed.
Use it for:
- Enforce a maximum cognitive complexity threshold in CI/CD pipelines to catch overly complex functions early.
- Identify functions that are hard to understand and maintain as part of code review workflows.
- Set project-wide complexity standards using the --max-cognitive-complexity option in flake8 configuration.
- Measure code quality improvements over time by tracking cognitive complexity violations in your codebase.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
A flake8 extension that checks Python code for cognitive complexity, flagging functions that exceed a configurable threshold (default 7) to help identify overly complex logic.
No. The package is abandoned (last update 2021-02-24) and untested with modern Python or flake8 versions. While the idea is sound and the MIT license is permissive, the lack of maintenance means you risk compatibility breakage and unpatched issues. Consider an actively maintained alternative or a more recent cognitive-complexity linter.
Install
flake8-cognitive-complexity on PyPI
pip
pip install flake8-cognitive-complexityuv
uv add flake8-cognitive-complexitypoetry
poetry add flake8-cognitive-complexityInstalling flake8-cognitive-complexity
Before you install
High install friction due to no runtime dependencies, but the package is abandoned—last release was 2020-08-01 and last commit 2021-02-24. It may not work with recent flake8 or Python versions without maintenance.
License in practice
MIT license is permissive and poses no restrictions on use, modification, or distribution.
Quickstart
pip install flake8-cognitive-complexity
flake8 --max-cognitive-complexity=7 your_file.py
Requires flake8 to be installed; tested on flake8 3.7.8 and Python 3.7.x, but package is unmaintained since 2021.
Verify before relying
- Compatibility with flake8 versions released after 2021 and modern Python versions (3.9+)
- Whether the package still functions as a working flake8 plugin in current environments
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.6) |
| Install friction | high — source build required |
| Runtime dependencies | none |
| Maintenance | abandoned — 2,204 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 298,539/month — #7,873 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: flake8_cognitive_complexity-0.1.0.tar.gz
Keywords: flake8
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
cognitive-complexityCalculates cognitive complexity scores for…
permissive · top 15,000 on PyPI
complexipyCalculates cognitive complexity scores for…
permissive · top 15,000 on PyPI
flake8-expression-complexityA flake8 extension that detects overly complex…
permissive · top 15,000 on PyPI
lizardLizard analyzes code complexity and detects…
permissive · top 5,000 on PyPI
mccabeMeasures cyclomatic complexity of Python…
permissive · top 1,000 on PyPI
flake8-functionsA flake8 extension that enforces function-level…
permissive · top 15,000 on PyPI
flake8-annotations-complexityA flake8 plugin that flags type annotations…
permissive · top 15,000 on PyPI
xenonXenon monitors Python code complexity by…
permissive · top 5,000 on PyPI
flake8Flake8 is a command-line tool that combines…
permissive · top 1,000 on PyPI
wemake-python-styleguideA flake8 plugin that enforces strict,…
permissive · top 15,000 on PyPI