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.

Currently, the following errors are reported:

Code Description
CAC001 func is too complex (complexity > max allowed complexity)
CAC002 func is too complex (complexity). Bad variable names penalty is too high (penalty)

Installation

pip install flake8-adjustable-complexity

Configuration

The plugin has the following configuration options:

  • --max-mccabe-complexity (or --max-adjustable-complexity) - Max allowed cyclomatic complexity.
  • --per-path-max-adjustable-complexity - Per-path complexity settings. The value of the option must be a comma-separated list of <path>:<complexity> pairs.
  • --var-names-extra-blacklist - Comma-separated list of bad variable names to blacklist. Each variable will affect the max allowed complexity.
  • --var-names-whitelist - Comma-separated list of bad variable names to whitelist.

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

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 foo 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.5

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.5
File Size Uploaded Provenance Actions
flake8_adjustable_complexity-0.0.5.tar.gz 8.6 kB Without provenance Details for flake8_adjustable_complexity-0.0.5.tar.gz

Built distribution (wheel)

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

Total release size: 17.6 kB

Release files / flake8_adjustable_complexity-0.0.5.tar.gz

Download URL flake8_adjustable_complexity-0.0.5.tar.gz
Size 8.6 kB
Tags Source
SHA-256 checksum
How to use checksums
f6a38046a4b79499d5d8db4e4fb272674e92198356248495b6feea9a607b1746
BLAKE2b-256 checksum
How to use checksums
f08b59cfbfba485a10a031e261d237d84218e3e3b559e4dc889515ce18fbbb7b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

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

Download URL flake8_adjustable_complexity-0.0.5-py3-none-any.whl
Size 9.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
be4c981a192c565a77bd8dc1b796abccb1f64bb3b9beada08f32a922aa73e82f
BLAKE2b-256 checksum
How to use checksums
d076855b02026f8ddf75e7342be2a7a1c6964e333734e71652b3ddb8b14e9f39
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

Security for flake8-adjustable-complexity 0.0.5

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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