FindBugs,
http://findbugs.sourceforge.net/
發現代碼中潛在bug的工具,有eclipse的插件,安裝后右鍵單擊java project name,點擊Find Bugs,切換到FindBugs得perspective可以看到結果,速度還比較快,比之前用過的一個(雖然已經記不得名字了)快一些~具體的效果還是要逐個分析。
Bug categories:
- Correctness bug
- Probable bug - an apparent coding mistake
resulting in code that was probably not what the
developer intended. We strive for a low false positive rate.
- Bad Practice
-
Violations of recommended and essential
coding practice. Examples include hash code and equals
problems, cloneable idiom, dropped exceptions,
serializable problems, and misuse of finalize.
We strive to make this analysis accurate,
although some groups may
not care about some of the bad practices.
- Dodgy
-
Code that is confusing, anomalous, or
written in a way that leads itself to errors.
Examples include dead local stores, switch fall through,
unconfirmed casts, and redundant null check of value
known to be null.
More false positives accepted.
In previous versions of FindBugs, this category was known as Style.
Multithreaded correctness
Incorrect lazy initialization and update of static field
Calls Thread.sleep() with a lock held: better to use wait(lock)
Synchronization on interned String could deadlock: 最好不用字符串,以免重復
Performance
invokes inefficient new String() constructor
concatenates strings using + in a loop: better to use append StringBuffer
inner class usage