Since Checkstyle 8.22
Checks if unnecessary semicolon is in enum definitions. Semicolon is not needed if enum body contains only enum constants.
To configure the check:
<module name="Checker"> <module name="TreeWalker"> <module name="UnnecessarySemicolonInEnumeration"/> </module> </module>
Example of violations
enum One { A,B; // violation } enum Two { A,B,; // violation } enum Three { A,B(); // violation } enum Four { A,B{}; // violation } enum Five { A, B ; // violation }
Example of good cases
enum Normal { A, B, ; // required ";", no violation Normal(){} } enum NoSemicolon { A, B // only enum constants, no semicolon required }
All messages can be customized if the default message doesn't suit you. Please see the documentation to learn how to.
com.puppycrawl.tools.checkstyle.checks.coding