A flake8 extension that checks cyclomatic complexity and calculates max complexity limit in runtime
Project description
flake8-adjustable-complexity
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:
- 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:
- You can run all checks and tests with
make check
. Please do it before TravisCI does. - We use BestDoctor python styleguide.
- We respect Django CoC. Make soft, not bullshit.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for flake8_adjustable_complexity-0.0.4.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 569f0e9ada5a493018e103972c68c8c2ef4f60726ed21f0e35d6501a4bea466f |
|
MD5 | c7caaaf4e3ab93c54cdaf2d597ae4379 |
|
BLAKE2b-256 | f4dd32b9371fcd600e4d9e87c8c7046ecc1852ea3c49037ad01f1c71991daa85 |
Hashes for flake8_adjustable_complexity-0.0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f21072649429e54121ee790b333c84075e3be0e6b14da1708a27bec0912f9634 |
|
MD5 | fe10d7706d649c57517e524c56fdaf23 |
|
BLAKE2b-256 | 1d877cfc2e5e96ec7b5b185e01cff7d4d0cb7ac95e486db7d8c52a0ebb2afcf9 |