Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a tool in eclipse, a plugin for eclipse, or an external program that can automatically limit access modifiers?

I used to be incredibly bad at limiting access of my variables/methods/classes, I tended to use public a hell of a lot when I shouldn't.

I was just wondering if there was any tool - plugin, external or otherwise - that can search your source code, find what calls your variables/methods/classes and changes the visibility if it's too high.

So for example, if I had a public variable and nothing outside that class called it, then the tool would reduce its access to private.

Mainly I need this for some of my older projects that have to many public variables. It would take far to long for me to sift through all of them and would be extremely annoying/inefficient to leave them public, when I come back to these projects to work on them again.

like image 475
Benjamin Tilbury Avatar asked Oct 22 '22 08:10

Benjamin Tilbury


1 Answers

Take a look at the UCDetector: Unnecessary Code Detector Eclipse plugin. It will create markers for the following problems (which appear in the Eclipse problem view):

  • Unnecessary (dead) code
  • Code where the visibility could be changed to protected, default or private
  • Methods of fields, which can be final

It also has support for Eclipse QuickFixes to automatically adjust member visibility

like image 91
RKumsher Avatar answered Nov 02 '22 04:11

RKumsher