All Projects → Melevir → flake8-cognitive-complexity

Melevir / flake8-cognitive-complexity

Licence: MIT License
An extension for flake8 that validates cognitive functions complexity

Programming Languages

python
139335 projects - #7 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to flake8-cognitive-complexity

flake8-functions
flake8 plugin for validation of function parameters (length, complexity, etc)
Stars: ✭ 32 (-27.27%)
Mutual labels:  styleguide, flake8, flake8-plugin
Elements Of Python Style
Goes beyond PEP8 to discuss what makes Python code feel great. A Strunk & White for Python.
Stars: ✭ 3,308 (+7418.18%)
Mutual labels:  styleguide, flake8, code-style
Wemake Python Styleguide
The strictest and most opinionated python linter ever!
Stars: ✭ 1,714 (+3795.45%)
Mutual labels:  styleguide, flake8, flake8-plugin
flake8-type-checking
Flake8 plugin for managing type-checking imports & forward references.
Stars: ✭ 38 (-13.64%)
Mutual labels:  flake8, flake8-plugin
flake8-broken-line
🚨 Flake8 plugin to forbid backslashes (\) for line breaks
Stars: ✭ 85 (+93.18%)
Mutual labels:  flake8, flake8-plugin
Pycodestyle
Simple Python style checker in one Python file
Stars: ✭ 4,465 (+10047.73%)
Mutual labels:  styleguide, flake8-plugin
Pep8speaks
A GitHub app to automatically review Python code style over Pull Requests
Stars: ✭ 546 (+1140.91%)
Mutual labels:  styleguide, code-style
Swift Style Guide
Swift language style guide & coding conventions followed by Xmartlabs.
Stars: ✭ 36 (-18.18%)
Mutual labels:  styleguide, code-style
flake8-docstrings
Integration of pydocstyle and flake8 for combined linting and reporting
Stars: ✭ 73 (+65.91%)
Mutual labels:  flake8, flake8-plugin
flake8-annotations
Flake8 Type Annotation Checking
Stars: ✭ 117 (+165.91%)
Mutual labels:  flake8, flake8-plugin
flake8-simplify
❄ A flake8 plugin that helps you to simplify code
Stars: ✭ 97 (+120.45%)
Mutual labels:  flake8, flake8-plugin
flake8-alfred
Alfred is a flake8 plugin to warn on unsafe/obsolete symbols.
Stars: ✭ 26 (-40.91%)
Mutual labels:  flake8, flake8-plugin
rubric
Linter Config Initializer for Python
Stars: ✭ 21 (-52.27%)
Mutual labels:  flake8
development-standard
Kata Platform Development Standard.
Stars: ✭ 29 (-34.09%)
Mutual labels:  styleguide
TheoLog
Vorlesungsunterlagen "Theoretische Informatik und Logik", Fakultät Informatik, TU Dresden
Stars: ✭ 20 (-54.55%)
Mutual labels:  complexity
birdseye
Next generation component catalog
Stars: ✭ 41 (-6.82%)
Mutual labels:  styleguide
programing-best-practices
A curated list of awesome Programming Best Practices For Good Developer 🥰
Stars: ✭ 67 (+52.27%)
Mutual labels:  code-style
decanter
A collection of front end web resources.
Stars: ✭ 31 (-29.55%)
Mutual labels:  styleguide
flake8-import-order-spoqa
Spoqa's import order style for flake8-import-order
Stars: ✭ 15 (-65.91%)
Mutual labels:  flake8
pydecker
Simple development tool that simplifies a pythonist's daily tasks.
Stars: ✭ 18 (-59.09%)
Mutual labels:  code-style

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.

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)

Contributing

We would love you to contribute to our project. It's simple:

  • Create an issue with bug you found or proposal you have. Wait for approve from maintainer.
  • Create a pull request. Make sure all checks are green.
  • Fix review comments if any.
  • Be awesome.

Here are useful tips:

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].