Add UnnecessarySemicolonAfterOuterTypeDeclaration

commit-id:e9b3967d
This commit is contained in:
Paul Campbell 2021-08-13 22:23:51 +01:00
parent 82868e9632
commit 767937448f
8 changed files with 110 additions and 0 deletions

View file

@ -274,6 +274,7 @@ Rule|Level|Source|Enabled|Suppressible
[UniformEnumConstantName](#uniformenumconstantname)|naming|sevntu|Yes| [UniformEnumConstantName](#uniformenumconstantname)|naming|sevntu|Yes|
[UniqueProperties](#uniqueproperties)|javadoc|checkstyle|Yes| [UniqueProperties](#uniqueproperties)|javadoc|checkstyle|Yes|
[UnnecessaryParentheses](#unnecessaryparentheses)|layout|checkstyle|Yes| [UnnecessaryParentheses](#unnecessaryparentheses)|layout|checkstyle|Yes|
[UnnecessarySemicolonAfterOuterTypeDeclaration](#unnecessarysemicolonafteroutertypedeclaration)|layout|checkstyle|Yes|
[UnusedImports](#unusedimports)|layout|checkstyle|Yes| [UnusedImports](#unusedimports)|layout|checkstyle|Yes|
[UpperEll](#upperell)|layout|checkstyle|Yes| [UpperEll](#upperell)|layout|checkstyle|Yes|
[UselessSingleCatch](#uselesssinglecatch)|tweaks|sevntu|Yes| [UselessSingleCatch](#uselesssinglecatch)|tweaks|sevntu|Yes|
@ -2134,6 +2135,55 @@ Invalid:
```` ````
if ((a < 1)) {} if ((a < 1)) {}
```` ````
#### [UnnecessarySemicolonAfterOuterTypeDeclaration](https://checkstyle.sourceforge.io/config_coding.html#UnnecessarySemicolonAfterOuterTypeDeclaration)
Checks if unnecessary semicolon is used after type declaration.
Valid:
````java
class A {
class Nested {
}; // OK, nested type declarations are ignored
}
interface B {
}
enum C {
}
@interface D {
}
````
Invalid:
````java
class A {
class Nested {
}; // OK, nested type declarations are ignored
}; // violation
interface B {
}; // violation
enum C {
}; // violation
@interface D {
}; // violation
````
#### [UnusedImports](http://checkstyle.sourceforge.net/config_imports.html#UnusedImports) #### [UnusedImports](http://checkstyle.sourceforge.net/config_imports.html#UnusedImports)
Checks for unused imports. Does not inspect wildcard imports, which should be blocked by [AvoidStarImport](#avoidstarimport) anyway. Checks for unused imports. Does not inspect wildcard imports, which should be blocked by [AvoidStarImport](#avoidstarimport) anyway.

View file

@ -1573,3 +1573,10 @@ rules:
enabled: true enabled: true
source: CHECKSTYLE source: CHECKSTYLE
uri: https://checkstyle.sourceforge.io/config_javadoc.html#JavadocMissingWhitespaceAfterAsterisk uri: https://checkstyle.sourceforge.io/config_javadoc.html#JavadocMissingWhitespaceAfterAsterisk
-
name: UnnecessarySemicolonAfterOuterTypeDeclaration
parent: TREEWALKER
level: LAYOUT
enabled: true
source: CHECKSTYLE
uri: https://checkstyle.sourceforge.io/config_coding.html#UnnecessarySemicolonAfterOuterTypeDeclaration

View file

@ -0,0 +1,48 @@
Checks if unnecessary semicolon is used after type declaration.
Valid:
````java
class A {
class Nested {
}; // OK, nested type declarations are ignored
}
interface B {
}
enum C {
}
@interface D {
}
````
Invalid:
````java
class A {
class Nested {
}; // OK, nested type declarations are ignored
}; // violation
interface B {
}; // violation
enum C {
}; // violation
@interface D {
}; // violation
````

View file

@ -56,6 +56,7 @@
<module name="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMissingLeadingAsteriskCheck"/> <module name="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMissingLeadingAsteriskCheck"/>
<module name="com.puppycrawl.tools.checkstyle.checks.NoCodeInFileCheck"/> <module name="com.puppycrawl.tools.checkstyle.checks.NoCodeInFileCheck"/>
<module name="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMissingWhitespaceAfterAsteriskCheck"/> <module name="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMissingWhitespaceAfterAsteriskCheck"/>
<module name="com.puppycrawl.tools.checkstyle.checks.coding.UnnecessarySemicolonAfterOuterTypeDeclarationCheck"/>
</module><!-- /TreeWalker --> </module><!-- /TreeWalker -->

View file

@ -83,6 +83,7 @@
<module name="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMissingLeadingAsteriskCheck"/> <module name="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMissingLeadingAsteriskCheck"/>
<module name="com.puppycrawl.tools.checkstyle.checks.NoCodeInFileCheck"/> <module name="com.puppycrawl.tools.checkstyle.checks.NoCodeInFileCheck"/>
<module name="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMissingWhitespaceAfterAsteriskCheck"/> <module name="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMissingWhitespaceAfterAsteriskCheck"/>
<module name="com.puppycrawl.tools.checkstyle.checks.coding.UnnecessarySemicolonAfterOuterTypeDeclarationCheck"/>
</module><!-- /TreeWalker --> </module><!-- /TreeWalker -->

View file

@ -102,6 +102,7 @@
<module name="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMissingLeadingAsteriskCheck"/> <module name="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMissingLeadingAsteriskCheck"/>
<module name="com.puppycrawl.tools.checkstyle.checks.NoCodeInFileCheck"/> <module name="com.puppycrawl.tools.checkstyle.checks.NoCodeInFileCheck"/>
<module name="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMissingWhitespaceAfterAsteriskCheck"/> <module name="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMissingWhitespaceAfterAsteriskCheck"/>
<module name="com.puppycrawl.tools.checkstyle.checks.coding.UnnecessarySemicolonAfterOuterTypeDeclarationCheck"/>
</module><!-- /TreeWalker --> </module><!-- /TreeWalker -->

View file

@ -145,6 +145,7 @@
<module name="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMissingLeadingAsteriskCheck"/> <module name="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMissingLeadingAsteriskCheck"/>
<module name="com.puppycrawl.tools.checkstyle.checks.NoCodeInFileCheck"/> <module name="com.puppycrawl.tools.checkstyle.checks.NoCodeInFileCheck"/>
<module name="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMissingWhitespaceAfterAsteriskCheck"/> <module name="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMissingWhitespaceAfterAsteriskCheck"/>
<module name="com.puppycrawl.tools.checkstyle.checks.coding.UnnecessarySemicolonAfterOuterTypeDeclarationCheck"/>
</module><!-- /TreeWalker --> </module><!-- /TreeWalker -->

View file

@ -192,6 +192,7 @@
<module name="com.puppycrawl.tools.checkstyle.checks.sizes.LambdaBodyLengthCheck"/> <module name="com.puppycrawl.tools.checkstyle.checks.sizes.LambdaBodyLengthCheck"/>
<module name="com.puppycrawl.tools.checkstyle.checks.NoCodeInFileCheck"/> <module name="com.puppycrawl.tools.checkstyle.checks.NoCodeInFileCheck"/>
<module name="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMissingWhitespaceAfterAsteriskCheck"/> <module name="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMissingWhitespaceAfterAsteriskCheck"/>
<module name="com.puppycrawl.tools.checkstyle.checks.coding.UnnecessarySemicolonAfterOuterTypeDeclarationCheck"/>
</module><!-- /TreeWalker --> </module><!-- /TreeWalker -->