Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 months ago.
The community reviewed whether to reopen this question 6 months ago and left it closed:
Original close reason(s) were not resolved
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(8)
为了测量圈复杂度,有一个很好的工具,位于 traceback.org。 该页面还很好地概述了如何解释结果。
+1 pylint。 它非常适合验证对编码标准的遵守情况(无论是 PEP8 还是您自己的组织的变体),这最终有助于降低圈复杂度。
For measuring cyclomatic complexity, there's a nice tool available at traceback.org. The page also gives a good overview of how to interpret the results.
+1 for pylint. It is great at verifying adherence to coding standards (be it PEP8 or your own organization's variant), which can in the end help to reduce cyclomatic complexity.
对于圈复杂度,您可以使用
radon
:https://github.com/rubik/radon< /a>(使用
pip
安装它:pip install radon
)此外,它还具有以下功能:
For cyclomatic complexity you can use
radon
: https://github.com/rubik/radon(Use
pip
to install it:pip install radon
)Additionally it also has these features:
对于静态分析,有 pylint 和 pychecker。 我个人使用 pylint,因为它似乎比 pychecker 更全面。
对于圈复杂度,你可以尝试这个perl程序,或者这个文章 介绍了一个Python程序来做同样的事情
For static analysis there is pylint and pychecker. Personally I use pylint as it seems to be more comprehensive than pychecker.
For cyclomatic complexity you can try this perl program, or this article which introduces a python program to do the same
当您需要了解一个新项目时,Pycana 非常有用!
看看它怎么运作:
http://pycana.sourceforge.net/
输出:
Pycana works like charm when you need to understand a new project!
See how it works:
http://pycana.sourceforge.net/
output:
感谢Pydev,您可以在 Eclipse IDE 中集成 pylint 非常容易,并分别获得一个代码报告保存修改后的文件的时间。
Thanks to Pydev, you can integrate pylint in the Eclipse IDE really easily and get a code report each time you save a modified file.
使用 flake8,它在一个工具中提供了 pep8、pyflakes 和圈复杂度分析
Use flake8, which provides pep8, pyflakes, and cyclomatic complexity analysis in one tool
有一个工具叫
CloneDigger 可帮助您查找类似的代码片段。
There is a tool called
CloneDigger that helps you find similar code snippets.
为了检查圈复杂度,当然有
mccabe
包。安装:
使用方法:
注意上面6的阈值。 根据这个答案,分数> 5可能应该被简化。
使用
--min=3
的示例输出:它也可以选择通过 pylint-mccabe 或 pytest-mccabe 等。
For checking cyclomatic complexity, there is of course the
mccabe
package.Installation:
Usage:
Note the threshold of 6 above. Per this answer, scores >5 probably should be simplified.
Sample output with
--min=3
:It can optionally also be used via pylint-mccabe or pytest-mccabe, etc.