<?xml version="1.0" encoding="UTF-8"?>

<document xmlns="http://maven.apache.org/XDOC/2.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">

  <head>
    <title>Block Checks</title>
    <script type="text/javascript"
            src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"/>
    <script type="text/javascript" src="js/anchors.js"/>
    <script type="text/javascript" src="js/google-analytics.js"/>
    <link rel="icon" href="images/favicon.png" type="image/x-icon" />
    <link rel="shortcut icon" href="images/favicon.ico" type="image/ico" />
  </head>

  <body>
    <section name="Content">
      <macro name="toc">
        <param name="fromDepth" value="1"/>
        <param name="toDepth" value="1"/>
      </macro>
    </section>

    <section name="AvoidNestedBlocks">
      <p>Since Checkstyle 3.1</p>
      <subsection name="Description" id="AvoidNestedBlocks_Description">
        <p>
          Finds nested blocks (blocks that are used freely in the code).
        </p>

        <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>
        <source>
public void guessTheOutput()
{
  int whichIsWhich = 0;
  {
    whichIsWhich = 2;
  }
  System.out.println("value = " + whichIsWhich);
}
        </source>

        <p> and debugging / refactoring leftovers such as </p>
        <source>
// if (conditionThatIsNotUsedAnyLonger)
{
  System.out.println("unconditional");
}
        </source>

        <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>
        <source>
switch (a)
{
  case 0:
    // Never OK, break outside block
    {
      x = 1;
    }
    break;
  case 1:
    // Never OK, statement outside block
    System.out.println("Hello");
    {
      x = 2;
      break;
    }
  case 2:
    // OK if allowInSwitchCase is true
    {
      System.out.println("Hello");
      x = 3;
      break;
    }
}
        </source>
      </subsection>

      <subsection name="Properties" id="AvoidNestedBlocks_Properties">
        <div class="wrapper">
          <table>
            <tr>
              <th>name</th>
              <th>description</th>
              <th>type</th>
              <th>default value</th>
              <th>since</th>
            </tr>
            <tr>
              <td>allowInSwitchCase</td>
              <td>Allow nested blocks if they are the only child of a switch case.</td>
              <td><a href="property_types.html#boolean">Boolean</a></td>
              <td><code>false</code></td>
              <td>3.2</td>
            </tr>
          </table>
        </div>
      </subsection>

      <subsection name="Examples" id="AvoidNestedBlocks_Examples">
        <p> To configure the check: </p>
        <source>
&lt;module name=&quot;AvoidNestedBlocks&quot;/&gt;
        </source>
      </subsection>

      <subsection name="Example of Usage" id="AvoidNestedBlocks_Example_of_Usage">
        <ul>
          <li>
            <a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources+filename%3Asun_checks.xml+repo%3Acheckstyle%2Fcheckstyle+AvoidNestedBlocks">
            Sun Style</a>
          </li>
          <li>
            <a href="https://github.com/search?q=path%3Aconfig+filename%3Acheckstyle_checks.xml+repo%3Acheckstyle%2Fcheckstyle+AvoidNestedBlocks">
            Checkstyle Style</a>
          </li>
        </ul>
      </subsection>

      <subsection name="Violation Messages" id="AvoidNestedBlocks_Violation_Messages">
        <ul>
          <li>
            <a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%2Fcom%2Fpuppycrawl%2Ftools%2Fcheckstyle%2Fchecks%2Fblocks+filename%3Amessages*.properties+repo%3Acheckstyle%2Fcheckstyle+%22block.nested%22">
            block.nested</a>
          </li>
        </ul>
        <p>
          All messages can be customized if the default message doesn't suit you.
          Please <a href="config.html#Custom_messages">see the documentation</a> to learn how to.
        </p>
      </subsection>

      <subsection name="Package" id="AvoidNestedBlocks_Package">
        <p> com.puppycrawl.tools.checkstyle.checks.blocks </p>
      </subsection>

      <subsection name="Parent Module" id="AvoidNestedBlocks_Parent_Module">
        <p> <a href="config.html#TreeWalker">TreeWalker</a> </p>
      </subsection>
    </section>

    <section name="EmptyBlock">
      <p>Since Checkstyle 3.0</p>
      <subsection name="Description" id="EmptyBlock_Description">
        <p> Checks for empty blocks. This check does not validate sequential blocks. </p>

        <p> Sequential blocks won't be checked. Also, no violations for fallthrough: </p>
        <source>
switch (a) {
  case 1:                          // no violation
  case 2:                          // no violation
  case 3: someMethod(); { }        // no violation
  default: break;
}
        </source>

        <p>
          This check processes LITERAL_CASE and LITERAL_DEFAULT separately.
          So, if tokens=LITERAL_DEFAULT, following code will not trigger any violation,
          as the empty block belongs to LITERAL_CASE:
        </p>
        <p> Configuration: </p>
        <source>
&lt;module name=&quot;EmptyBlock&quot;&gt;
  &lt;property name=&quot;tokens&quot; value=&quot;LITERAL_DEFAULT&quot;/&gt;
&lt;/module&gt;
        </source>
        <p> Result: </p>
        <source>
switch (a) {
  default:        // no violation for "default:" as empty block belong to "case 1:"
  case 1: { }
}
        </source>
      </subsection>

      <subsection name="Properties" id="EmptyBlock_Properties">
        <div class="wrapper">
          <table>
            <tr>
              <th>name</th>
              <th>description</th>
              <th>type</th>
              <th>default value</th>
              <th>since</th>
            </tr>
            <tr>
              <td>option</td>
              <td>specify the policy on block contents.</td>
              <td><a href="property_types.html#block">Block Policy</a></td>
              <td><code>statement</code></td>
              <td>3.0</td>
            </tr>
            <tr>
              <td>tokens</td>
              <td>tokens to check</td>
              <td>
                subset of tokens
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_WHILE">
                  LITERAL_WHILE</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_TRY">
                  LITERAL_TRY</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_CATCH">
                  LITERAL_CATCH</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_FINALLY">
                  LITERAL_FINALLY</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_DO">
                  LITERAL_DO</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_IF">
                  LITERAL_IF</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_ELSE">
                  LITERAL_ELSE</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_FOR">
                  LITERAL_FOR</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#INSTANCE_INIT">
                  INSTANCE_INIT</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#STATIC_INIT">
                  STATIC_INIT</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_SWITCH">
                  LITERAL_SWITCH</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_SYNCHRONIZED">
                  LITERAL_SYNCHRONIZED</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_CASE">
                  LITERAL_CASE</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_DEFAULT">
                  LITERAL_DEFAULT</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#ARRAY_INIT">
                  ARRAY_INIT</a>.
              </td>
              <td>
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_WHILE">
                  LITERAL_WHILE</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_TRY">
                  LITERAL_TRY</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_FINALLY">
                  LITERAL_FINALLY</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_DO">
                  LITERAL_DO</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_IF">
                  LITERAL_IF</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_ELSE">
                  LITERAL_ELSE</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_FOR">
                  LITERAL_FOR</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#INSTANCE_INIT">
                  INSTANCE_INIT</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#STATIC_INIT">
                  STATIC_INIT</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_SWITCH">
                  LITERAL_SWITCH</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_SYNCHRONIZED">
                  LITERAL_SYNCHRONIZED</a>.
              </td>
              <td>3.0</td>
            </tr>
          </table>
        </div>
      </subsection>

      <subsection name="Examples" id="EmptyBlock_Examples">
        <p> To configure the check: </p>
        <source>
&lt;module name=&quot;EmptyBlock&quot;/&gt;
        </source>

        <p>
          To configure the check for the <code>text</code>
          policy and only <code> try</code> blocks:
        </p>
        <source>
&lt;module name=&quot;EmptyBlock&quot;&gt;
  &lt;property name=&quot;option&quot; value=&quot;text&quot;/&gt;
  &lt;property name=&quot;tokens&quot; value=&quot;LITERAL_TRY&quot;/&gt;
&lt;/module&gt;
        </source>
      </subsection>

      <subsection name="Example of Usage" id="EmptyBlock_Example_of_Usage">
        <ul>
          <li>
            <a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources+filename%3Agoogle_checks.xml+repo%3Acheckstyle%2Fcheckstyle+EmptyBlock">
            Google Style</a>
          </li>
          <li>
            <a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources+filename%3Asun_checks.xml+repo%3Acheckstyle%2Fcheckstyle+EmptyBlock">
            Sun Style</a>
          </li>
          <li>
            <a href="https://github.com/search?q=path%3Aconfig+filename%3Acheckstyle_checks.xml+repo%3Acheckstyle%2Fcheckstyle+EmptyBlock">
            Checkstyle Style</a>
          </li>
        </ul>
      </subsection>

      <subsection name="Violation Messages" id="EmptyBlock_Violation_Messages">
        <ul>
          <li>
            <a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%2Fcom%2Fpuppycrawl%2Ftools%2Fcheckstyle%2Fchecks%2Fblocks+filename%3Amessages*.properties+repo%3Acheckstyle%2Fcheckstyle+%22block.empty%22">
            block.empty</a>
          </li>
          <li>
            <a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%2Fcom%2Fpuppycrawl%2Ftools%2Fcheckstyle%2Fchecks%2Fblocks+filename%3Amessages*.properties+repo%3Acheckstyle%2Fcheckstyle+%22block.noStatement%22">
            block.noStatement</a>
          </li>
        </ul>
        <p>
          All messages can be customized if the default message doesn't suit you.
          Please <a href="config.html#Custom_messages">see the documentation</a> to learn how to.
        </p>
      </subsection>

      <subsection name="Package" id="EmptyBlock_Package">
        <p> com.puppycrawl.tools.checkstyle.checks.blocks </p>
      </subsection>

      <subsection name="Parent Module" id="EmptyBlock_Parent_Module">
        <p> <a href="config.html#TreeWalker">TreeWalker</a> </p>
      </subsection>
    </section>

    <section name="EmptyCatchBlock">
      <p>Since Checkstyle 6.4</p>
      <subsection name="Description" id="EmptyCatchBlock_Description">
        <p>
          Checks for empty catch blocks.
          By default check allows empty catch block with any comment inside.
        </p>
      </subsection>

      <subsection name="Notes" id="EmptyCatchBlock_Notes">
        <p>
          There are two options to make validation more precise: <b>exceptionVariableName</b> and
          <b>commentFormat</b>.
          If both options are specified - they are applied by <b>any of them is matching</b>.
        </p>
      </subsection>

      <subsection name="Properties" id="EmptyCatchBlock_Properties">
        <div class="wrapper">
          <table>
            <tr>
              <th>name</th>
              <th>description</th>
              <th>type</th>
              <th>default value</th>
              <th>since</th>
            </tr>
            <tr>
              <td>exceptionVariableName</td>
              <td>
                Specify the RegExp for the name of the variable associated with exception.
                If check meets variable name matching specified value - empty block is suppressed.
              </td>
              <td><a href="property_types.html#regexp">Regular Expression</a></td>
              <td><code>&quot;^$&quot; (empty)</code></td>
              <td>6.4</td>
            </tr>
            <tr>
              <td>commentFormat</td>
              <td>
                Specify the RegExp for the first comment inside empty catch block.
                If check meets comment inside empty catch block matching specified format - empty
                block is suppressed. If it is multi-line comment - only its first line is analyzed.
              </td>
              <td><a href="property_types.html#regexp">Regular Expression</a></td>
              <td><code>&quot;.*&quot;</code></td>
              <td>6.4</td>
            </tr>
          </table>
        </div>
      </subsection>

      <subsection name="Examples" id="EmptyCatchBlock_Examples">
        <p>
          To configure the check to suppress empty catch block if exception's variable name is
           <code>expected</code> or <code>ignore</code> or there's any comment inside:
        </p>
        <source>
&lt;module name=&quot;EmptyCatchBlock&quot;&gt;
  &lt;property name=&quot;exceptionVariableName&quot; value=&quot;expected|ignore&quot;/&gt;
&lt;/module&gt;
        </source>
        <p>
          Such empty blocks would be both suppressed:
        </p>
        <source>
try {
  throw new RuntimeException();
} catch (RuntimeException expected) {
}
try {
  throw new RuntimeException();
} catch (RuntimeException ignore) {
}
        </source>
        <p>
          To configure the check to suppress empty catch block if single-line comment inside
           is &quot;//This is expected&quot;:
        </p>
        <source>
&lt;module name=&quot;EmptyCatchBlock&quot;&gt;
  &lt;property name=&quot;commentFormat&quot; value=&quot;This is expected&quot;/&gt;
&lt;/module&gt;
        </source>
        <p>
          Such empty block would be suppressed:
        </p>
        <source>
try {
  throw new RuntimeException();
} catch (RuntimeException ex) {
  //This is expected
}
        </source>
        <p>
          To configure the check to suppress empty catch block if single-line comment inside
          is &quot;//This is expected&quot; or exception's
          variable name is &quot;myException&quot; (any option is matching):
        </p>
        <source>
&lt;module name=&quot;EmptyCatchBlock&quot;&gt;
  &lt;property name=&quot;commentFormat&quot; value=&quot;This is expected&quot;/&gt;
  &lt;property name=&quot;exceptionVariableName&quot; value=&quot;myException&quot;/&gt;
&lt;/module&gt;
        </source>
        <p>
          Such empty blocks would be suppressed:
        </p>
        <source>
try {
  throw new RuntimeException();
} catch (RuntimeException e) {
  //This is expected
}
...
try {
  throw new RuntimeException();
} catch (RuntimeException e) {
  //   This is expected
}
...
try {
  throw new RuntimeException();
} catch (RuntimeException e) {
  // This is expected
  // some another comment
}
...
try {
  throw new RuntimeException();
} catch (RuntimeException e) {
  /* This is expected */
}
...
try {
  throw new RuntimeException();
} catch (RuntimeException e) {
  /*
  *
  * This is expected
  * some another comment
  */
}
...
try {
  throw new RuntimeException();
} catch (RuntimeException myException) {

}
        </source>
      </subsection>

      <subsection name="Example of Usage" id="EmptyCatchBlock_Example_of_Usage">
        <ul>
          <li>
            <a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources+filename%3Agoogle_checks.xml+repo%3Acheckstyle%2Fcheckstyle+EmptyCatchBlock">
            Google Style</a>
          </li>
          <li>
            <a href="https://github.com/search?q=path%3Aconfig+filename%3Acheckstyle_checks.xml+repo%3Acheckstyle%2Fcheckstyle+EmptyCatchBlock">
            Checkstyle Style</a>
          </li>
        </ul>
      </subsection>

      <subsection name="Violation Messages" id="EmptyCatchBlock_Violation_Messages">
        <ul>
          <li>
            <a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%2Fcom%2Fpuppycrawl%2Ftools%2Fcheckstyle%2Fchecks%2Fblocks+filename%3Amessages*.properties+repo%3Acheckstyle%2Fcheckstyle+%22catch.block.empty%22">
            catch.block.empty</a>
          </li>
        </ul>
        <p>
          All messages can be customized if the default message doesn't suit you.
          Please <a href="config.html#Custom_messages">see the documentation</a> to learn how to.
        </p>
      </subsection>

      <subsection name="Package" id="EmptyCatchBlock_Package">
        <p> com.puppycrawl.tools.checkstyle.checks.blocks </p>
      </subsection>

      <subsection name="Parent Module" id="EmptyCatchBlock_Parent_Module">
        <p> <a href="config.html#TreeWalker">TreeWalker</a> </p>
      </subsection>
    </section>

    <section name="LeftCurly">
      <p>Since Checkstyle 3.0</p>
      <subsection name="Description" id="LeftCurly_Description">
        <p>
          Checks for the placement of left curly braces
          (<code>'{'</code>) for code blocks.
        </p>
      </subsection>

      <subsection name="Properties" id="LeftCurly_Properties">
        <div class="wrapper">
          <table>
            <tr>
              <th>name</th>
              <th>description</th>
              <th>type</th>
              <th>default value</th>
              <th>since</th>
            </tr>
            <tr>
              <td>option</td>
              <td>Specify the policy on placement of a left curly brace (<code>'{'</code>).</td>
              <td><a href="property_types.html#lcurly">Left Curly Brace Policy</a></td>
              <td><code>eol</code></td>
              <td>3.0</td>
            </tr>
            <tr>
              <td>ignoreEnums</td>
              <td>Allow to ignore enums when left curly brace policy is EOL.</td>
              <td><a href="property_types.html#boolean">Boolean</a></td>
              <td><code>true</code></td>
              <td>6.9</td>
            </tr>
            <tr>
              <td>tokens</td>
              <td>tokens to check</td>
              <td>subset of tokens
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#ANNOTATION_DEF">
                  ANNOTATION_DEF</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#CLASS_DEF">
                  CLASS_DEF</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#CTOR_DEF">
                  CTOR_DEF</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#ENUM_CONSTANT_DEF">
                  ENUM_CONSTANT_DEF</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#ENUM_DEF">
                  ENUM_DEF</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#INTERFACE_DEF">
                  INTERFACE_DEF</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LAMBDA">
                  LAMBDA</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_CASE">
                  LITERAL_CASE</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_CATCH">
                  LITERAL_CATCH</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_DEFAULT">
                  LITERAL_DEFAULT</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_DO">
                  LITERAL_DO</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_ELSE">
                  LITERAL_ELSE</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_FINALLY">
                  LITERAL_FINALLY</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_FOR">
                  LITERAL_FOR</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_IF">
                  LITERAL_IF</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_SWITCH">
                  LITERAL_SWITCH</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_SYNCHRONIZED">
                  LITERAL_SYNCHRONIZED</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_TRY">
                  LITERAL_TRY</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_WHILE">
                  LITERAL_WHILE</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#METHOD_DEF">
                  METHOD_DEF</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#OBJBLOCK">
                  OBJBLOCK</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#STATIC_INIT">
                  STATIC_INIT</a>.
              </td>

              <td>
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#ANNOTATION_DEF">
                  ANNOTATION_DEF</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#CLASS_DEF">
                  CLASS_DEF</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#CTOR_DEF">
                  CTOR_DEF</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#ENUM_CONSTANT_DEF">
                  ENUM_CONSTANT_DEF</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#ENUM_DEF">
                  ENUM_DEF</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#INTERFACE_DEF">
                  INTERFACE_DEF</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LAMBDA">
                  LAMBDA</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_CASE">
                  LITERAL_CASE</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_CATCH">
                  LITERAL_CATCH</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_DEFAULT">
                  LITERAL_DEFAULT</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_DO">
                  LITERAL_DO</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_ELSE">
                  LITERAL_ELSE</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_FINALLY">
                  LITERAL_FINALLY</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_FOR">
                  LITERAL_FOR</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_IF">
                  LITERAL_IF</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_SWITCH">
                  LITERAL_SWITCH</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_SYNCHRONIZED">
                  LITERAL_SYNCHRONIZED</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_TRY">
                  LITERAL_TRY</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_WHILE">
                  LITERAL_WHILE</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#METHOD_DEF">
                  METHOD_DEF</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#OBJBLOCK">
                  OBJBLOCK</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#STATIC_INIT">
                  STATIC_INIT</a>.
              </td>
              <td>3.0</td>
            </tr>
          </table>
        </div>
      </subsection>

      <subsection name="Examples" id="LeftCurly_Examples">
        <p> To configure the check: </p>
        <source>
&lt;module name=&quot;LeftCurly&quot;/&gt;
        </source>
        <p>
          To configure the check to apply the <code>nl</code> policy to
          type blocks:
        </p>
        <source>
&lt;module name=&quot;LeftCurly&quot;&gt;
  &lt;property name=&quot;option&quot; value=&quot;nl&quot;/&gt;
  &lt;property name=&quot;tokens&quot; value=&quot;CLASS_DEF,INTERFACE_DEF&quot;/&gt;
&lt;/module&gt;
        </source>
        <p>
          An example of how to configure the check to validate enum definitions:
        </p>
        <source>
&lt;module name="LeftCurly"&gt;
  &lt;property name="ignoreEnums" value="false"/&gt;
&lt;/module&gt;
        </source>
      </subsection>

      <subsection name="Example of Usage" id="LeftCurly_Example_of_Usage">
        <ul>
          <li>
            <a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources+filename%3Agoogle_checks.xml+repo%3Acheckstyle%2Fcheckstyle+LeftCurly">
            Google Style</a>
          </li>
          <li>
            <a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources+filename%3Asun_checks.xml+repo%3Acheckstyle%2Fcheckstyle+LeftCurly">
            Sun Style</a>
          </li>
          <li>
            <a href="https://github.com/search?q=path%3Aconfig+filename%3Acheckstyle_checks.xml+repo%3Acheckstyle%2Fcheckstyle+LeftCurly">
            Checkstyle Style</a>
          </li>
        </ul>
      </subsection>

      <subsection name="Violation Messages" id="LeftCurly_Violation_Messages">
        <ul>
          <li>
            <a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%2Fcom%2Fpuppycrawl%2Ftools%2Fcheckstyle%2Fchecks%2Fblocks+filename%3Amessages*.properties+repo%3Acheckstyle%2Fcheckstyle+%22line.break.after%22">
            line.break.after</a>
          </li>
          <li>
            <a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%2Fcom%2Fpuppycrawl%2Ftools%2Fcheckstyle%2Fchecks%2Fblocks+filename%3Amessages*.properties+repo%3Acheckstyle%2Fcheckstyle+%22line.new%22">
            line.new</a>
          </li>
          <li>
            <a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%2Fcom%2Fpuppycrawl%2Ftools%2Fcheckstyle%2Fchecks%2Fblocks+filename%3Amessages*.properties+repo%3Acheckstyle%2Fcheckstyle+%22line.previous%22">
            line.previous</a>
          </li>
        </ul>
        <p>
          All messages can be customized if the default message doesn't suit you.
          Please <a href="config.html#Custom_messages">see the documentation</a> to learn how to.
        </p>
      </subsection>

      <subsection name="Package" id="LeftCurly_Package">
        <p> com.puppycrawl.tools.checkstyle.checks.blocks </p>
      </subsection>

      <subsection name="Parent Module" id="LeftCurly_Parent_Module">
        <p> <a href="config.html#TreeWalker">TreeWalker</a> </p>
      </subsection>
    </section>

    <section name="NeedBraces">
      <p>Since Checkstyle 3.0</p>
      <subsection name="Description" id="NeedBraces_Description">
        <p> Checks for braces around code blocks. </p>
      </subsection>

      <subsection name="Properties" id="NeedBraces_Properties">
        <div class="wrapper">
          <table>
            <tr>
              <th>name</th>
              <th>description</th>
              <th>type</th>
              <th>default value</th>
              <th>since</th>
            </tr>
            <tr>
              <td>allowSingleLineStatement</td>
              <td>allow single-line statements without braces.</td>
              <td><a href="property_types.html#boolean">Boolean</a></td>
              <td><code>false</code></td>
              <td>6.5</td>
            </tr>
            <tr>
              <td>allowEmptyLoopBody</td>
              <td>allow loops with empty bodies.</td>
              <td><a href="property_types.html#boolean">Boolean</a></td>
              <td><code>false</code></td>
              <td>6.12.1</td>
            </tr>
            <tr>
              <td>tokens</td>
              <td>tokens to check</td>
              <td>subset of tokens
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_DO">
                  LITERAL_DO</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_ELSE">
                  LITERAL_ELSE</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_FOR">
                  LITERAL_FOR</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_IF">
                  LITERAL_IF</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_WHILE">
                  LITERAL_WHILE</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_CASE">
                  LITERAL_CASE</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_DEFAULT">
                  LITERAL_DEFAULT</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LAMBDA">
                  LAMBDA</a>.
              </td>

              <td>
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_DO">
                  LITERAL_DO</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_ELSE">
                  LITERAL_ELSE</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_FOR">
                  LITERAL_FOR</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_IF">
                  LITERAL_IF</a>,
                <a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_WHILE">
                  LITERAL_WHILE</a>.
              </td>
              <td>3.0</td>
            </tr>
          </table>
        </div>
      </subsection>

      <subsection name="Examples" id="NeedBraces_Examples">
        <p> To configure the check: </p>
        <source>
&lt;module name=&quot;NeedBraces&quot;/&gt;
        </source>

        <p>
          To configure the check for <code>if</code> and
          <code> else</code> blocks:
        </p>
        <source>
&lt;module name=&quot;NeedBraces&quot;&gt;
  &lt;property name=&quot;tokens&quot; value=&quot;LITERAL_IF, LITERAL_ELSE&quot;/&gt;
&lt;/module&gt;
        </source>

        <p>
          To configure the check to allow single-line statements
          (<code>if, while, do-while, for</code>) without braces:
        </p>
        <source>
&lt;module name=&quot;NeedBraces&quot;&gt;
  &lt;property name=&quot;allowSingleLineStatement&quot; value=&quot;true&quot;/&gt;
&lt;/module&gt;
        </source>

        <p>
          Next statements won't be violated by check:
        </p>
        <source>
if (obj.isValid()) return true; // OK
while (obj.isValid()) return true; // OK
do this.notify(); while (o != null); // OK
for (int i = 0; ; ) this.notify(); // OK
        </source>

        <p>
          To configure the check to allow <code>case, default</code> single-line statements
          without braces:
        </p>
        <source>
&lt;module name=&quot;NeedBraces&quot;&gt;
  &lt;property name=&quot;tokens&quot; value=&quot;LITERAL_CASE, LITERAL_DEFAULT&quot;/&gt;
  &lt;property name=&quot;allowSingleLineStatement&quot; value=&quot;true&quot;/&gt;
&lt;/module&gt;
        </source>

        <p>
          Next statements won't be violated by check:
        </p>
        <source>
switch (num) {
  case 1: counter++; break; // OK
  case 6: counter += 10; break; // OK
  default: counter = 100; break; // OK
}
        </source>
        <p>
          To configure the check to allow loops (<code>while, for</code>) with empty bodies:
        </p>
        <source>
&lt;module name=&quot;NeedBraces&quot;&gt;
  &lt;property name=&quot;allowEmptyLoopBody&quot; value=&quot;true&quot;/&gt;
&lt;/module&gt;
        </source>

        <p>
            Next statements won't be violated by check:
        </p>
        <source>
while (value.incrementValue() &lt; 5); // OK
for(int i = 0; i &lt; 10; value.incrementValue()); // OK
        </source>
        <p>
          To configure the check to lambdas:
        </p>
        <div class="wrapper">
          <pre>
&lt;module name=&quot;NeedBraces&quot;&gt;
  &lt;property name=&quot;tokens&quot; value=&quot;LAMBDA&quot;/&gt;
  &lt;property name=&quot;allowSingleLineStatement&quot; value=&quot;true&quot;/&gt;
&lt;/module&gt;
          </pre>
        </div>
        <p>
          Results in following:
        </p>
        <div class="wrapper">
          <pre>
allowedFuture.addCallback(result -> assertEquals("Invalid response",
  EnumSet.of(HttpMethod.GET, HttpMethod.OPTIONS), result), // violation, lambda spans 2 lines
  ex -> fail(ex.getMessage())); // OK

allowedFuture.addCallback(result -> {
  return assertEquals("Invalid response",
    EnumSet.of(HttpMethod.GET, HttpMethod.OPTIONS), result);
  }, // OK
  ex -> fail(ex.getMessage()));
          </pre>
        </div>
      </subsection>

      <subsection name="Example of Usage" id="NeedBraces_Example_of_Usage">
        <ul>
          <li>
            <a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources+filename%3Agoogle_checks.xml+repo%3Acheckstyle%2Fcheckstyle+NeedBraces">
            Google Style</a>
          </li>
          <li>
            <a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources+filename%3Asun_checks.xml+repo%3Acheckstyle%2Fcheckstyle+NeedBraces">
            Sun Style</a>
          </li>
          <li>
            <a href="https://github.com/search?q=path%3Aconfig+filename%3Acheckstyle_checks.xml+repo%3Acheckstyle%2Fcheckstyle+NeedBraces">
            Checkstyle Style</a>
          </li>
        </ul>
      </subsection>

      <subsection name="Violation Messages" id="NeedBraces_Violation_Messages">
        <ul>
          <li>
            <a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%2Fcom%2Fpuppycrawl%2Ftools%2Fcheckstyle%2Fchecks%2Fblocks+filename%3Amessages*.properties+repo%3Acheckstyle%2Fcheckstyle+%22needBraces%22">
            needBraces</a>
          </li>
        </ul>
        <p>
          All messages can be customized if the default message doesn't suit you.
          Please <a href="config.html#Custom_messages">see the documentation</a> to learn how to.
        </p>
      </subsection>

      <subsection name="Package" id="NeedBraces_Package">
        <p> com.puppycrawl.tools.checkstyle.checks.blocks </p>
      </subsection>

      <subsection name="Parent Module" id="NeedBraces_Parent_Module">
        <p> <a href="config.html#TreeWalker">TreeWalker</a> </p>
      </subsection>
    </section>

    <section name="RightCurly">
      <p>Since Checkstyle 3.0</p>
      <subsection name="Description" id="RightCurly_Description">
        <p>
          Checks the placement of right curly braces (<code>'}'</code>) for code blocks.
          This check supports if-else, try-catch-finally blocks, while-loops, for-loops,
          method definitions, class definitions, constructor definitions,
          instance, static initialization blocks, annotation definitions and enum definitions.
          For right curly brace of expression blocks please follow issue
          <a href="https://github.com/checkstyle/checkstyle/issues/5945">#5945</a>.
        </p>
      </subsection>

      <subsection name="Properties" id="RightCurly_Properties">
        <div class="wrapper">
          <table>
            <tr>
              <th>name</th>
              <th>description</th>
              <th>type</th>
              <th>default value</th>
              <th>since</th>
            </tr>
            <tr>
              <td>option</td>
              <td>Specify the policy on placement of a right curly brace (<code>'}'</code>).</td>
              <td><a href="property_types.html#rcurly">Right Curly Brace Policy</a></td>
              <td><code>same</code></td>
              <td>3.0</td>
            </tr>
            <tr>
              <td>tokens</td>
              <td>tokens to check</td>
              <td>subset of tokens <a
               href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_TRY">
                  LITERAL_TRY</a>,
              <a
               href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_CATCH">
                  LITERAL_CATCH</a>,
              <a
               href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_FINALLY">
                  LITERAL_FINALLY</a>,
              <a
               href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_IF">
                  LITERAL_IF</a>,
              <a
               href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_ELSE">
                  LITERAL_ELSE</a>,
              <a
               href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#CLASS_DEF">
                  CLASS_DEF</a>,
              <a
               href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#METHOD_DEF">
                  METHOD_DEF</a>,
              <a
               href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#CTOR_DEF">
                  CTOR_DEF</a>,
               <a
               href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_FOR">
                  LITERAL_FOR</a>,
              <a
               href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_WHILE">
                  LITERAL_WHILE</a>,
              <a
               href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_DO">
                  LITERAL_DO</a>,
              <a
               href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#STATIC_INIT">
                  STATIC_INIT</a>,
              <a
               href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#INSTANCE_INIT">
                  INSTANCE_INIT</a>,
              <a
               href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#ANNOTATION_DEF">
                  ANNOTATION_DEF</a>,
              <a
               href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#ENUM_DEF">
                  ENUM_DEF</a>.</td>
              <td><a
               href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_TRY">
                  LITERAL_TRY</a>,
              <a
               href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_CATCH">
                  LITERAL_CATCH</a>,
              <a
               href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_FINALLY">
                  LITERAL_FINALLY</a>,
              <a
               href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_IF">
                  LITERAL_IF</a>,
              <a
               href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#LITERAL_ELSE">
                  LITERAL_ELSE</a>.</td>
              <td>3.0</td>
            </tr>
          </table>
        </div>
      </subsection>

      <subsection name="Examples" id="RightCurly_Examples">
        <p> To configure the check: </p>
        <source>
&lt;module name=&quot;RightCurly&quot;/&gt;
        </source>

        <p>
          To configure the check with policy <code>alone</code> for <code> else</code> and <a
             href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#METHOD_DEF">
          METHOD_DEF</a>
          tokens:
        </p>
        <source>
&lt;module name=&quot;RightCurly&quot;&gt;
  &lt;property name=&quot;option&quot; value=&quot;alone&quot;/&gt;
  &lt;property name=&quot;tokens&quot; value=&quot;LITERAL_ELSE, METHOD_DEF&quot;/&gt;
&lt;/module&gt;
        </source>
      </subsection>

      <subsection name="Example of Usage" id="RightCurly_Example_of_Usage">
        <ul>
          <li>
            <a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources+filename%3Agoogle_checks.xml+repo%3Acheckstyle%2Fcheckstyle+RightCurly">
            Google Style</a>
          </li>
          <li>
            <a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources+filename%3Asun_checks.xml+repo%3Acheckstyle%2Fcheckstyle+RightCurly">
            Sun Style</a>
          </li>
          <li>
            <a href="https://github.com/search?q=path%3Aconfig+filename%3Acheckstyle_checks.xml+repo%3Acheckstyle%2Fcheckstyle+RightCurly">
            Checkstyle Style</a>
          </li>
        </ul>
      </subsection>

      <subsection name="Violation Messages" id="RightCurly_Violation_Messages">
        <ul>
          <li>
            <a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%2Fcom%2Fpuppycrawl%2Ftools%2Fcheckstyle%2Fchecks%2Fblocks+filename%3Amessages*.properties+repo%3Acheckstyle%2Fcheckstyle+%22line.alone%22">
            line.alone</a>
          </li>
          <li>
            <a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%2Fcom%2Fpuppycrawl%2Ftools%2Fcheckstyle%2Fchecks%2Fblocks+filename%3Amessages*.properties+repo%3Acheckstyle%2Fcheckstyle+%22line.break.before%22">
            line.break.before</a>
          </li>
          <li>
            <a href="https://github.com/search?q=path%3Asrc%2Fmain%2Fresources%2Fcom%2Fpuppycrawl%2Ftools%2Fcheckstyle%2Fchecks%2Fblocks+filename%3Amessages*.properties+repo%3Acheckstyle%2Fcheckstyle+%22line.same%22">
            line.same</a>
          </li>
        </ul>
        <p>
          All messages can be customized if the default message doesn't suit you.
          Please <a href="config.html#Custom_messages">see the documentation</a> to learn how to.
        </p>
      </subsection>

      <subsection name="Package" id="RightCurly_Package">
        <p> com.puppycrawl.tools.checkstyle.checks.blocks </p>
      </subsection>

      <subsection name="Parent Module" id="RightCurly_Parent_Module">
        <p> <a href="config.html#TreeWalker">TreeWalker</a> </p>
      </subsection>
    </section>
  </body>
</document>
