<?xml version="1.0"?>

<ruleset name="Basic"
    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>
The Basic ruleset contains a collection of good practices which should be followed.
  </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}/rules/java/basic.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>

    <rule name="OverrideBothEqualsAndHashcode"
          language="java"
          since="0.4"
          message="Ensure you override both equals() and hashCode()"
          class="net.sourceforge.pmd.lang.java.rule.basic.OverrideBothEqualsAndHashcodeRule"
          externalInfoUrl="${pmd.website.baseurl}/rules/java/basic.html#OverrideBothEqualsAndHashcode">
      <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.
      </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>

</ruleset>
