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 restricting access to my variables/methods/classes , I usually did not use the public, but I could not.

I'm just wondering if there is any tool - a plugin, external or other - that can search your source code, find what calls your variables/methods/classes , and change the visibility if it is too high.

So, for example, if I had an open variable and did not call anything from this class, then the tool would reduce its access to the closed one.

Mostly I need this for some of my old projects that have many public variables. It would take me a long time to sift them all and it would be extremely unpleasant / inefficient to leave them public when I return to these projects to work on them again.

+4
source share
3 answers

Take a look at UCDetector: an unnecessary code detector Eclipse plugin. It will create markers for the following problems (which appear in the Eclipse problem view):

  • Unnecessary (dead) code
  • Code in which visibility can be changed to secure, default or private
  • Field Methods That May Be Final

It also supports Eclipse QuickFixes for automatically setting item visibility

+2
source

I have never heard or read about something like what you are asking for, but maybe PMD can help you: it will not fix your problems, but it will point to them. Next time, use personal attributes for all your attributes and create getters and setters (in eclipse, press Atl + Shift + R and then "s" to do this automatically)

0
source

There are many code quality tools designed to get too wide access: Sonar, PMD, FindBugs ... however they will not change the original source for you. The main focus should be on improving your habits and using tools to remind you of the places where you were wrong, and not use any plug-in as a crutch for bad habits.

0
source

Source: https://habr.com/ru/post/1483372/


All Articles