I am using plugin
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.17</version>
It has 6.11.2 checkstyle version. Configuration saying about whitespaces is:
<module name="NoWhitespaceAfter">
<property name="severity" value="error" />
<property name="tokens" value="ARRAY_INIT,BNOT,DEC,DOT,INC,LNOT" />
</module>
<module name="NoWhitespaceBefore">
<property name="severity" value="error" />
</module>
<module name="RedundantModifier">
<property name="severity" value="error" />
</module>
<module name="WhitespaceAround">
<property name="severity" value="error" />
<property name="tokens" value="ASSIGN,BAND,BAND_ASSIGN,BOR,BOR_ASSIGN,BSR,BSR_ASSIGN,BXOR,BXOR_ASSIGN,COLON,DIV,DIV_ASSIGN,DO_WHILE,EQUAL,GE,LAND,LCURLY,LE,LITERAL_ASSERT,LITERAL_CATCH,LITERAL_DO,LITERAL_ELSE,LITERAL_FINALLY,LITERAL_FOR,LITERAL_IF,LITERAL_RETURN,LITERAL_SYNCHRONIZED,LITERAL_TRY,LITERAL_WHILE,LOR,MINUS,MINUS_ASSIGN,MOD,MOD_ASSIGN,NOT_EQUAL,PLUS,PLUS_ASSIGN,RCURLY,SL,SLIST,SL_ASSIGN,SR,SR_ASSIGN,STAR,STAR_ASSIGN,TYPE_EXTENSION_AND" />
</module>
I always get this error:
(whitespace) WhitespaceAround: WhitespaceAround: '?' is not preceded with whitespace.
(whitespace) WhitespaceAround: WhitespaceAround: '?' is not followed by whitespace.
Empty blocks may only be represented as {} when not part of a multi-block statement (4.1.3)
The code snippets are:
Class<?>[] groups() default {};
Class<? extends Payload>[] payload() default {};
I tried to remove the snippet with whitespaces, but still get the same error.
Description. Checks that there is no whitespace after a token. More specifically, it checks that it is not followed by whitespace, or (if linebreaks are allowed) all characters on the line after are whitespace. To forbid linebreaks after a token, set property allowLineBreaks to false .
The Checkstyle Plugin generates a report regarding the code style used by the developers. For more information about Checkstyle, see https://checkstyle.org/. This version of the plugin uses Checkstyle 9.3 by default and requires Java 8. But you can upgrade the version used at runtime.
It is a bug in checkstyle, it has been fixed in Checkstyle 6.14 (see https://github.com/checkstyle/checkstyle/issues/2633)
You can upgrade checkstyle by adding a <dependencies>
section in the maven-checkstyle-plugin:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.17</version>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>6.14</version>
</dependency>
</dependencies>
</plugin>
Or you can go straight to the newest Checkstyle (7.0).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With