我想通过使用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模块的复杂度。如果没有,我该如何计算?
答案 0 :(得分:0)
在输出末尾看到的分数是基于pylint的代码质量的总体分数。如果您修复了所有这些警告,则评分将达到10分(满分10分)。
如果您的圈复杂度过高,您应该看到的消息是:
R:1:“功能1”太复杂。 McCabe评分为11(过于复杂)
另请参阅docs。