An extension for flake8 that validates cognitive functions complexity
Project description
flake8-cognitive-complexity
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.
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file flake8_cognitive_complexity-0.1.0.tar.gz
.
File metadata
- Download URL: flake8_cognitive_complexity-0.1.0.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/46.3.1 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f202df054e4f6ff182b659c261922b9c684628a47beb19cb0973c50d6a7831c1 |
|
MD5 | 91508c65384ff2627a81fbacf1b9fe74 |
|
BLAKE2b-256 | e7d62bb09fab21521424d5afc836aa0057d15a92f5e738e506a3e3cb035be517 |