<?xml version="1.0"?>

<ruleset name="Sample"
    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="OverrideBothEqualsAndHashcode"
          language="java"
          since="0.4"
          message="Ensure you override both equals() and hashCode()"
          class="net.sourceforge.pmd.lang.java.rule.errorprone.OverrideBothEqualsAndHashcodeRule"
          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_sample.html#overridebothequalsandhashcode"
          minimumLanguageVersion="1.5">
      <description>
            Override both `public boolean Object.equals(Object other)`, and `public int Object.hashCode()`, or override neither.
            Even if you are inheriting a `hashCode()` from a parent class, consider implementing hashCode and explicitly
            delegating to your superclass.

            Second paragraph.

                Code sample

            Third paragraph.
      </description>
      <priority>3</priority>
      <example>
  <![CDATA[
public class Bar {      // poor, missing a hashcode() method
    public boolean equals(Object o) {
      // do some comparison
    }
}

public class Baz {      // poor, missing an equals() method
    public int hashCode() {
      // return some hash value
    }
}

public class Foo {      // perfect, both methods provided
    public boolean equals(Object other) {
      // do some comparison
    }
    public int hashCode() {
      // return some hash value
    }
}
 ]]>
      </example>
    </rule>

    <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>
         <property name="sampleAdditionalProperty" type="String" description="This is a additional property for tests" value="the value" />
         <property name="sampleDeprecatedProperty" type="String" description="Deprecated! This is a sample deprecated property for tests" value="test" />
     </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>

<rule name="DeprecatedSample"
      language="java"
      since="1.0"
      message="Sample rule, which is deprecated"
      class="net.sourceforge.pmd.lang.rule.XPathRule"
      externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_sample.html#deprecatedsample"
      deprecated="true">
 <description>
Just some description of a deprecated rule.
 </description>
 <priority>3</priority>
 <properties>
     <property name="xpath">
         <value>
<![CDATA[
//ForStatement
]]>
         </value>
     </property>
 </properties>
 </rule>

<rule name="RenamedRule" ref="JumbledIncrementer"/>

<rule name="MovedRule" ref="rulesets/ruledoctest/sample2.xml/JumbledIncrementer"/>

</ruleset>
