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
option.
pip install flake8-adjustable-complexity
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)
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.