title: Can the CheckStyle module "NeedBraces" work with nested if/else blocks?
body: <p>We are using <a href="http://checkstyle.sourceforge.net/index.html" rel="nofollow noreferrer">CheckStyle</a> to enforce our style standards.  One of the style rules we opted to include was the <em>NeedBraces</em> module.</p>
  
  <p><em><a href="http://checkstyle.sourceforge.net/config_blocks.html#NeedBraces" rel="nofollow noreferrer">NeedBraces</a></em> specifies that every block type statement (such as <code>if</code>, <code>else</code>, <code>for</code>) must have opening and closing curly braces.  However, as far as I can tell it isn't working entirely correctly.</p>
  
  <p>This example will trigger a CheckStyle error.</p>
  
  <pre><code>    if (true)
      {
          System.out.println("20");   
      }
      else
          System.out.println("30");
  </code></pre>
  
  <p>Because the else case doesn't have braces.  However, the next example fails to trigger a CheckStyle error.</p>
  
  <pre><code>    if (true)
      {
          System.out.println("20");   
      }
      else
          if (true)
          {
              System.out.println("30");
          }
  </code></pre>
  
  <p>This should have failed because of the missing braces on the else case, but checkstyle lets it pass.  After double checking the documentation, I can't find any reason why this isn't working right.  </p>
  
  <p>So... 
  <strong>Can the CheckStyle module "NeedBraces" work with nested if/else blocks?</strong>
  Any ideas?</p>
  
  <hr>
  
  <p>The answer to this question begs <a href="https://stackoverflow.com/questions/387008/is-there-a-checkstyle-rule-to-force-if-else-keywords-to-be-on-the-same-line-in">another question</a>: is there a rule to flag the above undesirable code as a violation?</p>