Since Checkstyle 8.22
To configure the check:
<module name="Checker"> <module name="TreeWalker"> <module name="UnnecessarySemicolonInEnumeration"/> </module> </module>
Example of violations
enum One { A,B; // violation, 'Unnecessary semicolon' } enum Two { A,B,; // violation, 'Unnecessary semicolon' } enum Three { A,B(); // violation, 'Unnecessary semicolon' } enum Four { A,B{}; // violation, 'Unnecessary semicolon' } enum Five { A, B ; // violation, 'Unnecessary semicolon' }
Example of good cases
enum Normal { A, B, ; // ok, enum body contains constructor Normal(){} } enum NoSemicolon { A, B // ok, only enum constants without semicolon }
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