Skip to main content

flake8-adjustable-complexity

Build Status Maintainability Test Coverage

An extension for flake8 to report on too complex functions with bad variables names.

Sometimes you want to use too generic variable name inside some function. It this case you want to be sure that the function is more simple that others, so a reader doesn't have to remember meaning of a variable together with other logic for a long time.

This plugin calculates max allowed cyclomatic complexity for each function separately. Default is 7 and it is decreased by 2 for each variable from blacklist inside the function. If actual complexity overcomes max calculated complexity, the plugin reports an error.

Max allowed cyclomatic complexity can be configured via --max-mccabe-complexity (or --max-adjustable-complexity) option. The plugin also accepts --per-path-max-adjustable-complexity to define a simple per-path complexity settings. The value of the option must be a comma-delimited list of <path>:<complexity> pairs.

Both options also can be specified via [flake8] section of setup.cfg.

Installation

pip install flake8-adjustable-complexity

Example

Sample file:

# test.py

def foo():
    for vars in range(5):
        for info in range(5):
            for obj in range(5):
                pass

Usage:

$ flake8 test.py
test.py:1:1: CAC001 is too complex (4 > 1)

Contributing

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

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

Here are useful tips:

Metadata

Release files for flake8-adjustable-complexity 0.0.4

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-adjustable-complexity 0.0.4
File Size Uploaded
flake8_adjustable_complexity-0.0.4.tar.gz 5.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for flake8-adjustable-complexity 0.0.4
File Interpreter ABI Platform
flake8_adjustable_complexity-0.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 12.3 kB

Release files / flake8_adjustable_complexity-0.0.4.tar.gz

Download URL flake8_adjustable_complexity-0.0.4.tar.gz
Size 5.7 kB
Tags Source
SHA-256 checksum
How to use checksums
569f0e9ada5a493018e103972c68c8c2ef4f60726ed21f0e35d6501a4bea466f
BLAKE2b-256 checksum
How to use checksums
f4dd32b9371fcd600e4d9e87c8c7046ecc1852ea3c49037ad01f1c71991daa85
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.5

Release files / flake8_adjustable_complexity-0.0.4-py3-none-any.whl

Download URL flake8_adjustable_complexity-0.0.4-py3-none-any.whl
Size 6.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f21072649429e54121ee790b333c84075e3be0e6b14da1708a27bec0912f9634
BLAKE2b-256 checksum
How to use checksums
1d877cfc2e5e96ec7b5b185e01cff7d4d0cb7ac95e486db7d8c52a0ebb2afcf9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.5

Release history Release notifications | RSS feed

0.0.6

2 release files

0.0.5

2 release files

This release

0.0.4 This release

2 release files

0.0.3

2 release files

0.0.1

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