
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
flake8-adjustable-complexity
Advanced tools
A flake8 extension that checks cyclomatic complexity and calculates max complexity limit in runtime
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 ) |
pip install flake8-adjustable-complexity
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
.
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)
We would love you to contribute to our project. It's simple:
Here are useful tips:
make check
. Please do it before TravisCI does.FAQs
A flake8 extension that checks cyclomatic complexity and calculates max complexity limit in runtime
We found that flake8-adjustable-complexity demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.