skillfed

flake8-cognitive-complexity

An extension for flake8 that validates cognitive functions complexity

flake8-cognitive-complexity v0.1.0 298.5K downloads/30d#7,873 on PyPI71
Permissive license MIT Abandoned released

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-complexity

uv

uv add flake8-cognitive-complexity

poetry

poetry add flake8-cognitive-complexity

Installing 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

Environment :: ConsoleFramework :: Flake8Operating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Topic :: Software Development :: DocumentationTopic :: Software Development :: Libraries :: Python ModulesTopic :: Software Development :: Quality Assurance

Tags

flake8 cognitive complexity checkercode complexity linter pluginfunction complexity validationflake8 extension quality assurancemeasure code understandabilitycyclomatic complexity alternativecode maintainability analysis
code-qualitylinter-pluginunmaintained

More Python Modules packages