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

别来无恙 提交于 2019-12-05 09:16:30

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

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

There are many code quality tools designed to pick up on overly-broad access like this: Sonar, PMD, FindBugs...however, they will not modify the original source for you. The focus should be to improve your habits, and use the tools to remind you of places where you have faltered mistakenly, not use some plugin as a crutch for bad habits.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!