<?xml version="1.0"?>

<ruleset name="Sample2"
    xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd">
  <description>
Sample ruleset to test rule doc generation.
  </description>

    <rule name="JumbledIncrementer"
          language="java"
          since="1.0"
          message="Avoid modifying an outer loop incrementer in an inner loop for update expression"
          class="net.sourceforge.pmd.lang.rule.XPathRule"
          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_sample.html#jumbledincrementer">
     <description>
Avoid jumbled loop incrementers - its usually a mistake, and is confusing even if intentional.
     </description>
     <priority>3</priority>
     <properties>
         <property name="xpath">
             <value>
<![CDATA[
//ForStatement
  [
    ForUpdate/StatementExpressionList/StatementExpression/PostfixExpression/PrimaryExpression/PrimaryPrefix/Name/@Image
    =
    ancestor::ForStatement/ForInit//VariableDeclaratorId/@Image
  ]
]]>
             </value>
         </property>
     </properties>
     <example>
 <![CDATA[
public class JumbledIncrementerRule1 {
    public void foo() {
        for (int i = 0; i < 10; i++) {          // only references 'i'
            for (int k = 0; k < 20; i++) {      // references both 'i' and 'k'
                System.out.println("Hello");
            }
        }
    }
}
 ]]>
     </example>
     </rule>

</ruleset>
