File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Swerrgy Smith
Ranch Hand
Posts: 94
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 118
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)
 
Swerrgy Smith
Ranch Hand
Posts: 94
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1704
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I too use FindBugs, its quite useful.
 
Swerrgy Smith
Ranch Hand
Posts: 94
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic