---
title: Java Rules
tags: [rule_references, java]
summary: Index of all built-in rules available for Java
language_name: Java
permalink: pmd_rules_java.html
folder: pmd/rules
editmepath: false
---
<!-- DO NOT EDIT THIS FILE. This file is generated. -->
## Sample

{% include callout.html content="Sample ruleset to test rule doc generation.  Here might be &lt;script&gt;alert('XSS');&lt;/script&gt; as well. And &quot;quotes&quot;.  Inside CDATA &lt;script&gt;alert('XSS');&lt;/script&gt;." %}

*   [DeprecatedSample](pmd_rules_java_sample.html#deprecatedsample): <span style="border-radius: 0.25em; color: #fff; padding: 0.2em 0.6em 0.3em; display: inline; background-color: #d9534f; font-size: 75%;">Deprecated</span> Just some description of a deprecated rule. RuleTag with quotes: Use {% rule "RenamedRule" %} ins...
*   [JumbledIncrementer](pmd_rules_java_sample.html#jumbledincrementer): Avoid jumbled loop incrementers - its usually a mistake, and is confusing even if intentional.
*   [MovedRule](pmd_rules_java_sample.html#movedrule): <span style="border-radius: 0.25em; color: #fff; padding: 0.2em 0.6em 0.3em; display: inline; background-color: #d9534f; font-size: 75%;">Deprecated</span> The rule has been moved to another ruleset. Use instead [JumbledIncrementer](pmd_rules_java_sample2.html#jumbledincrementer).
*   [OverrideBothEqualsAndHashcode](pmd_rules_java_sample.html#overridebothequalsandhashcode): Override both 'public boolean Object.equals(Object other)', and 'public int Object.hashCode()', o...
*   [RenamedRule1](pmd_rules_java_sample.html#renamedrule1): <span style="border-radius: 0.25em; color: #fff; padding: 0.2em 0.6em 0.3em; display: inline; background-color: #d9534f; font-size: 75%;">Deprecated</span> The rule has been renamed. Use instead [JumbledIncrementer](pmd_rules_java_sample.html#jumbledincrementer).
*   [RenamedRule2](pmd_rules_java_sample.html#renamedrule2): <span style="border-radius: 0.25em; color: #fff; padding: 0.2em 0.6em 0.3em; display: inline; background-color: #d9534f; font-size: 75%;">Deprecated</span> The rule has been renamed. Use instead [JumbledIncrementer](pmd_rules_java_sample.html#jumbledincrementer).
*   [RenamedRule3](pmd_rules_java_sample.html#renamedrule3): <span style="border-radius: 0.25em; color: #fff; padding: 0.2em 0.6em 0.3em; display: inline; background-color: #d9534f; font-size: 75%;">Deprecated</span> The rule has been renamed. Use instead [JumbledIncrementer](pmd_rules_java_sample.html#jumbledincrementer).
*   [RenamedRule4](pmd_rules_java_sample.html#renamedrule4): <span style="border-radius: 0.25em; color: #fff; padding: 0.2em 0.6em 0.3em; display: inline; background-color: #d9534f; font-size: 75%;">Deprecated</span> The rule has been renamed. Use instead [JumbledIncrementer](pmd_rules_java_sample.html#jumbledincrementer).
*   [XSSInDocumentation](pmd_rules_java_sample.html#xssindocumentation): &lt;script&gt;alert('XSS at the beginning');&lt;/script&gt; HTML tags might appear at various places.        ...

## Additional rulesets

*   Other ruleset (`rulesets/ruledoctest/other-ruleset.xml`):

    Ruleset which serves a specific use case, such as Getting Started.

    It contains the following rules:

    [JumbledIncrementer](pmd_rules_java_sample.html#jumbledincrementer), [OverrideBothEqualsAndHashcode](pmd_rules_java_sample.html#overridebothequalsandhashcode)

*   Sample Deprecated (`rulesets/ruledoctest/sample-deprecated.xml`):

    <span style="border-radius: 0.25em; color: #fff; padding: 0.2em 0.6em 0.3em; display: inline; background-color: #d9534f; font-size: 75%;">Deprecated</span>  This ruleset is for backwards compatibility.

    It contains the following rules:

    [JumbledIncrementer](pmd_rules_java_sample.html#jumbledincrementer), [OldNameOfJumbledIncrementer](pmd_rules_java_sample.html#jumbledincrementer), [OverrideBothEqualsAndHashcode](pmd_rules_java_sample.html#overridebothequalsandhashcode)

