<?xml version="1.0"?>

<ruleset name="Braces Rules" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="../etc/ruleset_xml_schema.xml">
  <description>
The Braces Ruleset contains a collection of braces rules.
  </description>

<!-- jmv

   <rule name="IfStmtsMustUseBraces"
         message="Avoid using if statements without curly braces"
         class="net.sourceforge.pmd.rules.XPathRule"
          externalInfoUrl="http://pmd.sourceforge.net/rules/braces.html#IfStmtsMustUseBraces">
     <description>
Avoid using if statements without using curly braces
     </description>
       <properties>
           <property name="xpath">
               <value>
                   <![CDATA[
//IfStatement[count(*) < 3][not(Statement/Block)]
                   ]]>
               </value>
           </property>
       </properties>
       <priority>3</priority>

     <example>
 <![CDATA[
 public class Foo {
   public void bar() {
     int x = 0;
     if (foo) x++;
   }
 }
 ]]>
     </example>
     </rule>
-->

    <rule name="WhileLoopsMustUseBraces"
          message="Avoid using 'while' statements without curly braces"
          class="net.sourceforge.pmd.rules.XPathRule"
          externalInfoUrl="http://pmd.sourceforge.net/rules/braces.html#WhileLoopsMustUseBraces">
      <description>
Avoid using 'while' statements without using curly braces
      </description>
        <properties>
            <property name="xpath">
                <value>
<![CDATA[
//WhileStatement[not(Statement/Block)]
]]>
                </value>
            </property>
        </properties>
        <priority>3</priority>

      <example>
<![CDATA[
public void doSomething() {
  while (true)
      x++;
}
]]>
      </example>
    </rule>

<!-- jmv
      <rule name="IfElseStmtsMustUseBraces"
           message="Avoid using 'if...else' statements without curly braces"
           class="net.sourceforge.pmd.rules.XPathRule"
          externalInfoUrl="http://pmd.sourceforge.net/rules/braces.html#IfElseStmtsMustUseBraces">
       <description>
Avoid using if..else statements without using curly braces
       </description>
         <properties>
             <property name="xpath">
                 <value>
<![CDATA[
//Statement
 [parent::IfStatement[@Else='true']]
 [not(child::Block)]
 [not(child::IfStatement)]
 ]]>
                 </value>
             </property>
         </properties>
         <priority>3</priority>

       <example>
<![CDATA[
 public void doSomething() {
   // this is OK
   if (foo) x++;
   // but this is not
   if (foo)
       x=x+1;
   else
       x=x-1;
 }
]]>
       </example>
     </rule>
-->

     <rule name="ForLoopsMustUseBraces"
           message="Avoid using 'for' statements without curly braces"
           class="net.sourceforge.pmd.rules.XPathRule"
          externalInfoUrl="http://pmd.sourceforge.net/rules/braces.html#ForLoopsMustUseBraces">
       <description>
Avoid using 'for' statements without using curly braces
       </description>
         <properties>
             <property name="xpath">
                 <value>
 <![CDATA[
//ForStatement[not(Statement/Block)]
 ]]>
                 </value>
             </property>
         </properties>
         <priority>3</priority>

       <example>
<![CDATA[
public void foo() {
 for (int i=0; i<42;i++)
   foo();
}
]]>
       </example>
     </rule>

</ruleset>
