Skip to main content

An extension for flake8 that validates cognitive functions complexity

Project description

flake8-cognitive-complexity

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.

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)

Project details


Download files

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

Source Distribution

flake8_cognitive_complexity-0.0.2.tar.gz (3.0 kB view details)

Uploaded Source

File details

Details for the file flake8_cognitive_complexity-0.0.2.tar.gz.

File metadata

  • Download URL: flake8_cognitive_complexity-0.0.2.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using 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.37.0 CPython/3.6.8

File hashes

Hashes for flake8_cognitive_complexity-0.0.2.tar.gz
Algorithm Hash digest
SHA256 7fbace212a216e09f0b2bb5aa68857e89c752e06465477b7126ae9fd54bf5fef
MD5 7e4984b758adc3c9c4c1e2d2299246e9
BLAKE2b-256 e4d00979bba275bb2332c247cee33f03e40c7f49d16b594cc7978891c62d3842

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page