Jones Complexity checker,flake8插件
项目描述
Flake8扩展,用于计算每行复杂度和总代码密度。
安装
$ pip install jones-complexity
使用(独立使用)
$ python -m jones_complexity --min 5 your_file.py
使用(flake8)
$ flake8 --max-line-complexity 15 --max-jones-score 8 yourproject
这是什么?
因为
if user.get_full_name().toUpper().split(' ')[0] == 'ALICE':
return True
比
if first_name == 'Alice':
return True
无耻地以我的名字命名,遵循McCabe和Halstead的传统。
示例
自身
$ python jones_complexity.py jones_complexity.py Line counts: { "39": 19, "46": 15, "137": 12, "115": 12, [...] "18": 1, "9": 1, "148": 1 } Jones Score: 4.0
$ p jones_complexity.py pyesprima.py Line counts: { "4182": 265, "3688": 190, "4186": 189, "48": 189, "4181": 164, [...] "1201": 1, "3728": 1 } Jones Score: 9.0