Thursday, March 04, 2010

Static Code Analysis Tool – Find Bugs Tutorial

A quick two minute tutorial with sample code to get you started on Static Code Analysis Tool – Find Bugs.



What is it?

FindBugs is an open source program created by William Pugh which looks for bugs in Java code. It uses static analysis to identify hundreds of different potential types of errors in Java programs. FindBugs operates on Java bytecode,rather than source code. The software is distributed as a stand-alone GUI application. There are also plug-ins available for Eclipse, Netbeans, and IntelliJ IDEA


Official Website?

http://findbugs.sourceforge.net/



How to Install the Eclipse Plugin?

http://findbugs.cs.umd.edu/eclipse/




Demo & FAQ?

http://findbugs.sourceforge.net/demo.html / http://findbugs.sourceforge.net/FAQ.html


How does it work and how to use it?

a) After you install the eclipse plugin, restart eclipse.

b) Go to Window –> Show view –> other and select the find bug options available.



c) Open – perspective – Findbugs [Window –> open perspective–> findbugs]




c) Create a potential test class (with some obvious issues) like the following,




d) Initiate the find bugs by doing the following.




e) Now the errors get listed based on Project – Type – Package – Class – Priority – Category – Error – Location





f) Now you try to correct them :)



Final Verdict – I am able to find several small but nevertheless ISSUES in existing code, so I would say it is a must use tool and yes it is free WHY NOT?


m.m

No comments: