UnnecessarySemicolonAfterOuterTypeDeclaration

Since Checkstyle 8.31

Description

Checks if unnecessary semicolon is used after type declaration.

Notes

This check is not applicable to nested type declarations, UnnecessarySemicolonAfterTypeMemberDeclaration is responsible for it.

Properties

name description type default value since
tokens tokens to check subset of tokens CLASS_DEF , INTERFACE_DEF , ENUM_DEF , ANNOTATION_DEF , RECORD_DEF . CLASS_DEF , INTERFACE_DEF , ENUM_DEF , ANNOTATION_DEF , RECORD_DEF . 8.31

Examples

To configure the check:

<module name="Checker">
  <module name="TreeWalker">
    <module name="UnnecessarySemicolonAfterOuterTypeDeclaration"/>
  </module>
</module>
        

Example:

class Example1 {
  class Nested {

  }; // OK, nested type declarations are ignored

}; // violation

interface B {

}; // violation

enum C {

}; // violation

@interface D {

}; // violation
        

To configure the check to detect unnecessary semicolon only after top level class definitions:

<module name="Checker">
  <module name="TreeWalker">
    <module name="UnnecessarySemicolonAfterOuterTypeDeclaration">
      <property name="tokens" value="CLASS_DEF"/>
    </module>
  </module>
</module>
        

Example:

class Example2 {
  class Nested {

  }; // OK, nested type declarations are ignored

}; // violation

interface T {

};

enum U {

};

@interface V {

};
        

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