如何分析Python代码以识别问题区域? [英] How can I analyze Python code to identify problematic areas?
问题描述
我有一个大型的源代码仓库,分布在多个项目中。我想生成一份有关源代码运行状况的报告,确定需要解决的问题区域。
I have a large source repository split across multiple projects. I would like to produce a report about the health of the source code, identifying problem areas that need to be addressed.
特别是,我想用高度复杂的循环,确定重复,并可能进行类似棉绒的静态分析以发现可疑(因而可能是错误的)构造。
Specifically, I'd like to call out routines with a high cyclomatic complexity, identify repetition, and perhaps run some lint-like static analysis to spot suspicious (and thus likely erroneous) constructs.
我应该如何构造这样的构造
How might I go about constructing such a report?
推荐答案
要测量圈复杂度,在 traceback.org 。该页面还很好地概述了如何解释结果。
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表示圆筒。它非常适合验证是否遵守编码标准(无论是 PEP8 还是您自己的组织的变体),最终可以帮助降低圈复杂度。
+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.
这篇关于如何分析Python代码以识别问题区域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!