【发布时间】:2019-07-22 18:38:20
【问题描述】:
我想使用 PyLint 计算圈复杂度。我需要一个 python 脚本来一次计算许多模块的复杂性。
我尝试过使用命令以及通过 python 程序。
这是我正在使用的命令:
pylint shortQuestion.py --load-plugins=pylint.extensions.mccabe
这是我在 python 中使用的代码:
import pylint.lint
pylint_opts = ['basics.py','--load-plugins=pylint.extensions.mccabe','--rcfile=~/.pylintrc']
pylint.lint.Run(pylint_opts)
这是我从命令和代码中得到的结果:
Using config file /var/root/.pylintrc
************* Module shortQuestion
W: 5, 0: Found indentation with tabs instead of spaces (mixed-indentation)
W: 6, 0: Found indentation with tabs instead of spaces (mixed-indentation)
W: 7, 0: Found indentation with tabs instead of spaces (mixed-indentation)
W: 8, 0: Found indentation with tabs instead of spaces (mixed-indentation)
C: 1, 0: Module name "shortQuestion" doesn't conform to snake_case naming style (invalid-name)
C: 1, 0: Missing module docstring (missing-docstring)
C: 4, 0: Function name "isContained" doesn't conform to snake_case naming style (invalid-name)
C: 4, 0: Missing function docstring (missing-docstring)
R: 5, 1: Unnecessary "else" after "return" (no-else-return)
W: 4,16: Unused argument 'cls' (unused-argument)
----------------------------------------------------------------------
Your code has been rated at -15.00/10 (previous run: 10.00/10, -25.00)
这里是 -15.00/10 圈复杂度吗?如果是,我怎样才能以格式化的方式获得输出?因为我需要一次计算许多 python 模块的复杂性。如果没有,我该如何计算?
【问题讨论】:
标签: python pylint cyclomatic-complexity