问题
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