Checkstyle - methods order by modifier

风格不统一 提交于 2020-06-12 07:54:39

问题


Is it possible add to checkstyle rule to have ordered methods in class by modifier. I mean public methods on the begining and private methods in the end ?


回答1:


MethodsOrderCheck do this job.

Check the documentation

FYI: there is some logical issue about it.




回答2:


Checkstyle has a check for that called DecralationOrderCheck - http://checkstyle.sourceforge.net/apidocs/com/puppycrawl/tools/checkstyle/checks/coding/DeclarationOrderCheck.html

You may find it in the 'Coding' group. Please tell me if that helps.




回答3:


You could use: <module name="ModifierOrder"/> that checks the order of modifiers.

http://checkstyle.sourceforge.net/apidocs/com/puppycrawl/tools/checkstyle/checks/modifier/ModifierOrderCheck.html



来源:https://stackoverflow.com/questions/49457690/checkstyle-methods-order-by-modifier

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