推荐个Java代码质量检测的利器 —— FindBugs

一、下载

插件的下载地址(sourceforge):FindBugs-Eclipse插件

二、安装

Eclipse插件的安装,就不多说了。

三、使用

1、找一个Project,选中它(也可以针对某个Package或者某个Java文件),右键,会看到如下图所示的菜单。点击【Find Bugs】,看一下运行的结果,你就知道这是干什么用的了。

  

 

2、检查完以后,在 Bug Explorer 视图中,会看到结果,如图。都是些明显或者不明显的BUG。

  例如,

  a、Comparison of String objects using == or !=

    使用 == 或者 != 来判断两个 String 对象是否相等

  b、Dead store to local variable

    对局部变量重新赋值以后又没有使用

  c、Exception created and droped rather than thrown

    创建(new)了一个异常,但没有抛出(throw)

  d、Nullcheck of value previously dereferenced

    可能会抛出 NullPointerException 异常的代码

  .

  .

  .

  

 

posted on 2013-07-30 16:53  Memory4Young  阅读(754)  评论(1编辑  收藏  举报

导航