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
}
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
}
        

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

Parent Module

TreeWalker