Python 圈复杂度计算器
Cyclomatic complexity is a code quality metric
- multi charset support.(this may lead slow)
- pretty output
pip install pcc-calc==0.0.2
you need download or build library first.
pcc --help
Usage: pcc [OPTIONS] CODE_PATH
Cyclomatic Complexity Caculator
Options:
-j, --jobs INTEGER Parallel jobs count [default: 10]
-c, --count INTEGER Output item count [default: 10]
-s, --sort BOOLEAN sort by Complexity [default: True]
-e, --exclude_path DIRECTORY exclude path
--lib_path DIRECTORY tree-sitter library path [default: .pcc/]
--version
--help Show this message and exit.
pcc ./pcc/pcc.py
Code Cyclomatic Complexity Caculator
| Complexity | Function | File |
|------------|--------------------------------|--------------------------------|
| 2 | get_vistor |/your/project/pcc/pcc/pcc.py:19 |
| 2 | get_parser |/your/project/pcc/pcc/pcc.py:26 |
| 1 | detect_file_lanuage |/your/project/pcc/pcc/pcc.py:14 |
| 1 | parse_code |/your/project/pcc/pcc/pcc.py:33 |
| 1 | calc_code_complexity |/your/project/pcc/pcc/pcc.py:37 |
| 1 | calc_code_complexity_from_file |/your/project/pcc/pcc/pcc.py:49 |
pcc . -j 8 -e ./venv -e ./docs -e ./languages
Code Cyclomatic Complexity Caculator
| Complexity | Function | File |
|------------|-----------------------|-----------------------------------------------------------|
| 7 | class | /your/project/pcc/pcc/python/vistor_impl.py:94 |
| 7 | class | /your/project/pcc/pcc/python/vistor_impl.py:117 |
| 7 | class | /your/project/pcc/build/lib/pcc/python/vistor_impl.py:94 |
| 7 | class | /your/project/pcc/build/lib/pcc/python/vistor_impl.py:117 |
| 6 | travel_dir_and_filter | /your/project/pcc/pcc/utils.py:33 |
| 6 | check_or_download | /your/project/pcc/pcc/cli.py:38 |
| 6 | class |/your/project/pcc/tests/data/python3/directory/class.py:15 |
| 6 | myfun |/your/project/pcc/tests/data/python3/directory/class.py:32 |
| 6 | myfun2 |/your/project/pcc/tests/data/python3/directory/class.py:52 |
| 6 | travel_dir_and_filter | /your/project/pcc/build/lib/pcc/utils.py:33 |
Procee [37] files use Time: 0.04288077354431152 s
as u can see, -e
can exclude directory you don't want, and can use multi times.
download repo and initialize environment
python3 -m venv venv
source ./venv/bin/activate
pip3 install -r requirements_dev.txt
# or use aliyun
pip3 install -r requirements_dev.txt -i https://mirrors.aliyun.com/pypi/simple/
git submodule update --init
compile dynamic library
make lib
run test
make test
- add tree-sitter-parser project to languages dir
- build new language so
- add new dir in
pcc
dir like python. - implement node, parser, vistor for new language
- add unit test
- add json output for future analyze
- depoly to pipy
- add c language
- add macos, windows support
- do more test
- comment support
Cookiecutter
audreyr/cookiecutter-pypackage
cyclomatic complexities Wiki
gocyclo
tree-sitter
py-tree-sitter
mccabe
cccalculator