PMD和FindBugs有什么区别? [英] What are the differences between PMD and FindBugs?

查看:692
本文介绍了PMD和FindBugs有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个比较PMD和CheckStyle的问题。但是,我找不到PMD和FindBugs之间差异/相似性的细分。我认为一个关键的区别是PMD适用于源代码,而FindBugs适用于编译的字节码文件。但就能力而言,它应该是一个或两个选择还是相互补充?

There was a question comparing PMD and CheckStyle. However, I can't find a nice breakdown on the differences/similarities between PMD and FindBugs. I believe a key difference is that PMD works on source code, while FindBugs works on compiled bytecode files. But in terms of capabilities, should it be an either/or choice or do they complement each other?

推荐答案

我正在使用都。我认为它们相互补充。

I'm using both. I think they complement each other.

如你所说, PMD 适用于源代码,因此会发现以下问题:违反命名约定,缺少花括号,错误的空检查,长参数列表,不必要的构造函数,缺少切换中断等等.PMD还会告诉您代码的Cyclomatic复杂性我觉得非常有帮助(FindBugs没有告诉你关于Cyclomatic复杂性)。

As you said, PMD works on source code and therefore finds problems like: violation of naming conventions, lack of curly braces, misplaced null check, long parameter list, unnecessary constructor, missing break in switch, etc. PMD also tells you about the Cyclomatic complexity of your code which I find very helpful (FindBugs doesn't tell you about the Cyclomatic complexity).

FindBugs 适用于字节码。以下是FindBugs发现哪些PMD不存在的问题:equals()方法在子类型上失败,clone方法可能返回null,布尔值的引用比较,不可能的转换,32位int移位的数量不在0-31范围内,包含自身的集合,equals方法总是返回true,无限循环等。

FindBugs works on bytecode. Here are some problems FindBugs finds which PMD doesn't: equals() method fails on subtypes, clone method may return null, reference comparison of Boolean values, impossible cast, 32bit int shifted by an amount not in the range of 0-31, a collection which contains itself, equals method always returns true, an infinite loop, etc.

通常每个集合都会找到一组不同的问题。两者兼用。这些工具教会了我很多关于如何编写优秀Java代码的知识。

Usually each of them finds a different set of problems. Use both. These tools taught me a lot about how to write good Java code.

这篇关于PMD和FindBugs有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆