Skip to main content

flake8-expression-complexity

Build Status Maintainability Test Coverage

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.

Installation

pip install flake8-cognitive-complexity

Example

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

Usage:

$ flake8 --max-cognitive-complexity=3 test.py
text.py:1:5: 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)

Metadata

Release files for flake8-cognitive-complexity 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for flake8-cognitive-complexity 0.0.1
File Size Uploaded
flake8_cognitive_complexity-0.0.1.tar.gz 2.8 kB Details

Release files / flake8_cognitive_complexity-0.0.1.tar.gz

Download URL flake8_cognitive_complexity-0.0.1.tar.gz
Size 2.8 kB
Tags Source
SHA-256 checksum
How to use checksums
565ffbe4d9329f877d14759e0ce859efeac56dc55ec35aacca4c61b207777fba
BLAKE2b-256 checksum
How to use checksums
f1568cd2f5e55ae6ca4accee9ae352f3ce6255420c1e3ba3aa16f61c3131e7af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.2

Release history Release notifications | RSS feed

0.1.0

1 release file

0.0.2

1 release file

This release

0.0.1 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page