简体   繁体   中英

Java static code analysis

我正在寻找eclipse / netbeans插件或分析java项目的工具,并给我们报告未使用的导入,未使用的变量,未使用的方法, 违反自定义命名约定等。

Eclipse provides it as Markers . It will provide all your cases except violating custom naming conventions .

在此输入图像描述

FindBugs is probably one of the most prominent ones and well worth a try.

For naming conventions etc, I'd suggest you have a look at CheckStyle.

Netbeans 7.2 has a new Inspect feature: goto Source|Inspect from the menu. It certainly has most of the tests for mentioned in your question.

... in addition look at sonar . It's been quiet the eye opener when I first discovered it.

Findbugs works well as Eclipse plugin, and is easily customizable.

If you're looking for something bigger, or you work in a continous integration environment, I'd go for Sonar .

For the little things like naming conventions and imports, I agree with the other answers that PMD is a pretty good choice.

[shameless plug] This may be overkill, but there's a tool called "Codefacts" that the company that I work at developed, which will analyze your code from a git or svn repository. It runs metrics and stuff to assess code quality. It might fit into your "etc.."

I can't recall all of the metrics it uses, but some of them are things like comment/code ratio, documentation coverage, checking if a lot of your methods/classes are too long, and a bunch more. Codefacts can be downloaded here [/shameless plug]

我使用三种相互补充的工具组合:PMD,Checkstyle和FindBugs。

尝试Checkstyle(我的偏好)或PMD。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM