Skip to main content

An extension for flake8 that validates cognitive functions complexity

Project description


Build Status Maintainability Test Coverage PyPI version PyPI - Python Version

An extension for flake8 that validates cognitive functions complexity.

Cognitive complexity is analog of cyclomatic complexity, that measure how difficult to understand piece of code. Introduced by G. Ann Campbell and currently used by SonarSource, CodeClimate and others. You can find more readings about cognitive complexity in cognitive-complexity readme file.

Default complexity is 7, can be configured via --max-cognitive-complexity option.


pip install flake8-cognitive-complexity


def f(a, b):
    if a:
        for i in range(b):
            if b:
                return 1


$ flake8 --max-cognitive-complexity=3 CCR001 Cognitive complexity is too high (6 > 3)

Tested on Python 3.7.x and flake8 3.7.8.

Error codes

Error code Description
CCR001 Cognitive complexity is too high (X > Y)

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for flake8-cognitive-complexity, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size flake8_cognitive_complexity-0.1.0.tar.gz (3.1 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page