4

After eliminating some specific nonsense pattern, I need to identify and possibly delete fields that are declared in some interface like this:

public interface X
{
    String A = "xxx";
    String B = "zzz";
}

Sure I can use Eclipse's "find all references" for one identifier after another, but facing thousands of them lets that appear like a very dull fulltime job for days to come.

I tried both Google CodePro and the warnings that the Java compiler can spit out on demand, but found only options for non-public fields in classes, not for public fields in interfaces.

My next try would be: Comment them all out, and go through the errorlist. All fields that are not in the error list can be safely (in my case!) removed. That will be a dull day, too, because instead of a list of all fields that do have active references I am looking for a list of all fields that are not referenced anywhere.

So how can I find all those now-unreferenced fields efficiently?

I mean: I see it is dangerous to look at those references for a given project because another project that my Eclipse workspace does not know about might have references. That might be the rationale behind not offering the warning/analysis option I look for in Eclipse or CodePro.

This is not the case here, though. If it's not references in my project, I want to eliminate it.

TheBlastOne
  • 4,291
  • 3
  • 38
  • 72

2 Answers2

9

I think UCDetector is what you want : http://www.ucdetector.org/

Guillaume USE
  • 436
  • 1
  • 4
  • 6
0

If IntelliJ IDEA is option for you, even free community edition will highlight unused interface methods on the spot

Konstantin Pribluda
  • 12,329
  • 1
  • 30
  • 35