aspose file tools*
The moose likes Java in General and the fly likes Tool to verify null check (FindBugs, CheckStyle ..) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Tool to verify null check (FindBugs, CheckStyle ..)" Watch "Tool to verify null check (FindBugs, CheckStyle ..)" New topic
Author

Tool to verify null check (FindBugs, CheckStyle ..)

Swerrgy Smith
Ranch Hand

Joined: Mar 26, 2010
Posts: 86
Dear all,

I often forget to check if an object is null before using it.
Do you know any tool (like FindBugs, CheckStyle ...) that can detect whether an object is checked before it is used and give alarm to programmer?

Thank you very much.
Siddhesh Deodhar
Ranch Hand

Joined: Mar 05, 2009
Posts: 117
I use FindBugs. It shows me all the places where exception can come in future.

example. suppose i have a method



On this if i run findbug, it warns me at line if(cmpStr.equals("yes").
It says dont do cmpStr.equals("yes") do "yes".equals(cmpStr)


Good, Better, Best, Don't take rest until, Good becomes Better, and Better becomes Best.
Sidd : (SCJP 6 [90%] )
Swerrgy Smith
Ranch Hand

Joined: Mar 26, 2010
Posts: 86
Siddhesh Deodhar wrote:I use FindBugs. It shows me all the places where exception can come in future.

example. suppose i have a method



On this if i run findbug, it warns me at line if(cmpStr.equals("yes").
It says dont do cmpStr.equals("yes") do "yes".equals(cmpStr)


Thank you very much
Kj Reddy
Ranch Hand

Joined: Sep 20, 2003
Posts: 1704
I too use FindBugs, its quite useful.
Swerrgy Smith
Ranch Hand

Joined: Mar 26, 2010
Posts: 86
I have just checked with FindBugs. It can only find simple null check. However, if we wrote something like following code:


instead of



In this case, FindBugs will not detect what we have forgotten.
Which tool can be used for this purpose?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Tool to verify null check (FindBugs, CheckStyle ..)
 
Similar Threads
Code Review Tool
Developer Mentality
code review tool for java
Eclipse with Jlint
please explain null pointer dereference