
com.puppycrawl.tools.checkstyle.meta.checks.whitespace.WhitespaceAroundCheck.xml Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of checkstyle Show documentation
Show all versions of checkstyle Show documentation
Checkstyle is a development tool to help programmers write Java code
that adheres to a coding standard
<?xml version="1.0" encoding="UTF-8"?> <checkstyle-metadata> <module> <check fully-qualified-name="com.puppycrawl.tools.checkstyle.checks.whitespace.WhitespaceAroundCheck" name="WhitespaceAround" parent="com.puppycrawl.tools.checkstyle.TreeWalker"> <description><div> Checks that a token is surrounded by whitespace. Empty constructor, method, class, enum, interface, loop bodies (blocks), lambdas of the form </div> <pre> public MyClass() {} // empty constructor public void func() {} // empty method public interface Foo {} // empty interface public class Foo {} // empty class public enum Foo {} // empty enum MyClass c = new MyClass() {}; // empty anonymous class while (i = 1) {} // empty while loop for (int i = 1; i &gt; 1; i++) {} // empty for loop do {} while (i = 1); // empty do-while loop Runnable noop = () -&gt; {}; // empty lambda public @interface Beta {} // empty annotation type </pre> <p> may optionally be exempted from the policy using the {@code allowEmptyMethods}, {@code allowEmptyConstructors}, {@code allowEmptyTypes}, {@code allowEmptyLoops}, {@code allowEmptyLambdas}, {@code allowEmptyCatches} and {@code allowEmptySwitchBlockStatements} properties. </p> <p> This check does not flag as violation double brace initialization like: </p> <pre> new Properties() {{ setProperty("key", "value"); }}; </pre> <p> Parameter allowEmptyCatches allows to suppress violations when token list contains SLIST to check if beginning of block is surrounded by whitespace and catch block is empty, for example: </p> <pre> try { k = 5 / i; } catch (ArithmeticException ex) {} </pre> <p> With this property turned off, this raises violation because the beginning of the catch block (left curly bracket) is not separated from the end of the catch block (right curly bracket). </p> <p> Note: <a href="https://openjdk.org/jeps/361"> Switch expressions</a> are ignored by this check. </p></description> <properties> <property default-value="false" name="allowEmptyCatches" type="boolean"> <description>Allow empty catch bodies.</description> </property> <property default-value="false" name="allowEmptyConstructors" type="boolean"> <description>Allow empty constructor bodies.</description> </property> <property default-value="false" name="allowEmptyLambdas" type="boolean"> <description>Allow empty lambda bodies.</description> </property> <property default-value="false" name="allowEmptyLoops" type="boolean"> <description>Allow empty loop bodies.</description> </property> <property default-value="false" name="allowEmptyMethods" type="boolean"> <description>Allow empty method bodies.</description> </property> <property default-value="false" name="allowEmptySwitchBlockStatements" type="boolean"> <description>Allow empty switch blocks and block statements.</description> </property> <property default-value="false" name="allowEmptyTypes" type="boolean"> <description>Allow empty class, interface and enum bodies.</description> </property> <property default-value="true" name="ignoreEnhancedForColon" type="boolean"> <description>Ignore whitespace around colon in <a href="https://docs.oracle.com/javase/specs/jls/se11/html/jls-14.html#jls-14.14.2"> enhanced for</a> loop.</description> </property> <property default-value="ASSIGN,BAND,BAND_ASSIGN,BOR,BOR_ASSIGN,BSR,BSR_ASSIGN,BXOR,BXOR_ASSIGN,COLON,DIV,DIV_ASSIGN,DO_WHILE,EQUAL,GE,GT,LAMBDA,LAND,LCURLY,LE,LITERAL_CATCH,LITERAL_DO,LITERAL_ELSE,LITERAL_FINALLY,LITERAL_FOR,LITERAL_IF,LITERAL_RETURN,LITERAL_SWITCH,LITERAL_SYNCHRONIZED,LITERAL_TRY,LITERAL_WHILE,LOR,LT,MINUS,MINUS_ASSIGN,MOD,MOD_ASSIGN,NOT_EQUAL,PLUS,PLUS_ASSIGN,QUESTION,RCURLY,SL,SLIST,SL_ASSIGN,SR,SR_ASSIGN,STAR,STAR_ASSIGN,LITERAL_ASSERT,TYPE_EXTENSION_AND,LITERAL_WHEN" name="tokens" type="java.lang.String[]" validation-type="tokenSet"> <description>tokens to check</description> </property> </properties> <message-keys> <message-key key="ws.notFollowed"/> <message-key key="ws.notPreceded"/> </message-keys> </check> </module> </checkstyle-metadata>
© 2015 - 2025 Weber Informatics LLC | Privacy Policy