Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find all unused variable

Tags:

java

netbeans

Normally it's easy to see unused variables in Netbeans, just a grey squiggly line.

But how would I find all of these unused variables in my project or of a single class?

Reason: I'm debugging a code base which had lots of copy and paste, but it wasn't done carefully. There's many bug of not replacing with the right variable after copy and paste.

like image 641
Dan Avatar asked Dec 10 '08 14:12

Dan


Video Answer


1 Answers

You could run something like FindBugs on it.

FindBugs

Looking at the bug list it has

UuF: Unused field (UUF_UNUSED_FIELD) This field is never used. Consider removing it from the class.

You could filter on just this, but it is a good idea to run this on all code all the time, it is amazing what it finds.

like image 98
Shawn Vader Avatar answered Sep 30 '22 04:09

Shawn Vader