Java – is there a tool in eclipse, an eclipse plug-in, or an external program that can automatically restrict access to modifiers?

I used to be very bad at restricting access to my variables / methods / classes. When I shouldn't, I tend to use public places

I just want to know if there are any tools - plug-ins, external or others - that can search your source code and find what calls your variables / methods / classes. If it is too high, it will change the visibility

So, for example, if I have a public variable and nothing outside the class calls it, the tool will reduce its access to private variables

For some old projects with many public variables, I mainly need this It takes me a long time to filter out all these contents. When I go back to these projects and deal with them again, it is very annoying / inefficient to make them public

Solution

Look at the ucdetector: unnecessary code detector Eclipse Plug-in It will create a tag for the following issues (which appear in the eclipse issues view):

>Unnecessary (dead) code > visibility can be changed to protected, and the default or private > field method can be final

It also supports eclipse quickfixes to automatically adjust member visibility

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>