code review 工具列表
1.代码格式检查checkstyle;
2.性能安全最佳实践检查RAD Software Analyzer和FindBug;
3.依赖检查JDepend;
4.重复性检查eclipse PMD插件;
5.复杂度检查eclipse Metrics插件;
6.协作工具Jupiter
下面是最近对这几个检查工具的使用总结:
对于代码编写格式的插件checkstyle, 鉴于这个要求太苛刻了, 估计我们大部分的代码都没法通过, 因此可以放弃.
然后看了一下FindBugs, 这个是基于对class文件进行分析检查, 当然也可以直接对java文件进行检查,
还是能发现我们代码中不少的低级错误.
这个FindBugs使用起来也非常简单,
直接安装eclipse插件(http://findbugs.cs.umd.edu/eclipse )即可. 建议每个开发人员装一个.
可以对我们的产出物进行检查, 是否存在隐患.
然后我用了另外一个用来辅助我们检查代码的插件:PDM (http://pmd.sourceforge.net/eclipse/ )
这个插件的功能更加强大, 我觉得他的两个功能非常有用:
一个是它可以发现里面存在的重复代码, 我对我们系统中的某个工程进行了一下检查,
发现了600多处重复, 所以这个检查结果太离谱了, 不适用, 可以做个参考.
另一个是对单个类进行检查, 这个非常严格, 我最近对某个服务类进行了检查, 得到下面的结果也不是很理想.
它对发现的问题定义了一些优先级(1-5). 对检查的结果进行了一下分析, 发现还是有很多东西太严格了, 没有实际参考价值, 比如这个:
A method/constructor shouldn't explicitly throw java.lang.Exception
不过我觉得它这个建议不错:
This class has too many methods, consider refactoring it.
所以我觉得它对复杂度(方法太多, 依赖太多, 一个方法中的执行路径太多等)的检查还是不错的, 其他的嘛, 参考一下就可以了,
没有必要完全遵守.
另外, 剩下的几个工具
JDepend 安装了一下, 没有跑起来, 放弃
Metrics的功能其实PMD已经部分实现, 而且安装之后发现运行非常耗时, 放弃.
Jupiter 用来辅助code
review, 感觉不够敏捷, 太繁琐了,
放弃.
所以最后我的结论是: 如果希望进一步提供系统的代码质量, 强烈推荐安装FindBugs和PMD插件. 经常性的对我们的代码进行检查!
http://bbs.51testing.com/thread-165358-1-1.html
Welcome to the FindBugs Eclipse plugin update site.
This web page provides automatic distribution and updates for the Eclipse plugin for FindBugs.
Plugin requirements
This plugin has primarily been tested with Eclipse 3.3 and 3.4 It should work with 3.x releases, but let us know if you have any problems. The plugin is not compatible with versions of Eclipse preceding 3.3. The plugin runs under Java 1.5/5.0, or newer.
Plugin installation
If you have previously installed a version of the FindBugs plugin prior to mid-May, 2006, then you should remove it first. Simply remove the de.tobject.findbugs_0.0.n directory from Eclipse's plugins directory.
To install the FindBugs plugin:
- In Eclipse, click on Help -> Software Update -> Find and Install...
- Choose the Search for new features to install option, and click Next .
- Click New Remote Site .
- Enter the following:
- Name: FindBugs update site
- URL:
one of the following (note: no final slash on the
url)
- http://findbugs.cs.umd.edu/eclipse for official releases
- http://findbugs.cs.umd.edu/eclipse-candidate for candidate releases and official releases
- http://findbugs.cs.umd.edu/eclipse-daily for all releases, including developmental ones
- "FindBugs update site" should appear under Sites to
include in search
.
Click the checkbox next to it to select it, and click Finish . - You should see FindBugs Feature
under Select
features to install
.
(You may have to click on one or two triangles to make it visible in the tree.)
Select the checkbox next to it and click next. - Select the I accept option to accept the license and click Next .
- Make sure the location is correct where you're installing it. The default (your workspace) should be fine. Click Finish .
- The plugin is not digitally signed. Go ahead and install it anyway.
- Click Yes to make Eclipse restart itself.