Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I find (and eliminate) all unreferenced fields declared in an interface?

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.

like image 732
TheBlastOne Avatar asked Jan 17 '23 03:01

TheBlastOne


1 Answers

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

like image 198
Guillaume USE Avatar answered Feb 01 '23 08:02

Guillaume USE