UnnecessarySemicolonInEnumeration
Since Checkstyle 8.22
Description
Checks if unnecessary semicolon is in enum definitions.
Semicolon is not needed if enum body contains only enum constants.
Examples
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
}
Example of Usage
Violation Messages
All messages can be customized if the default message doesn't suit you. Please see the documentation to learn how to.
Package
com.puppycrawl.tools.checkstyle.checks.coding