com.puppycrawl.tools.checkstyle.meta.checks.blocks.AvoidNestedBlocksCheck.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
The newest version!
<?xml version="1.0" encoding="UTF-8"?> <checkstyle-metadata> <module> <check fully-qualified-name="com.puppycrawl.tools.checkstyle.checks.blocks.AvoidNestedBlocksCheck" name="AvoidNestedBlocks" parent="com.puppycrawl.tools.checkstyle.TreeWalker"> <description><div> Finds nested blocks (blocks that are used freely in the code). </div> <p> Rationale: Nested blocks are often leftovers from the debugging process, they confuse the reader. </p> <p> For example, this check finds the obsolete braces in </p> <pre> public void guessTheOutput() { int whichIsWhich = 0; { whichIsWhich = 2; } System.out.println("value = " + whichIsWhich); } </pre> <p> and debugging / refactoring leftovers such as </p> <pre> // if (conditionThatIsNotUsedAnyLonger) { System.out.println("unconditional"); } </pre> <p> A case in a switch statement does not implicitly form a block. Thus, to be able to introduce local variables that have case scope it is necessary to open a nested block. This is supported, set the allowInSwitchCase property to true and include all statements of the case in the block. </p></description> <properties> <property default-value="false" name="allowInSwitchCase" type="boolean"> <description>Allow nested blocks if they are the only child of a switch case.</description> </property> </properties> <message-keys> <message-key key="block.nested"/> </message-keys> </check> </module> </checkstyle-metadata>
© 2015 - 2025 Weber Informatics LLC | Privacy Policy