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) |
Metadata
Release files for flake8-cognitive-complexity 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| flake8_cognitive_complexity-0.1.0.tar.gz | 3.1 kB | Without provenance | Details |
Release files / flake8_cognitive_complexity-0.1.0.tar.gz
| Download URL | flake8_cognitive_complexity-0.1.0.tar.gz |
|---|---|
| Size | 3.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f202df054e4f6ff182b659c261922b9c684628a47beb19cb0973c50d6a7831c1
|
|
BLAKE2b-256 checksum How to use checksums |
e7d62bb09fab21521424d5afc836aa0057d15a92f5e738e506a3e3cb035be517
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Security for flake8-cognitive-complexity 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.