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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With