免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 6966 | 回复: 3
打印 上一主题 下一主题

python静态代码分析工具——pylint [复制链接]

论坛徽章:
2
2015年迎新春徽章
日期:2015-03-04 09:55:28IT运维版块每日发帖之星
日期:2016-07-29 06:20:00
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-11-24 16:11 |只看该作者 |倒序浏览
1·下载地址:
http://www.logilab.org/project/pylint

2·安装:
pylint-0.22.0.tar.gz
解压,然后python setup.py install
安装过程会自动下载并安装
logilab-astng-0.21.0.tar.gz  logilab-common-0.53.0.tar.gz
这两个工具。

3·使用语法:
pylint 参数 py脚本
如果不加任何参数,会有一个"No config file found, using default configuration"这样的提示,
解决办法,可以生成一个默认的配置文件
pylint --generate-rcfile > pylint.conf
然后再执行
pylint --rcfile=pylint.conf ……

4·参考
http://www.ibm.com/developerworks/cn/linux/l-cn-pylint/index.html

(C) 惯例。违反了编码风格标准
(R) 重构。写得非常糟糕的代码。
(W) 警告。某些 Python 特定的问题。
(E) 错误。很可能是代码中的错误。
(F) 致命错误。阻止 Pylint 进一步运行的错误。

5·总结:
    操作符的左右要加空格
    自定义的变量要大写并简短(([A-Z_][A-Z0-9_]*)|(__.*__))$)
    每行的代码不要太长

论坛徽章:
0
2 [报告]
发表于 2010-12-27 09:53 |只看该作者
pylint 你没说他是刚什么的。至少你得简单介绍下他的功能吧?

论坛徽章:
0
3 [报告]
发表于 2011-01-07 09:25 |只看该作者
pylint自己介绍是说,它是python代码检查工具。

--------------
1. What is pylint?
Pylint is a tool that checks for errors in python code, tries to enforce a coding standard and looks for bad code smells. This is similar but nevertheless different from what pychecker provides, especially since pychecker explicitly does not bother with coding style. The default coding style used by pylint is close to Guido's style guide. For more information about code smells, refer to Martin Fowler's refactoring book
Pylint will display a number of errors and warnings as it analyzes the code, as well as some statistics about the number of warnings and errors found in different files. If you run pylint twice, it will display the statistics from the previous run together with the ones from the current run, so that you can see if the code has improved or not.
Last but not least, the code is given an overall mark, based on the number an severity of the warnings and errors. This has proven to be very motivating for programmers.

论坛徽章:
0
4 [报告]
发表于 2011-01-07 09:26 |只看该作者
其实,主要是代码的风格检查,而不是逻辑检查。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP