You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2021/09/09 13:56:08 UTC

[GitHub] [ignite-3] alievmirza opened a new pull request #327: review pmd check rules

alievmirza opened a new pull request #327:
URL: https://github.com/apache/ignite-3/pull/327


   Let's select rules that we want to add to our `check-rules/pmd-rules.xml`. 
   I propose to review at least ruels with `<priority>1</priority>` and `<priority>2</priority>`


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] alievmirza commented on a change in pull request #327: review pmd check rules

Posted by GitBox <gi...@apache.org>.
alievmirza commented on a change in pull request #327:
URL: https://github.com/apache/ignite-3/pull/327#discussion_r705400378



##########
File path: check-rules/bestpractices.xml
##########
@@ -0,0 +1,2130 @@
+<?xml version="1.0"?>
+
+<ruleset name="Best Practices"
+         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 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">
+
+    <description>
+        Rules which enforce generally accepted best practices.
+    </description>
+
+    <rule name="AbstractClassWithoutAbstractMethod"
+          language="java"
+          since="3.0"
+          message="This abstract class does not have any abstract methods"
+          class="net.sourceforge.pmd.lang.java.rule.bestpractices.AbstractClassWithoutAbstractMethodRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#abstractclasswithoutabstractmethod">
+        <description>
+            The abstract class does not contain any abstract methods. An abstract class suggests
+            an incomplete implementation, which is to be completed by subclasses implementing the
+            abstract methods. If the class is intended to be used as a base class only (not to be instantiated
+            directly) a protected constructor can be provided prevent direct instantiation.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public abstract class Foo {
+  void int method1() { ... }
+  void int method2() { ... }
+  // consider using abstract methods or removing
+  // the abstract modifier and adding protected constructors
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AccessorClassGeneration"
+          language="java"
+          since="1.04"
+          maximumLanguageVersion="10"
+          message="Avoid instantiation through private constructors from outside of the constructor's class."
+          class="net.sourceforge.pmd.lang.java.rule.bestpractices.AccessorClassGenerationRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#accessorclassgeneration">
+        <description>
+            Instantiation by way of private constructors from outside of the constructor's class often causes the
+            generation of an accessor. A factory method, or non-privatization of the constructor can eliminate this
+            situation. The generated class file is actually an interface.  It gives the accessing class the ability
+            to invoke a new hidden package scope constructor that takes the interface as a supplementary parameter.
+            This turns a private constructor effectively into one with package scope, and is challenging to discern.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class Outer {
+ void method(){
+  Inner ic = new Inner();//Causes generation of accessor class
+ }
+ public class Inner {
+  private Inner(){}
+ }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AccessorMethodGeneration"
+          language="java"
+          since="5.5.4"
+          maximumLanguageVersion="10"
+          message="Avoid autogenerated methods to access private fields and methods of inner / outer classes"
+          class="net.sourceforge.pmd.lang.java.rule.bestpractices.AccessorMethodGenerationRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#accessormethodgeneration">
+        <description>
+            When accessing private fields / methods from another class, the Java compiler will generate accessor methods
+            with package-private visibility. This adds overhead, and to the dex method count on Android. This situation can
+            be avoided by changing the visibility of the field / method from private to package-private.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class OuterClass {
+    private int counter;
+    /* package */ int id;
+    public class InnerClass {
+        InnerClass() {
+            OuterClass.this.counter++; // wrong accessor method will be generated
+        }
+        public int getOuterClassId() {
+            return OuterClass.this.id; // id is package-private, no accessor method needed
+        }
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="ArrayIsStoredDirectly"
+          language="java"
+          since="2.2"
+          message="The user-supplied array ''{0}'' is stored directly."
+          class="net.sourceforge.pmd.lang.java.rule.bestpractices.ArrayIsStoredDirectlyRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#arrayisstoreddirectly">
+        <description>
+            Constructors and methods receiving arrays should clone objects and store the copy.
+            This prevents future changes from the user from affecting the original array.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class Foo {
+    private String [] x;
+        public void foo (String [] param) {
+        // Don't do this, make a copy of the array at least
+        this.x=param;
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidMessageDigestField"
+          language="java"
+          since="6.18.0"
+          message="You shouldn't declare field of MessageDigest type, because unsynchronized access could cause problems"
+          typeResolution="true"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#avoidmessagedigestfield">
+        <description>
+            Declaring a MessageDigest instance as a field make this instance directly available to multiple threads.
+            Such sharing of MessageDigest instances should be avoided if possible since it leads to wrong results
+            if the access is not synchronized correctly.
+            Just create a new instance and use it locally, where you need it.
+            Creating a new instance is easier than synchronizing access to a shared instance.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//FieldDeclaration[pmd-java:typeIs('java.security.MessageDigest')]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+import java.security.MessageDigest;
+public class AvoidMessageDigestFieldExample {
+    private final MessageDigest sharedMd;
+    public AvoidMessageDigestFieldExample() throws Exception {
+        sharedMd = MessageDigest.getInstance("SHA-256");
+    }
+    public byte[] calculateHashShared(byte[] data) {
+        // sharing a MessageDigest like this without synchronizing access
+        // might lead to wrong results
+        sharedMd.reset();
+        sharedMd.update(data);
+        return sharedMd.digest();
+    }
+    // better
+    public byte[] calculateHash(byte[] data) throws Exception {
+        MessageDigest md = MessageDigest.getInstance("SHA-256");
+        md.update(data);
+        return md.digest();
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidPrintStackTrace"
+          language="java"
+          since="3.2"
+          message="Avoid printStackTrace(); use a logger call instead."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#avoidprintstacktrace">
+        <description>
+            Avoid printStackTrace(); use a logger call instead.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//PrimaryExpression[
+   ( PrimaryPrefix[Name[contains(@Image,'printStackTrace')]]
+   | PrimarySuffix[@Image='printStackTrace']
+   )/following-sibling::*[1][self::PrimarySuffix/Arguments[@Size=0]]
+]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+class Foo {
+    void bar() {
+        try {
+            // do something
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidReassigningCatchVariables"
+          language="java"
+          since="6.27.0"
+          message="Avoid reassigning caught exception ''{0}''"
+          class="net.sourceforge.pmd.lang.java.rule.bestpractices.AvoidReassigningCatchVariablesRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#avoidreassigningcatchvariables">
+        <description>
+            Reassigning exception variables caught in a catch statement should be avoided because of:
+
+            1) If it is needed, multi catch can be easily added and code will still compile.
+
+            2) Following the principle of least surprise we want to make sure that a variable caught in a catch statement
+            is always the one thrown in a try block.
+        </description>
+        <priority>3</priority>
+        <example><![CDATA[
+public class Foo {
+    public void foo() {
+        try {
+            // do something
+        } catch (Exception e) {
+            e = new NullPointerException(); // not recommended
+        }
+        try {
+            // do something
+        } catch (MyException | ServerException e) {
+            e = new RuntimeException(); // won't compile
+        }
+    }
+}
+        ]]></example>
+    </rule>
+
+    <rule name="AvoidReassigningLoopVariables"
+          language="java"
+          since="6.11.0"
+          message="Avoid reassigning the loop control variable ''{0}''"
+          class="net.sourceforge.pmd.lang.java.rule.bestpractices.AvoidReassigningLoopVariablesRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#avoidreassigningloopvariables">
+        <description>
+            Reassigning loop variables can lead to hard-to-find bugs. Prevent or limit how these variables can be changed.
+
+            In foreach-loops, configured by the `foreachReassign` property:
+            - `deny`: Report any reassignment of the loop variable in the loop body. _This is the default._
+            - `allow`: Don't check the loop variable.
+            - `firstOnly`: Report any reassignments of the loop variable, except as the first statement in the loop body.
+            _This is useful if some kind of normalization or clean-up of the value before using is permitted, but any other change of the variable is not._
+
+            In for-loops, configured by the `forReassign` property:
+            - `deny`: Report any reassignment of the control variable in the loop body. _This is the default._
+            - `allow`: Don't check the control variable.
+            - `skip`: Report any reassignments of the control variable, except conditional increments/decrements (`++`, `--`, `+=`, `-=`).
+            _This prevents accidental reassignments or unconditional increments of the control variable._
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class Foo {
+  private void foo() {
+    for (String s : listOfStrings()) {
+      s = s.trim(); // OK, when foreachReassign is "firstOnly" or "allow"
+      doSomethingWith(s);
+      s = s.toUpper(); // OK, when foreachReassign is "allow"
+      doSomethingElseWith(s);
+    }
+    for (int i=0; i < 10; i++) {
+      if (check(i)) {
+        i++; // OK, when forReassign is "skip" or "allow"
+      }
+      i = 5;  // OK, when forReassign is "allow"
+      doSomethingWith(i);
+    }
+  }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidReassigningParameters"
+          language="java"
+          since="1.0"
+          message="Avoid reassigning parameters such as ''{0}''"
+          class="net.sourceforge.pmd.lang.java.rule.bestpractices.AvoidReassigningParametersRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#avoidreassigningparameters">
+        <description>
+            Reassigning values to incoming parameters of a method or constructor is not recommended, as this can
+            make the code more difficult to understand. The code is often read with the assumption that parameter values
+            don't change and an assignment violates therefore the principle of least astonishment. This is especially a
+            problem if the parameter is documented e.g. in the method's javadoc and the new content differs from the original
+            documented content.
+
+            Use temporary local variables instead. This allows you to assign a new name, which makes the code better
+            understandable.
+
+            Note that this rule considers both methods and constructors. If there are multiple assignments for a formal
+            parameter, then only the first assignment is reported.
+        </description>
+        <priority>2</priority>
+        <example>
+            <![CDATA[
+public class Hello {
+  private void greet(String name) {
+    name = name.trim();
+    System.out.println("Hello " + name);
+    // preferred
+    String trimmedName = name.trim();
+    System.out.println("Hello " + trimmedName);
+  }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidStringBufferField"
+          language="java"
+          since="4.2"
+          message="StringBuffers can grow quite a lot, and so may become a source of memory leak (if the owning class has a long life time)."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#avoidstringbufferfield">
+        <description>
+            StringBuffers/StringBuilders can grow considerably, and so may become a source of memory leaks
+            if held within objects with long lifetimes.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//FieldDeclaration/Type/ReferenceType/ClassOrInterfaceType[@Image = 'StringBuffer' or @Image = 'StringBuilder']
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo {
+    private StringBuffer buffer;    // potential memory leak as an instance variable;
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidUsingHardCodedIP"
+          language="java"
+          since="4.1"
+          message="Do not hard code the IP address ${variableName}"
+          class="net.sourceforge.pmd.lang.java.rule.bestpractices.AvoidUsingHardCodedIPRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#avoidusinghardcodedip">
+        <description>
+            Application with hard-coded IP addresses can become impossible to deploy in some cases.
+            Externalizing IP adresses is preferable.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class Foo {
+    private String ip = "127.0.0.1";     // not recommended
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="CheckResultSet"
+          language="java"
+          since="4.1"
+          class="net.sourceforge.pmd.lang.java.rule.bestpractices.CheckResultSetRule"
+          message="Always check the return of one of the navigation method (next,previous,first,last) of a ResultSet."
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#checkresultset">
+        <description>
+            Always check the return values of navigation methods (next, previous, first, last) of a ResultSet.
+            If the value return is 'false', it should be handled properly.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+Statement stat = conn.createStatement();
+ResultSet rst = stat.executeQuery("SELECT name FROM person");
+rst.next();     // what if it returns false? bad form
+String firstName = rst.getString(1);
+Statement stat = conn.createStatement();
+ResultSet rst = stat.executeQuery("SELECT name FROM person");
+if (rst.next()) {    // result is properly examined and used
+    String firstName = rst.getString(1);
+    } else  {
+        // handle missing data
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="ConstantsInInterface"
+          language="java"
+          since="5.5"
+          message="Avoid constants in interfaces. Interfaces define types, constants are implementation details better placed in classes or enums. See Effective Java, item 19."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#constantsininterface">
+        <description>
+            Avoid constants in interfaces. Interfaces should define types, constants are implementation details
+            better placed in classes or enums. See Effective Java, item 19.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="ignoreIfHasMethods" type="Boolean" description="Whether to ignore constants in interfaces if the interface defines any methods" value="true"/>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//ClassOrInterfaceDeclaration[@Interface= true()][$ignoreIfHasMethods= false() or not(.//MethodDeclaration)]//FieldDeclaration
+ ]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public interface ConstantInterface {
+    public static final int CONST1 = 1; // violation, no fields allowed in interface!
+    static final int CONST2 = 1;        // violation, no fields allowed in interface!
+    final int CONST3 = 1;               // violation, no fields allowed in interface!
+    int CONST4 = 1;                     // violation, no fields allowed in interface!
+}
+// with ignoreIfHasMethods = false
+public interface AnotherConstantInterface {
+    public static final int CONST1 = 1; // violation, no fields allowed in interface!
+    int anyMethod();
+}
+// with ignoreIfHasMethods = true
+public interface YetAnotherConstantInterface {
+    public static final int CONST1 = 1; // no violation
+    int anyMethod();
+}
+ ]]>
+        </example>
+    </rule>
+
+    <rule name="DefaultLabelNotLastInSwitchStmt"
+          language="java"
+          since="1.5"
+          message="The default label should be the last label in a switch statement"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#defaultlabelnotlastinswitchstmt">
+        <description>
+            By convention, the default label should be the last label in a switch statement.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//SwitchStatement
+ [not(SwitchLabel[position() = last()][@Default= true()])]
+ [SwitchLabel[@Default= true()]]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo {
+  void bar(int a) {
+   switch (a) {
+    case 1:  // do something
+       break;
+    default:  // the default case should be last, by convention
+       break;
+    case 2:
+       break;
+   }
+  }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="DoubleBraceInitialization"
+          language="java"
+          since="6.16.0"
+          message="Double-brace initialization should be avoided"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#doublebraceinitialization">
+        <description>
+            Double brace initialisation is a pattern to initialise eg collections concisely. But it implicitly
+            generates a new .class file, and the object holds a strong reference to the enclosing object. For those
+            reasons, it is preferable to initialize the object normally, even though it's verbose.
+
+            This rule counts any anonymous class which only has a single initializer as an instance of double-brace
+            initialization. There is currently no way to find out whether a method called in the initializer is not
+            accessible from outside the anonymous class, and those legit cases should be suppressed for the time being.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//AllocationExpression/ClassOrInterfaceBody[count(*)=1]/*/Initializer[@Static=false()]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example><![CDATA[
+// this is double-brace initialization
+return new ArrayList<String>(){{
+    add("a");
+    add("b");
+    add("c");
+}};
+// the better way is to not create an anonymous class:
+List<String> a = new ArrayList<>();
+a.add("a");
+a.add("b");
+a.add("c");
+return a;
+]]>
+        </example>
+    </rule>
+
+
+    <rule name="ForLoopCanBeForeach"
+          language="java"
+          since="6.0.0"
+          message="This 'for' loop can be replaced by a 'foreach' loop"
+          typeResolution="true"
+          minimumLanguageVersion="1.5"
+          class="net.sourceforge.pmd.lang.java.rule.bestpractices.ForLoopCanBeForeachRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#forloopcanbeforeach">
+        <description>
+            Reports loops that can be safely replaced with the foreach syntax. The rule considers loops over
+            lists, arrays and iterators. A loop is safe to replace if it only uses the index variable to
+            access an element of the list or array, only has one update statement, and loops through *every*
+            element of the list or array left to right.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class MyClass {
+  void loop(List<String> l) {
+    for (int i = 0; i < l.size(); i++) { // pre Java 1.5
+      System.out.println(l.get(i));
+    }
+    for (String s : l) {        // post Java 1.5
+      System.out.println(s);
+    }
+  }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="ForLoopVariableCount"
+          language="java"
+          since="6.11.0"
+          message="Too many control variables in the 'for' statement"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#forloopvariablecount">
+        <description>
+            Having a lot of control variables in a 'for' loop makes it harder to see what range of values
+            the loop iterates over. By default this rule allows a regular 'for' loop with only one variable.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="maximumVariables" type="Integer"
+                      description="A regular for statement will have 1 control variable" min="0" max="100" value="1"/>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>//ForInit/LocalVariableDeclaration[count(VariableDeclarator) > $maximumVariables]</value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+// this will be reported with the default setting of at most one control variable in a for loop
+for (int i = 0, j = 0; i < 10; i++, j += 2) {
+   foo();
+]]>
+        </example>
+    </rule>
+
+    <rule name="GuardLogStatement"
+          language="java"
+          since="5.1.0"
+          message="Logger calls should be surrounded by log level guards."
+          class="net.sourceforge.pmd.lang.java.rule.bestpractices.GuardLogStatementRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#guardlogstatement">
+        <description>
+            Whenever using a log level, one should check if the loglevel is actually enabled, or
+            otherwise skip the associate String creation and manipulation.
+
+            An alternative to checking the log level are substituting parameters, formatters or lazy logging
+            with lambdas. The available alternatives depend on the actual logging framework.
+        </description>
+        <priority>2</priority>
+        <example>
+            <![CDATA[
+// Add this for performance
+if (log.isDebugEnabled()) {
+    log.debug("log something" + param1 + " and " + param2 + "concat strings");
+}
+// Avoid the guarding if statement with substituting parameters
+log.debug("log something {} and {}", param1, param2);
+// Avoid the guarding if statement with formatters
+log.debug("log something %s and %s", param1, param2);
+// Avoid the guarding if statement with lazy logging and lambdas
+log.debug("log something expensive: {}", () -> calculateExpensiveLoggingText());
+]]>
+        </example>
+    </rule>
+
+    <rule name="JUnit4SuitesShouldUseSuiteAnnotation"
+          language="java"
+          since="4.0"
+          message="JUnit 4 indicates test suites via annotations, not the suite method."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          typeResolution="true"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#junit4suitesshouldusesuiteannotation">
+        <description>
+            In JUnit 3, test suites are indicated by the suite() method. In JUnit 4, suites are indicated
+            through the @RunWith(Suite.class) annotation.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//ClassOrInterfaceBodyDeclaration
+[MethodDeclaration[@Name='suite']/ResultType/Type/ReferenceType/ClassOrInterfaceType[pmd-java:typeIs('junit.framework.Test')]]
+[not(MethodDeclaration/Block/BlockStatement/Statement/ReturnStatement//ClassOrInterfaceType[pmd-java:typeIs('junit.framework.JUnit4TestAdapter')])]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class BadExample extends TestCase{
+    public static Test suite(){
+        return new Suite();
+    }
+}
+@RunWith(Suite.class)
+@SuiteClasses( { TestOne.class, TestTwo.class })
+public class GoodTest {
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="JUnit4TestShouldUseAfterAnnotation"
+          language="java"
+          since="4.0"
+          message="JUnit 4 tests that clean up tests should use the @After annotation, JUnit5 tests should use @AfterEach or @AfterAll"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          typeResolution="true"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#junit4testshoulduseafterannotation">
+        <description>
+            In JUnit 3, the tearDown method was used to clean up all data entities required in running tests.
+            JUnit 4 skips the tearDown method and executes all methods annotated with @After after running each test.
+            JUnit 5 introduced @AfterEach and @AfterAll annotations to execute methods after each test or after all tests in the class, respectively.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//ClassOrInterfaceBodyDeclaration
+    [MethodDeclaration[@Name='tearDown']]
+    [not(Annotation/*/Name[
+           pmd-java:typeIs('org.junit.After')
+        or pmd-java:typeIs('org.junit.jupiter.api.AfterEach')
+        or pmd-java:typeIs('org.junit.jupiter.api.AfterAll')
+        or pmd-java:typeIs('org.testng.annotations.AfterMethod')])]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class MyTest {
+    public void tearDown() {
+        bad();
+    }
+}
+public class MyTest2 {
+    @After public void tearDown() {
+        good();
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="JUnit4TestShouldUseBeforeAnnotation"
+          language="java"
+          since="4.0"
+          message="JUnit 4 tests that set up tests should use the @Before annotation, JUnit5 tests should use @BeforeEach or @BeforeAll"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          typeResolution="true"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#junit4testshouldusebeforeannotation">
+        <description>
+            In JUnit 3, the setUp method was used to set up all data entities required in running tests.
+            JUnit 4 skips the setUp method and executes all methods annotated with @Before before all tests.
+            JUnit 5 introduced @BeforeEach and @BeforeAll annotations to execute methods before each test or before all tests in the class, respectively.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//ClassOrInterfaceBodyDeclaration
+    [MethodDeclaration[@Name='setUp']]
+    [not(Annotation/*/Name[
+           pmd-java:typeIs('org.junit.Before')
+        or pmd-java:typeIs('org.junit.jupiter.api.BeforeEach')
+        or pmd-java:typeIs('org.junit.jupiter.api.BeforeAll')
+        or pmd-java:typeIs('org.testng.annotations.BeforeMethod')])]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class MyTest {
+    public void setUp() {
+        bad();
+    }
+}
+public class MyTest2 {
+    @Before public void setUp() {
+        good();
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="JUnit4TestShouldUseTestAnnotation"
+          language="java"
+          since="4.0"
+          message="JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          typeResolution="true"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#junit4testshouldusetestannotation">
+        <description>
+            In JUnit 3, the framework executed all methods which started with the word test as a unit test.
+            In JUnit 4, only methods annotated with the @Test annotation are executed.
+            In JUnit 5, one of the following annotations should be used for tests: @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//ClassOrInterfaceDeclaration[
+       matches(@SimpleName, $testClassPattern)
+        or ExtendsList/ClassOrInterfaceType[pmd-java:typeIs('junit.framework.TestCase')]]
+    /ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration[MethodDeclaration[@Public=true() and starts-with(@Name, 'test')]]
+    [not(Annotation//Name[
+        pmd-java:typeIs('org.junit.Test')
+        or pmd-java:typeIs('org.junit.jupiter.api.Test') or pmd-java:typeIs('org.junit.jupiter.api.RepeatedTest')
+        or pmd-java:typeIs('org.junit.jupiter.api.TestFactory') or pmd-java:typeIs('org.junit.jupiter.api.TestTemplate')
+        or pmd-java:typeIs('org.junit.jupiter.params.ParameterizedTest')
+    ])]
+]]>
+                </value>
+            </property>
+            <property name="testClassPattern" type="Regex" description="The regex pattern used to identify test classes" value="Test" />
+            <property name="version" value="2.0"/>
+        </properties>
+        <example>
+            <![CDATA[
+public class MyTest {
+    public void testBad() {
+        doSomething();
+    }
+    @Test
+    public void testGood() {
+        doSomething();
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="JUnit5TestShouldBePackagePrivate"
+          language="java"
+          since="6.35.0"
+          message="JUnit 5 tests should be package-private."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          typeResolution="true"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#junit5testshouldbepackageprivate">
+        <description><![CDATA[
+Reports JUnit 5 test classes and methods that are not package-private.
+Contrary to JUnit 4 tests, which required public visibility to be run by the engine,
+JUnit 5 tests can also be run if they're package-private. Marking them as such
+is a good practice to limit their visibility.
+Test methods are identified as those which use `@Test`, `@RepeatedTest`,
+`@TestFactory`, `@TestTemplate` or `@ParameterizedTest`.
+            ]]></description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//ClassOrInterfaceDeclaration[
+    (: a Junit 5 test class, ie, it has methods with the annotation :)
+    @Interface=false() and
+    ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration
+        [Annotation//Name[
+            pmd-java:typeIs('org.junit.jupiter.api.Test') or pmd-java:typeIs('org.junit.jupiter.api.RepeatedTest')
+            or pmd-java:typeIs('org.junit.jupiter.api.TestFactory') or pmd-java:typeIs('org.junit.jupiter.api.TestTemplate')
+            or pmd-java:typeIs('org.junit.jupiter.params.ParameterizedTest')
+        ]]
+        [MethodDeclaration]
+]/(
+    self::*[@Abstract=false() and (@Public=true() or @Protected=true())]
+|   ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration
+        [Annotation//Name[
+            pmd-java:typeIs('org.junit.jupiter.api.Test') or pmd-java:typeIs('org.junit.jupiter.api.RepeatedTest')
+            or pmd-java:typeIs('org.junit.jupiter.api.TestFactory') or pmd-java:typeIs('org.junit.jupiter.api.TestTemplate')
+            or pmd-java:typeIs('org.junit.jupiter.params.ParameterizedTest')
+        ]]
+        /MethodDeclaration[@Public=true() or @Protected=true()]
+)
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+class MyTest { // not public, that's fine
+    @Test
+    public void testBad() { } // should not have a public modifier
+    @Test
+    protected void testAlsoBad() { } // should not have a protected modifier
+    @Test
+    private void testNoRun() { } // should not have a private modifier
+    @Test
+    void testGood() { } // package private as expected
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="JUnitAssertionsShouldIncludeMessage"
+          language="java"
+          since="1.04"
+          message="JUnit assertions should include a message"
+          class="net.sourceforge.pmd.lang.java.rule.bestpractices.JUnitAssertionsShouldIncludeMessageRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#junitassertionsshouldincludemessage">
+        <description>
+            JUnit assertions should include an informative message - i.e., use the three-argument version of
+            assertEquals(), not the two-argument version.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class Foo extends TestCase {
+    public void testSomething() {
+        assertEquals("foo", "bar");
+        // Use the form:
+        // assertEquals("Foo does not equals bar", "foo", "bar");
+        // instead
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="JUnitTestContainsTooManyAsserts"
+          language="java"
+          since="5.0"
+          message="Unit tests should not contain more than ${maximumAsserts} assert(s)."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          typeResolution="true"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#junittestcontainstoomanyasserts">
+        <description>
+            Unit tests should not contain too many asserts. Many asserts are indicative of a complex test, for which
+            it is harder to verify correctness.  Consider breaking the test scenario into multiple, shorter test scenarios.
+            Customize the maximum number of assertions used by this Rule to suit your needs.
+
+            This rule checks for JUnit4, JUnit5 and TestNG Tests, as well as methods starting with "test".
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="maximumAsserts" type="Integer" min="1" max="1000" description="Maximum number of Asserts in a test method" value="1"/>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//MethodDeclaration[@Name[matches(.,'^test')] or ../Annotation/MarkerAnnotation/Name[
+           pmd-java:typeIs('org.junit.Test')
+        or pmd-java:typeIs('org.junit.jupiter.api.Test')
+        or pmd-java:typeIs('org.junit.jupiter.api.RepeatedTest')
+        or pmd-java:typeIs('org.junit.jupiter.api.TestFactory')
+        or pmd-java:typeIs('org.junit.jupiter.api.TestTemplate')
+        or pmd-java:typeIs('org.junit.jupiter.params.ParameterizedTest')
+        or pmd-java:typeIs('org.testng.annotations.Test')
+    ]]
+    [count(.//PrimaryPrefix/Name[@Image[matches(.,'^assert')]]) > $maximumAsserts]
+]]>
+                </value>
+            </property>
+            <property name="version" value="2.0"/>
+        </properties>
+        <example>
+            <![CDATA[
+public class MyTestCase extends TestCase {
+    // Ok
+    public void testMyCaseWithOneAssert() {
+        boolean myVar = false;
+        assertFalse("should be false", myVar);
+    }
+    // Bad, too many asserts (assuming max=1)
+    public void testMyCaseWithMoreAsserts() {
+        boolean myVar = false;
+        assertFalse("myVar should be false", myVar);
+        assertEquals("should equals false", false, myVar);
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="JUnitTestsShouldIncludeAssert"
+          language="java"
+          since="2.0"
+          message="JUnit tests should include assert() or fail()"
+          class="net.sourceforge.pmd.lang.java.rule.bestpractices.JUnitTestsShouldIncludeAssertRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#junittestsshouldincludeassert">
+        <description>
+            JUnit tests should include at least one assertion.  This makes the tests more robust, and using assert
+            with messages provide the developer a clearer idea of what the test does.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class Foo extends TestCase {
+   public void testSomething() {
+      Bar b = findBar();
+   // This is better than having a NullPointerException
+   // assertNotNull("bar not found", b);
+   b.work();
+   }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="JUnitUseExpected"
+          language="java"
+          since="4.0"
+          message="In JUnit4, use the @Test(expected) annotation to denote tests that should throw exceptions"
+          class="net.sourceforge.pmd.lang.java.rule.bestpractices.JUnitUseExpectedRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#junituseexpected">
+        <description>
+            In JUnit4, use the @Test(expected) annotation to denote tests that should throw exceptions.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class MyTest {
+    @Test
+    public void testBad() {
+        try {
+            doSomething();
+            fail("should have thrown an exception");
+        } catch (Exception e) {
+        }
+    }
+    @Test(expected=Exception.class)
+    public void testGood() {
+        doSomething();
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="LiteralsFirstInComparisons"
+          language="java"
+          since="6.24.0"
+          message="Position literals first in String comparisons"
+          class="net.sourceforge.pmd.lang.java.rule.bestpractices.LiteralsFirstInComparisonsRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#literalsfirstincomparisons">
+        <description>
+            Position literals first in all String comparisons, if the second argument is null then NullPointerExceptions
+            can be avoided, they will just return false. Note that switching literal positions for compareTo and
+            compareToIgnoreCase may change the result, see examples.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+class Foo {
+    boolean bar(String x) {
+        return x.equals("2"); // should be "2".equals(x)
+    }
+    boolean bar(String x) {
+        return x.equalsIgnoreCase("2"); // should be "2".equalsIgnoreCase(x)
+    }
+    boolean bar(String x) {
+        return (x.compareTo("bar") > 0); // should be: "bar".compareTo(x) < 0
+    }
+    boolean bar(String x) {
+        return (x.compareToIgnoreCase("bar") > 0); // should be: "bar".compareToIgnoreCase(x) < 0
+    }
+    boolean bar(String x) {
+        return x.contentEquals("bar"); // should be "bar".contentEquals(x)
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="LooseCoupling"
+          language="java"
+          since="0.7"
+          message="Avoid using implementation types like ''{0}''; use the interface instead"
+          class="net.sourceforge.pmd.lang.java.rule.bestpractices.LooseCouplingRule"
+          typeResolution="true"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#loosecoupling">
+        <description>
+            The use of implementation types (i.e., HashSet) as object references limits your ability to use alternate
+            implementations in the future as requirements change. Whenever available, referencing objects
+            by their interface types (i.e, Set) provides much more flexibility.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+import java.util.ArrayList;
+import java.util.HashSet;
+public class Bar {
+    // sub-optimal approach
+    private ArrayList<SomeType> list = new ArrayList<>();
+    public HashSet<SomeType> getFoo() {
+        return new HashSet<SomeType>();
+    }
+    // preferred approach
+    private List<SomeType> list = new ArrayList<>();
+    public Set<SomeType> getFoo() {
+        return new HashSet<SomeType>();
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="MethodReturnsInternalArray"
+          language="java"
+          since="2.2"
+          message="Returning ''{0}'' may expose an internal array."
+          class="net.sourceforge.pmd.lang.java.rule.bestpractices.MethodReturnsInternalArrayRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#methodreturnsinternalarray">
+        <description>
+            Exposing internal arrays to the caller violates object encapsulation since elements can be
+            removed or replaced outside of the object that owns it. It is safer to return a copy of the array.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class SecureSystem {
+    UserData [] ud;
+    public UserData [] getUserData() {
+        // Don't return directly the internal array, return a copy
+        return ud;
+    }
+}
+]]>
+        </example>
+    </rule>
+
+
+    <rule name="MissingOverride"
+          language="java"
+          since="6.2.0"
+          minimumLanguageVersion="1.5"
+          message="The method ''{0}'' is missing an @Override annotation."
+          typeResolution="true"
+          class="net.sourceforge.pmd.lang.java.rule.bestpractices.MissingOverrideRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#missingoverride">
+        <description>
+            Annotating overridden methods with @Override ensures at compile time that
+            the method really overrides one, which helps refactoring and clarifies intent.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+            public class Foo implements Runnable {
+                // This method is overridden, and should have an @Override annotation
+                public void run() {
+                }
+            }
+            ]]>
+        </example>
+    </rule>
+
+    <rule name="OneDeclarationPerLine"
+          language="java"
+          since="5.0"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          message="Use one line for each declaration, it enhances code readability."
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#onedeclarationperline">
+        <description>
+            Java allows the use of several variables declaration of the same type on one line. However, it
+            can lead to quite messy code. This rule looks for several declarations on the same line.
+        </description>
+        <priority>4</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//LocalVariableDeclaration
+   [not(parent::ForInit)]
+   [count(VariableDeclarator) > 1]
+   [$strictMode or count(distinct-values(VariableDeclarator/@BeginLine)) != count(VariableDeclarator)]
+|
+//FieldDeclaration
+   [count(VariableDeclarator) > 1]
+   [$strictMode or count(distinct-values(VariableDeclarator/@BeginLine)) != count(VariableDeclarator)]
+]]>
+                </value>
+            </property>
+            <property name="version" value="2.0"/>
+            <property name="strictMode" type="Boolean" value="false"
+                      description="If true, mark combined declaration even if the declarations are on separate lines."/>
+        </properties>
+        <example>
+            <![CDATA[
+String name;            // separate declarations
+String lastname;
+String name, lastname;  // combined declaration, a violation
+String name,
+       lastname;        // combined declaration on multiple lines, no violation by default.
+                        // Set property strictMode to true to mark this as violation.
+]]>
+        </example>
+    </rule>
+
+    <rule name="PositionLiteralsFirstInCaseInsensitiveComparisons"
+          language="java"
+          since="5.1"
+          message="Position literals first in String comparisons for EqualsIgnoreCase"
+          class="net.sourceforge.pmd.lang.java.rule.bestpractices.PositionLiteralsFirstInCaseInsensitiveComparisonsRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#positionliteralsfirstincaseinsensitivecomparisons"
+          deprecated="true">
+        <description>
+            Position literals first in comparisons, if the second argument is null then NullPointerExceptions
+            can be avoided, they will just return false.
+
+            This rule is replaced by the more general rule {% rule "LiteralsFirstInComparisons" %}.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+class Foo {
+  boolean bar(String x) {
+    return x.equalsIgnoreCase("2"); // should be "2".equalsIgnoreCase(x)
+  }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="PositionLiteralsFirstInComparisons"
+          language="java"
+          since="3.3"
+          message="Position literals first in String comparisons"
+          class="net.sourceforge.pmd.lang.java.rule.bestpractices.PositionLiteralsFirstInComparisonsRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#positionliteralsfirstincomparisons"
+          deprecated="true">
+        <description>
+            Position literals first in comparisons, if the second argument is null then NullPointerExceptions
+            can be avoided, they will just return false.
+
+            This rule is replaced by the more general rule {% rule "LiteralsFirstInComparisons" %}.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+class Foo {
+  boolean bar(String x) {
+    return x.equals("2"); // should be "2".equals(x)
+  }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="PreserveStackTrace"
+          language="java"
+          since="3.7"
+          message="New exception is thrown in catch block, original stack trace may be lost"
+          class="net.sourceforge.pmd.lang.java.rule.bestpractices.PreserveStackTraceRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#preservestacktrace">
+        <description>
+            Throwing a new exception from a catch block without passing the original exception into the
+            new exception will cause the original stack trace to be lost making it difficult to debug
+            effectively.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class Foo {
+    void good() {
+        try{
+            Integer.parseInt("a");
+        } catch (Exception e) {
+            throw new Exception(e); // first possibility to create exception chain
+        }
+        try {
+            Integer.parseInt("a");
+        } catch (Exception e) {
+            throw (IllegalStateException)new IllegalStateException().initCause(e); // second possibility to create exception chain.
+        }
+    }
+    void bad() {
+        try{
+            Integer.parseInt("a");
+        } catch (Exception e) {
+            throw new Exception(e.getMessage());
+        }
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="PrimitiveWrapperInstantiation"
+          language="java"
+          since="6.37.0"
+          message="Do not use `new {0}(...)`, prefer `{0}.valueOf(...)`"
+          class="net.sourceforge.pmd.lang.java.rule.bestpractices.PrimitiveWrapperInstantiationRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#primitivewrapperinstantiation">
+        <description>
+            Reports usages of primitive wrapper constructors. They are deprecated
+            since Java 9 and should not be used. Even before Java 9, they can
+            be replaced with usage of the corresponding static `valueOf` factory method
+            (which may be automatically inserted by the compiler since Java 1.5).
+            This has the advantage that it may reuse common instances instead of creating
+            a new instance each time.
+
+            Note that for `Boolean`, the named constants `Boolean.TRUE` and `Boolean.FALSE`
+            are preferred instead of `Boolean.valueOf`.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+            public class Foo {
+                private Integer ZERO = new Integer(0);      // violation
+                private Integer ZERO1 = Integer.valueOf(0); // better
+                private Integer ZERO1 = 0;                  // even better
+            }
+            ]]>
+        </example>
+    </rule>
+
+
+    <rule name="ReplaceEnumerationWithIterator"
+          language="java"
+          since="3.4"
+          message="Consider replacing this Enumeration with the newer java.util.Iterator"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#replaceenumerationwithiterator">
+        <description>
+            Consider replacing Enumeration usages with the newer java.util.Iterator
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//ImplementsList/ClassOrInterfaceType[@Image='Enumeration']
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo implements Enumeration {
+    private int x = 42;
+    public boolean hasMoreElements() {
+        return true;
+    }
+    public Object nextElement() {
+        return String.valueOf(i++);
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="ReplaceHashtableWithMap"
+          language="java"
+          since="3.4"
+          message="Consider replacing this Hashtable with the newer java.util.Map"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#replacehashtablewithmap">
+        <description>
+            Consider replacing Hashtable usage with the newer java.util.Map if thread safety is not required.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>//Type/ReferenceType/ClassOrInterfaceType[@Image='Hashtable']</value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo {
+    void bar() {
+        Hashtable h = new Hashtable();
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="ReplaceVectorWithList"
+          language="java"
+          since="3.4"
+          message="Consider replacing this Vector with the newer java.util.List"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#replacevectorwithlist">
+        <description>
+            Consider replacing Vector usages with the newer java.util.ArrayList if expensive thread-safe operations are not required.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>//Type/ReferenceType/ClassOrInterfaceType[@Image='Vector']</value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo {
+    void bar() {
+        Vector v = new Vector();
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="SimplifiableTestAssertion"
+          language="java"
+          since="6.37.0"
+          message="Assertion may be simplified using {0}"
+          typeResolution="true"
+          class="net.sourceforge.pmd.lang.java.rule.bestpractices.SimplifiableTestAssertionRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#simplifiabletestassertion">
+        <description>
+            Reports test assertions that may be simplified using a more specific
+            assertion method. This enables better error messages, and makes the
+            assertions more readable.
+
+            The rule only applies within test classes for the moment. It replaces
+            the deprecated rules {% rule UseAssertEqualsInsteadOfAssertTrue %},
+            {% rule UseAssertNullInsteadOfAssertTrue %}, {% rule UseAssertSameInsteadOfAssertTrue %},
+            {% rule UseAssertTrueInsteadOfAssertEquals %}, and {% rule java/design/SimplifyBooleanAssertion %}.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+import org.junit.Test;
+import static org.junit.Assert.*;
+class SomeTestClass {
+    Object a,b;
+    @Test
+    void testMethod() {
+        assertTrue(a.equals(b)); // could be assertEquals(a, b);
+        assertTrue(!a.equals(b)); // could be assertNotEquals(a, b);
+        assertTrue(!something); // could be assertFalse(something);
+        assertFalse(!something); // could be assertTrue(something);
+        assertTrue(a == b); // could be assertSame(a, b);
+        assertTrue(a != b); // could be assertNotSame(a, b);
+        assertTrue(a == null); // could be assertNull(a);
+        assertTrue(a != null); // could be assertNotNull(a);
+    }
+}
+            ]]>
+        </example>
+    </rule>
+
+    <rule name="SwitchStmtsShouldHaveDefault"
+          language="java"
+          since="1.0"
+          message="Switch statements should be exhaustive, add a default case (or missing enum branches)"
+          typeResolution="true"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#switchstmtsshouldhavedefault">
+        <description>
+            Switch statements should be exhaustive, to make their control flow
+            easier to follow. This can be achieved by adding a `default` case, or,
+            if the switch is on an enum type, by ensuring there is one switch branch
+            for each enum constant.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value><![CDATA[
+                //SwitchStatement[@DefaultCase = false() and @ExhaustiveEnumSwitch = false()]
+            ]]></value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+class Foo {{
+    int x = 2;
+    switch (x) {
+      case 1: int j = 6;
+      case 2: int j = 8;
+      // missing default: here
+    }
+}}
+]]>
+        </example>
+    </rule>
+
+    <rule name="SystemPrintln"
+          language="java"
+          since="2.1"
+          message="{0} is used"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#systemprintln">
+        <description>
+            References to System.(out|err).print are usually intended for debugging purposes and can remain in
+            the codebase even in production code. By using a logger one can enable/disable this behaviour at
+            will (and by priority) and avoid clogging the Standard out log.
+        </description>
+        <priority>2</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//Name[
+    starts-with(@Image, 'System.out.print')
+    or
+    starts-with(@Image, 'System.err.print')
+    ]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+class Foo{
+    Logger log = Logger.getLogger(Foo.class.getName());
+    public void testA () {
+        System.out.println("Entering test");
+        // Better use this
+        log.fine("Entering test");
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="UnusedAssignment"
+          language="java"
+          since="6.26.0"
+          message="The value assigned to this variable is never used or always overwritten"
+          class="net.sourceforge.pmd.lang.java.rule.bestpractices.UnusedAssignmentRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#unusedassignment">
+        <description>
+            Reports assignments to variables that are never used before the variable is overwritten,
+            or goes out of scope. Unused assignments are those for which
+            1. The variable is never read after the assignment, or
+            2. The assigned value is always overwritten by other assignments before the next read of
+            the variable.
+
+            The rule doesn't consider assignments to fields except for those of `this` in a constructor,
+            or static fields of the current class in static initializers.
+
+            The rule may be suppressed with the standard `@SuppressWarnings("unused")` tag.
+
+            The rule subsumes {% rule "UnusedLocalVariable" %}, and {% rule "UnusedFormalParameter" %}.
+            Those violations are filtered
+            out by default, in case you already have enabled those rules, but may be enabled with the property
+            `reportUnusedVariables`. Variables whose name starts with `ignored` or `unused` are filtered out, as
+            is standard practice for exceptions.
+
+            Limitations:
+            * The rule currently cannot know which method calls throw exceptions, or which exceptions they throw.
+            In the body of a try block, every method or constructor call is assumed to throw.  This may cause false-negatives.
+            The only other language construct that is assumed to throw is the `throw` statement, in particular,
+            things like `assert` statements, or NullPointerExceptions on dereference are ignored.
+            * The rule cannot resolve assignments across constructors, when they're called with the special
+            `this(...)` syntax. This may cause false-negatives.
+
+            Both of those limitations may be partly relaxed in PMD 7.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+            class A {
+                // this field initializer is redundant,
+                // it is always overwritten in the constructor
+                int f = 1;
+                A(int f) {
+                    this.f = f;
+                }
+            }
+        ]]>
+        </example>
+        <example><![CDATA[
+class B {
+    int method(int i, int j) {
+        // this initializer is redundant,
+        // it is overwritten in all branches of the `if`
+        int k = 0;
+        // Both the assignments to k are unused, because k is
+        // not read after the if/else
+        // This may hide a bug: the programmer probably wanted to return k
+        if (i < j)
+            k = i;
+        else
+            k = j;
+        return j;
+    }
+}
+        ]]>
+
+        </example>
+        <example><![CDATA[
+class C {
+    int method() {
+        int i = 0;
+        checkSomething(++i);
+        checkSomething(++i);
+        checkSomething(++i);
+        checkSomething(++i);
+        // That last increment is not reported unless
+        // the property `checkUnusedPrefixIncrement` is
+        // set to `true`
+        // Technically it could be written (i+1), but it
+        // is not very important
+    }
+}
+        ]]>
+
+        </example>
+        <example><![CDATA[
+class C {
+    // variables that are truly unused (at most assigned to, but never accessed)
+    // are only reported if property `reportUnusedVariables` is true
+    void method(int param) { } // for example this method parameter
+    // even then, you can suppress the violation with an annotation:
+    void method(@SuppressWarning("unused") int param) { } // no violation, even if `reportUnusedVariables` is true
+    // For catch parameters, or for resources which don't need to be used explicitly,
+    // you can give a name that starts with "ignored" to ignore such warnings
+    {
+        try (Something ignored = Something.create()) {
+            // even if ignored is unused, it won't be flagged
+            // its purpose might be to side-effect in the create/close routines
+        } catch (Exception e) { // this is unused and will cause a warning if `reportUnusedVariables` is true
+            // you should choose a name that starts with "ignored"
+            return;
+        }
+    }
+}
+        ]]>
+
+        </example>
+    </rule>
+
+    <rule name="UnusedFormalParameter"
+          language="java"
+          since="0.8"
+          message="Avoid unused {0} parameters such as ''{1}''."
+          class="net.sourceforge.pmd.lang.java.rule.bestpractices.UnusedFormalParameterRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#unusedformalparameter">
+        <description>
+            Reports parameters of methods and constructors that are not referenced them in the method body.
+            Parameters whose name starts with `ignored` or `unused` are filtered out.
+
+            Removing unused formal parameters from public methods could cause a ripple effect through the code base.
+            Hence, by default, this rule only considers private methods. To include non-private methods, set the
+            `checkAll` property to `true`.
+
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class Foo {
+    private void bar(String howdy) {
+        // howdy is not used
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="UnusedImports"
+          language="java"
+          since="1.0"
+          message="Unused import ''{0}''"
+          class="net.sourceforge.pmd.lang.java.rule.bestpractices.UnusedImportsRule"
+          typeResolution="true"
+          deprecated="true"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#unusedimports">
+        <description>
+            Reports import statements that are not used within the file. This also reports
+            duplicate imports, and imports from the same package. The simplest fix is just
+            to delete those imports.
+
+            This rule is deprecated since PMD 6.34.0. Use the rule {% rule "java/codestyle/UnnecessaryImport" %}
+            from category codestyle instead.
+        </description>
+        <priority>4</priority>
+        <example>
+            <![CDATA[
+import java.io.File;  // not referenced or required
+import java.util.*;   // not referenced or required
+public class Foo {}
+]]>
+        </example>
+    </rule>
+
+    <rule name="UnusedLocalVariable"
+          language="java"
+          since="0.1"
+          message="Avoid unused local variables such as ''{0}''."
+          class="net.sourceforge.pmd.lang.java.rule.bestpractices.UnusedLocalVariableRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#unusedlocalvariable">
+        <description>
+            Detects when a local variable is declared and/or assigned, but not used.
+            Variables whose name starts with `ignored` or `unused` are filtered out.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class Foo {
+    public void doSomething() {
+        int i = 5; // Unused
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="UnusedPrivateField"

Review comment:
       This rule is enabled in our repo




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] alievmirza commented on a change in pull request #327: review pmd check rules

Posted by GitBox <gi...@apache.org>.
alievmirza commented on a change in pull request #327:
URL: https://github.com/apache/ignite-3/pull/327#discussion_r705368917



##########
File path: check-rules/errorprone.xml
##########
@@ -0,0 +1,3721 @@
+<?xml version="1.0"?>
+
+<ruleset name="Error Prone"
+         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 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">
+
+    <description>
+        Rules to detect constructs that are either broken, extremely confusing or prone to runtime errors.
+    </description>
+
+    <rule name="AssignmentInOperand"
+          language="java"
+          since="1.03"
+          message="Avoid assignments in operands"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AssignmentInOperandRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#assignmentinoperand">
+        <description>
+            Avoid assignments in operands; this can make code more complicated and harder to read.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public void bar() {
+    int x = 2;
+    if ((x = getX()) == 3) {
+      System.out.println("3!");
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AssignmentToNonFinalStatic"
+          language="java"
+          since="2.2"
+          message="Possible unsafe assignment to a non-final static field in a constructor."
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AssignmentToNonFinalStaticRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#assignmenttononfinalstatic">
+        <description>
+            Identifies a possible unsafe usage of a static field.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class StaticField {
+   static int x;
+   public FinalFields(int y) {
+    x = y; // unsafe
+   }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidAccessibilityAlteration"
+          language="java"
+          since="4.1"
+          message="You should not modify visibility of class or methods using getDeclaredConstructors(), getDeclaredConstructor(Class[]), setAccessible() or PrivilegedAction."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidaccessibilityalteration">
+        <description>
+            Methods such as getDeclaredConstructors(), getDeclaredConstructor(Class[]) and setAccessible(),
+            as the interface PrivilegedAction, allow for the runtime alteration of variable, class, or
+            method visibility, even if they are private. This violates the principle of encapsulation.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//PrimaryExpression[
+(
+(PrimarySuffix[
+        ends-with(@Image,'getDeclaredConstructors')
+                or
+        ends-with(@Image,'getDeclaredConstructor')
+                or
+        ends-with(@Image,'setAccessible')
+        ])
+or
+(PrimaryPrefix/Name[
+        ends-with(@Image,'getDeclaredConstructor')
+        or
+        ends-with(@Image,'getDeclaredConstructors')
+        or
+        starts-with(@Image,'AccessibleObject.setAccessible')
+        ])
+)
+and
+(//ImportDeclaration/Name[
+        contains(@Image,'java.security.PrivilegedAction')])
+]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Method;
+import java.security.PrivilegedAction;
+
+public class Violation {
+  public void invalidCallsInMethod() throws SecurityException, NoSuchMethodException {
+    // Possible call to forbidden getDeclaredConstructors
+    Class[] arrayOfClass = new Class[1];
+    this.getClass().getDeclaredConstructors();
+    this.getClass().getDeclaredConstructor(arrayOfClass);
+    Class clazz = this.getClass();
+    clazz.getDeclaredConstructor(arrayOfClass);
+    clazz.getDeclaredConstructors();
+      // Possible call to forbidden setAccessible
+    clazz.getMethod("", arrayOfClass).setAccessible(false);
+    AccessibleObject.setAccessible(null, false);
+    Method.setAccessible(null, false);
+    Method[] methodsArray = clazz.getMethods();
+    int nbMethod;
+    for ( nbMethod = 0; nbMethod < methodsArray.length; nbMethod++ ) {
+      methodsArray[nbMethod].setAccessible(false);
+    }
+
+      // Possible call to forbidden PrivilegedAction
+    PrivilegedAction priv = (PrivilegedAction) new Object(); priv.run();
+  }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidAssertAsIdentifier"
+          language="java"
+          since="3.4"
+          message="Avoid using assert as an identifier; it became a reserved word in JDK 1.4"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidassertasidentifier">
+        <description>
+            Use of the term 'assert' will conflict with newer versions of Java since it is a reserved word.
+        </description>
+        <priority>2</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>//VariableDeclaratorId[@Name='assert']</value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class A {
+    public class Foo {
+        String assert = "foo";
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidBranchingStatementAsLastInLoop"
+          language="java"
+          since="5.0"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AvoidBranchingStatementAsLastInLoopRule"
+          message="Avoid using a branching statement as the last in a loop."
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidbranchingstatementaslastinloop">
+        <description>
+            Using a branching statement as the last part of a loop may be a bug, and/or is confusing.
+            Ensure that the usage is not a bug, or consider using another approach.
+        </description>
+        <priority>2</priority>
+        <example>
+            <![CDATA[
+// unusual use of branching statement in a loop
+for (int i = 0; i < 10; i++) {
+    if (i*i <= 25) {
+        continue;
+    }
+    break;
+}
+
+// this makes more sense...
+for (int i = 0; i < 10; i++) {
+    if (i*i > 25) {
+        break;
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidCallingFinalize"
+          language="java"
+          since="3.0"
+          message="Avoid calling finalize() explicitly"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AvoidCallingFinalizeRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidcallingfinalize">
+        <description>
+            The method Object.finalize() is called by the garbage collector on an object when garbage collection determines
+            that there are no more references to the object. It should not be invoked by application logic.
+
+            Note that Oracle has declared Object.finalize() as deprecated since JDK 9.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+void foo() {
+    Bar b = new Bar();
+    b.finalize();
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidCatchingNPE"

Review comment:
       This rule is enabled in our repo

##########
File path: check-rules/errorprone.xml
##########
@@ -0,0 +1,3721 @@
+<?xml version="1.0"?>
+
+<ruleset name="Error Prone"
+         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 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">
+
+    <description>
+        Rules to detect constructs that are either broken, extremely confusing or prone to runtime errors.
+    </description>
+
+    <rule name="AssignmentInOperand"
+          language="java"
+          since="1.03"
+          message="Avoid assignments in operands"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AssignmentInOperandRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#assignmentinoperand">
+        <description>
+            Avoid assignments in operands; this can make code more complicated and harder to read.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public void bar() {
+    int x = 2;
+    if ((x = getX()) == 3) {
+      System.out.println("3!");
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AssignmentToNonFinalStatic"
+          language="java"
+          since="2.2"
+          message="Possible unsafe assignment to a non-final static field in a constructor."
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AssignmentToNonFinalStaticRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#assignmenttononfinalstatic">
+        <description>
+            Identifies a possible unsafe usage of a static field.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class StaticField {
+   static int x;
+   public FinalFields(int y) {
+    x = y; // unsafe
+   }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidAccessibilityAlteration"
+          language="java"
+          since="4.1"
+          message="You should not modify visibility of class or methods using getDeclaredConstructors(), getDeclaredConstructor(Class[]), setAccessible() or PrivilegedAction."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidaccessibilityalteration">
+        <description>
+            Methods such as getDeclaredConstructors(), getDeclaredConstructor(Class[]) and setAccessible(),
+            as the interface PrivilegedAction, allow for the runtime alteration of variable, class, or
+            method visibility, even if they are private. This violates the principle of encapsulation.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//PrimaryExpression[
+(
+(PrimarySuffix[
+        ends-with(@Image,'getDeclaredConstructors')
+                or
+        ends-with(@Image,'getDeclaredConstructor')
+                or
+        ends-with(@Image,'setAccessible')
+        ])
+or
+(PrimaryPrefix/Name[
+        ends-with(@Image,'getDeclaredConstructor')
+        or
+        ends-with(@Image,'getDeclaredConstructors')
+        or
+        starts-with(@Image,'AccessibleObject.setAccessible')
+        ])
+)
+and
+(//ImportDeclaration/Name[
+        contains(@Image,'java.security.PrivilegedAction')])
+]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Method;
+import java.security.PrivilegedAction;
+
+public class Violation {
+  public void invalidCallsInMethod() throws SecurityException, NoSuchMethodException {
+    // Possible call to forbidden getDeclaredConstructors
+    Class[] arrayOfClass = new Class[1];
+    this.getClass().getDeclaredConstructors();
+    this.getClass().getDeclaredConstructor(arrayOfClass);
+    Class clazz = this.getClass();
+    clazz.getDeclaredConstructor(arrayOfClass);
+    clazz.getDeclaredConstructors();
+      // Possible call to forbidden setAccessible
+    clazz.getMethod("", arrayOfClass).setAccessible(false);
+    AccessibleObject.setAccessible(null, false);
+    Method.setAccessible(null, false);
+    Method[] methodsArray = clazz.getMethods();
+    int nbMethod;
+    for ( nbMethod = 0; nbMethod < methodsArray.length; nbMethod++ ) {
+      methodsArray[nbMethod].setAccessible(false);
+    }
+
+      // Possible call to forbidden PrivilegedAction
+    PrivilegedAction priv = (PrivilegedAction) new Object(); priv.run();
+  }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidAssertAsIdentifier"
+          language="java"
+          since="3.4"
+          message="Avoid using assert as an identifier; it became a reserved word in JDK 1.4"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidassertasidentifier">
+        <description>
+            Use of the term 'assert' will conflict with newer versions of Java since it is a reserved word.
+        </description>
+        <priority>2</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>//VariableDeclaratorId[@Name='assert']</value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class A {
+    public class Foo {
+        String assert = "foo";
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidBranchingStatementAsLastInLoop"
+          language="java"
+          since="5.0"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AvoidBranchingStatementAsLastInLoopRule"
+          message="Avoid using a branching statement as the last in a loop."
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidbranchingstatementaslastinloop">
+        <description>
+            Using a branching statement as the last part of a loop may be a bug, and/or is confusing.
+            Ensure that the usage is not a bug, or consider using another approach.
+        </description>
+        <priority>2</priority>
+        <example>
+            <![CDATA[
+// unusual use of branching statement in a loop
+for (int i = 0; i < 10; i++) {
+    if (i*i <= 25) {
+        continue;
+    }
+    break;
+}
+
+// this makes more sense...
+for (int i = 0; i < 10; i++) {
+    if (i*i > 25) {
+        break;
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidCallingFinalize"
+          language="java"
+          since="3.0"
+          message="Avoid calling finalize() explicitly"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AvoidCallingFinalizeRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidcallingfinalize">
+        <description>
+            The method Object.finalize() is called by the garbage collector on an object when garbage collection determines
+            that there are no more references to the object. It should not be invoked by application logic.
+
+            Note that Oracle has declared Object.finalize() as deprecated since JDK 9.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+void foo() {
+    Bar b = new Bar();
+    b.finalize();
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidCatchingNPE"
+          language="java"
+          since="1.8"
+          message="Avoid catching NullPointerException; consider removing the cause of the NPE."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidcatchingnpe">
+        <description>
+            Code should never throw NullPointerExceptions under normal circumstances.  A catch block may hide the
+            original error, causing other, more subtle problems later on.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//CatchStatement/FormalParameter/Type
+ /ReferenceType/ClassOrInterfaceType[@Image='NullPointerException']
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo {
+    void bar() {
+        try {
+            // do something
+        } catch (NullPointerException npe) {
+        }
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidCatchingThrowable"
+          language="java"
+          since="1.2"
+          message="A catch statement should never catch throwable since it includes errors."
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AvoidCatchingThrowableRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidcatchingthrowable">
+        <description>
+            Catching Throwable errors is not recommended since its scope is very broad. It includes runtime issues such as
+            OutOfMemoryError that should be exposed and managed separately.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public void bar() {
+    try {
+        // do something
+    } catch (Throwable th) {  // should not catch Throwable
+        th.printStackTrace();
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidDecimalLiteralsInBigDecimalConstructor"
+          language="java"
+          since="3.4"
+          message="Avoid creating BigDecimal with a decimal (float/double) literal. Use a String literal"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoiddecimalliteralsinbigdecimalconstructor">
+        <description>
+            One might assume that the result of "new BigDecimal(0.1)" is exactly equal to 0.1, but it is actually
+            equal to .1000000000000000055511151231257827021181583404541015625.
+            This is because 0.1 cannot be represented exactly as a double (or as a binary fraction of any finite
+            length). Thus, the long value that is being passed in to the constructor is not exactly equal to 0.1,
+            appearances notwithstanding.
+
+            The (String) constructor, on the other hand, is perfectly predictable: 'new BigDecimal("0.1")' is
+            exactly equal to 0.1, as one would expect.  Therefore, it is generally recommended that the
+            (String) constructor be used in preference to this one.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//AllocationExpression[pmd-java:typeIs('java.math.BigDecimal')]
+[Arguments/ArgumentList/Expression/PrimaryExpression
+    [
+        pmd-java:typeIs('float') or
+        pmd-java:typeIs('java.lang.Float') or
+        pmd-java:typeIs('double') or
+        pmd-java:typeIs('java.lang.Double')
+    ]
+]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+BigDecimal bd = new BigDecimal(1.123);       // loss of precision, this would trigger the rule
+
+BigDecimal bd = new BigDecimal("1.123");     // preferred approach
+
+BigDecimal bd = new BigDecimal(12);          // preferred approach, ok for integer values
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidDuplicateLiterals"
+          language="java"
+          since="1.0"
+          message="The String literal {0} appears {1} times in this file; the first occurrence is on line {2}"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AvoidDuplicateLiteralsRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidduplicateliterals">
+        <description>
+            Code containing duplicate String literals can usually be improved by declaring the String as a constant field.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+private void bar() {
+     buz("Howdy");
+     buz("Howdy");
+     buz("Howdy");
+     buz("Howdy");
+}
+private void buz(String x) {}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidEnumAsIdentifier"
+          language="java"
+          since="3.4"
+          message="Avoid using enum as an identifier; it's a reserved word in JDK 1.5"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidenumasidentifier">
+        <description>
+            Use of the term 'enum' will conflict with newer versions of Java since it is a reserved word.
+        </description>
+        <priority>2</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>//VariableDeclaratorId[@Name='enum']</value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class A {
+    public class Foo {
+        String enum = "foo";
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidFieldNameMatchingMethodName"
+          language="java"
+          since="3.0"
+          message="Field {0} has the same name as a method"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AvoidFieldNameMatchingMethodNameRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidfieldnamematchingmethodname">
+        <description>
+            It can be confusing to have a field name with the same name as a method. While this is permitted,
+            having information (field) and actions (method) is not clear naming. Developers versed in
+            Smalltalk often prefer this approach as the methods denote accessor methods.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class Foo {
+    Object bar;
+    // bar is data or an action or both?
+    void bar() {
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidFieldNameMatchingTypeName"
+          language="java"
+          since="3.0"
+          message="It is somewhat confusing to have a field name matching the declaring class name"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AvoidFieldNameMatchingTypeNameRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidfieldnamematchingtypename">
+        <description>
+            It is somewhat confusing to have a field name matching the declaring type name.
+            This probably means that type and/or field names should be chosen more carefully.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class Foo extends Bar {
+    int foo;    // There is probably a better name that can be used
+}
+public interface Operation {
+    int OPERATION = 1; // There is probably a better name that can be used
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidInstanceofChecksInCatchClause"
+          language="java"
+          since="3.0"
+          message="An instanceof check is being performed on the caught exception.  Create a separate catch clause for this exception type."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidinstanceofchecksincatchclause">
+        <description>
+            Each caught exception type should be handled in its own catch clause.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//CatchStatement/FormalParameter
+ /following-sibling::Block//InstanceOfExpression/PrimaryExpression/PrimaryPrefix
+  /Name[
+   @Image = ./ancestor::Block/preceding-sibling::FormalParameter
+    /VariableDeclaratorId/@Name
+  ]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+try { // Avoid this
+    // do something
+} catch (Exception ee) {
+    if (ee instanceof IOException) {
+        cleanup();
+    }
+}
+
+try {  // Prefer this:
+    // do something
+} catch (IOException ee) {
+    cleanup();
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidLiteralsInIfCondition"
+          language="java"
+          since="4.2.6"
+          message="Avoid using Literals in Conditional Statements"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidliteralsinifcondition">
+        <description>
+            Avoid using hard-coded literals in conditional statements. By declaring them as static variables
+            or private members with descriptive names maintainability is enhanced. By default, the literals "-1" and "0" are ignored.
+            More exceptions can be defined with the property "ignoreMagicNumbers".
+
+            The rule doesn't consider deeper expressions by default, but this can be enabled via the property `ignoreExpressions`.
+            With this property set to false, if-conditions like `i == 1 + 5` are reported as well. Note that in that case,
+            the property ignoreMagicNumbers is not taken into account, if there are multiple literals involved in such an expression.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="ignoreMagicNumbers"
+                      description="Comma-separated list of magic numbers, that should be ignored"
+                      type="String" value="-1,0"/>
+            <property name="ignoreExpressions"
+                      description="If true, only literals in simple if conditions are considered. Otherwise literals in expressions are checked, too."
+                      type="Boolean" value="true"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+(: simple case - no deep expressions :)
+//IfStatement[$ignoreExpressions = true()]/Expression/*/PrimaryExpression/PrimaryPrefix/Literal
+    [not(NullLiteral)]
+    [not(BooleanLiteral)]
+    [empty(index-of(tokenize($ignoreMagicNumbers, '\s*,\s*'), @Image))]
+|
+(: consider also deeper expressions :)
+//IfStatement[$ignoreExpressions = false()]/Expression//*[local-name() != 'UnaryExpression' or @Operator != '-']/PrimaryExpression/PrimaryPrefix/Literal
+    [not(NullLiteral)]
+    [not(BooleanLiteral)]
+    [empty(index-of(tokenize($ignoreMagicNumbers, '\s*,\s*'), @Image))]
+|
+(: consider negative literals :)
+//IfStatement[$ignoreExpressions = false()]/Expression//UnaryExpression[@Operator = '-']/PrimaryExpression/PrimaryPrefix/Literal
+    [not(NullLiteral)]
+    [not(BooleanLiteral)]
+    [empty(index-of(tokenize($ignoreMagicNumbers, '\s*,\s*'), concat('-', @Image)))]
+|
+(: consider multiple literals in expressions :)
+//IfStatement[$ignoreExpressions = false()]/Expression[count(*/PrimaryExpression/PrimaryPrefix/Literal
+    [not(NullLiteral)]
+    [not(BooleanLiteral)]) > 1]
+]]>
+                </value>
+            </property>
+            <property name="version" value="2.0"/>
+        </properties>
+        <example>
+            <![CDATA[
+private static final int MAX_NUMBER_OF_REQUESTS = 10;
+
+public void checkRequests() {
+
+    if (i == 10) {                        // magic number, buried in a method
+      doSomething();
+    }
+
+    if (i == MAX_NUMBER_OF_REQUESTS) {    // preferred approach
+      doSomething();
+    }
+
+    if (aString.indexOf('.') != -1) {}     // magic number -1, by default ignored
+    if (aString.indexOf('.') >= 0) { }     // alternative approach
+
+    if (aDouble > 0.0) {}                  // magic number 0.0
+    if (aDouble >= Double.MIN_VALUE) {}    // preferred approach
+
+    // with rule property "ignoreExpressions" set to "false"
+    if (i == pos + 5) {}  // violation: magic number 5 within an (additive) expression
+    if (i == pos + SUFFIX_LENGTH) {} // preferred approach
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidLosingExceptionInformation"
+          since="4.2.6"
+          language="java"
+          message="Avoid statements in a catch block that invoke accessors on the exception without using the information"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidlosingexceptioninformation">
+        <description>
+            Statements in a catch block that invoke accessors on the exception without using the information
+            only add to code size.  Either remove the invocation, or use the return result.
+        </description>
+        <priority>2</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//CatchStatement/Block/BlockStatement/Statement/StatementExpression/PrimaryExpression/PrimaryPrefix/Name
+[
+   @Image = concat(../../../../../../../FormalParameter/VariableDeclaratorId/@Name, '.getMessage')
+   or
+   @Image = concat(../../../../../../../FormalParameter/VariableDeclaratorId/@Name, '.getLocalizedMessage')
+   or
+   @Image = concat(../../../../../../../FormalParameter/VariableDeclaratorId/@Name, '.getCause')
+   or
+   @Image = concat(../../../../../../../FormalParameter/VariableDeclaratorId/@Name, '.getStackTrace')
+   or
+   @Image = concat(../../../../../../../FormalParameter/VariableDeclaratorId/@Name, '.toString')
+]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public void bar() {
+    try {
+        // do something
+    } catch (SomeException se) {
+        se.getMessage();
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidMultipleUnaryOperators"
+          language="java"
+          since="4.2"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AvoidMultipleUnaryOperatorsRule"
+          message="Using multiple unary operators may be a bug, and/or is confusing."
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidmultipleunaryoperators">
+        <description>
+            The use of multiple unary operators may be problematic, and/or confusing.
+            Ensure that the intended usage is not a bug, or consider simplifying the expression.
+        </description>
+        <priority>2</priority>
+        <example>
+            <![CDATA[
+// These are typo bugs, or at best needlessly complex and confusing:
+int i = - -1;
+int j = + - +1;
+int z = ~~2;
+boolean b = !!true;
+boolean c = !!!true;
+
+// These are better:
+int i = 1;
+int j = -1;
+int z = 2;
+boolean b = true;
+boolean c = false;
+
+// And these just make your brain hurt:
+int i = ~-2;
+int j = -~7;
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidUsingOctalValues"
+          language="java"
+          since="3.9"
+          message="Do not start a literal by 0 unless it's an octal value"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AvoidUsingOctalValuesRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidusingoctalvalues">
+        <description>
+            Integer literals should not start with zero since this denotes that the rest of literal will be
+            interpreted as an octal value.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+int i = 012;    // set i with 10 not 12
+int j = 010;    // set j with 8 not 10
+k = i * j;      // set k with 80 not 120
+]]>
+        </example>
+    </rule>
+
+    <rule name="BadComparison" ref="ComparisonWithNaN" deprecated="true" />
+
+    <rule name="BeanMembersShouldSerialize"
+          language="java"
+          since="1.1"
+          message="Found non-transient, non-static member. Please mark as transient or provide accessors."
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.BeanMembersShouldSerializeRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#beanmembersshouldserialize">
+        <description>
+            If a class is a bean, or is referenced by a bean directly or indirectly it needs to be serializable.
+            Member variables need to be marked as transient, static, or have accessor methods in the class. Marking
+            variables as transient is the safest and easiest modification. Accessor methods should follow the Java
+            naming conventions, i.e. for a variable named foo, getFoo() and setFoo() accessor methods should be provided.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+private transient int someFoo;  // good, it's transient
+private static int otherFoo;    // also OK
+private int moreFoo;            // OK, has proper accessors, see below
+private int badFoo;             // bad, should be marked transient
+
+private void setMoreFoo(int moreFoo){
+      this.moreFoo = moreFoo;
+}
+
+private int getMoreFoo(){
+      return this.moreFoo;
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="BrokenNullCheck"
+          language="java"
+          since="3.8"
+          message="Method call on object which may be null"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.BrokenNullCheckRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#brokennullcheck">
+        <description>
+            The null check is broken since it will throw a NullPointerException itself.
+            It is likely that you used || instead of &amp;&amp; or vice versa.
+        </description>
+        <priority>2</priority>
+        <example>
+            <![CDATA[
+public String bar(String string) {
+  // should be &&
+    if (string!=null || !string.equals(""))
+        return string;
+  // should be ||
+    if (string==null && string.equals(""))
+        return string;
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="CallSuperFirst"
+          since="4.2.5"
+          language="java"
+          message="super should be called at the start of the method"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#callsuperfirst">
+        <description>Super should be called at the start of the method</description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//MethodDeclaration[
+  @Name='onCreate' or
+  @Name='onConfigurationChanged' or
+  @Name='onPostCreate' or
+  @Name='onPostResume' or
+  @Name='onRestart' or
+  @Name='onRestoreInstanceState' or
+  @Name='onResume' or
+  @Name='onStart'
+  ]
+    /Block[not(
+      (BlockStatement[1]/Statement/StatementExpression/PrimaryExpression[./PrimaryPrefix[@SuperModifier= true()]]/PrimarySuffix[@Image= ancestor::MethodDeclaration/@Name]))]
+[ancestor::ClassOrInterfaceDeclaration[ExtendsList/ClassOrInterfaceType[
+  pmd-java:typeIs('android.app.Activity') or
+  pmd-java:typeIs('android.app.Application') or
+  pmd-java:typeIs('android.app.Service')
+]]]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class DummyActivity extends Activity {
+    public void onCreate(Bundle bundle) {
+        // missing call to super.onCreate(bundle)
+        foo();
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="CallSuperLast"
+          since="4.2.5"
+          language="java"
+          message="super should be called at the end of the method"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#callsuperlast">
+        <description>
+            Super should be called at the end of the method
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//MethodDeclaration[
+  @Name='finish' or
+  @Name='onDestroy' or
+  @Name='onPause' or
+  @Name='onSaveInstanceState' or
+  @Name='onStop' or
+  @Name='onTerminate'
+  ]
+   /Block/BlockStatement[last()]
+    [not(Statement/StatementExpression/PrimaryExpression[./PrimaryPrefix[@SuperModifier= true()]]/PrimarySuffix[@Image= ancestor::MethodDeclaration/@Name])]
+[ancestor::ClassOrInterfaceDeclaration[ExtendsList/ClassOrInterfaceType[
+  pmd-java:typeIs('android.app.Activity') or
+  pmd-java:typeIs('android.app.Application') or
+  pmd-java:typeIs('android.app.Service')
+]]]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class DummyActivity extends Activity {
+    public void onPause() {
+        foo();
+        // missing call to super.onPause()
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="CheckSkipResult"
+          language="java"
+          since="5.0"
+          message="Check the value returned by the skip() method of an InputStream to see if the requested number of bytes has been skipped."
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.CheckSkipResultRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#checkskipresult">
+        <description>
+            The skip() method may skip a smaller number of bytes than requested. Check the returned value to find out if it was the case or not.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class Foo {
+
+   private FileInputStream _s = new FileInputStream("file");
+
+   public void skip(int n) throws IOException {
+      _s.skip(n); // You are not sure that exactly n bytes are skipped
+   }
+
+   public void skipExactly(int n) throws IOException {
+      while (n != 0) {
+         long skipped = _s.skip(n);
+         if (skipped == 0)
+            throw new EOFException();
+         n -= skipped;
+      }
+   }
+]]>
+        </example>
+    </rule>
+
+    <rule name="ClassCastExceptionWithToArray"
+          language="java"
+          since="3.4"
+          message="This usage of the Collection.toArray() method will throw a ClassCastException."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#classcastexceptionwithtoarray">
+        <description>
+            When deriving an array of a specific class from your Collection, one should provide an array of
+            the same class as the parameter of the toArray() method. Doing otherwise you will will result
+            in a ClassCastException.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//CastExpression[Type/ReferenceType/ClassOrInterfaceType[@Image != "Object"]]
+    /PrimaryExpression
+    [PrimaryPrefix/Name[ends-with(@Image, '.toArray')]]
+    [PrimarySuffix/Arguments[not(*)]]
+    [count(PrimarySuffix) = 1]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+Collection c = new ArrayList();
+Integer obj = new Integer(1);
+c.add(obj);
+
+    // this would trigger the rule (and throw a ClassCastException if executed)
+Integer[] a = (Integer [])c.toArray();
+
+   // this is fine and will not trigger the rule
+Integer[] b = (Integer [])c.toArray(new Integer[c.size()]);
+]]>
+        </example>
+    </rule>
+
+    <rule name="CloneMethodMustBePublic"
+          language="java"
+          since="5.4.0"
+          message="clone() method must be public if the class implements Cloneable"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#clonemethodmustbepublic">
+        <description>
+            The java Manual says "By convention, classes that implement this interface should override
+            Object.clone (which is protected) with a public method."
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//MethodDeclaration[@Public= false()]
+  [@Name = 'clone']
+  [@Arity = 0]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo implements Cloneable {
+    @Override
+    protected Object clone() throws CloneNotSupportedException { // Violation, must be public
+    }
+}
+
+public class Foo implements Cloneable {
+    @Override
+    protected Foo clone() { // Violation, must be public
+    }
+}
+
+public class Foo implements Cloneable {
+    @Override
+    public Object clone() // Ok
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="CloneMethodMustImplementCloneable"
+          language="java"
+          since="1.9"
+          message="clone() method should be implemented only if implementing Cloneable interface"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.CloneMethodMustImplementCloneableRule"
+          typeResolution="true"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#clonemethodmustimplementcloneable">
+        <description>
+            The method clone() should only be implemented if the class implements the Cloneable interface with the exception of
+            a final method that only throws CloneNotSupportedException.
+
+            The rule can also detect, if the class implements or extends a Cloneable class.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class MyClass {
+ public Object clone() throws CloneNotSupportedException {
+  return foo;
+ }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="CloneMethodReturnTypeMustMatchClassName"
+          language="java"
+          minimumLanguageVersion="1.5"
+          since="5.4.0"
+          message="The return type of the clone() method must be the class name when implements Cloneable"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#clonemethodreturntypemustmatchclassname">
+        <description>
+            If a class implements cloneable the return type of the method clone() must be the class name. That way, the caller
+            of the clone method doesn't need to cast the returned clone to the correct type.
+
+            Note: This is only possible with Java 1.5 or higher.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//MethodDeclaration
+[
+@Name = 'clone'
+and @Arity = 0
+and not (ResultType//ClassOrInterfaceType/@Image = ancestor::ClassOrInterfaceDeclaration[1]/@SimpleName)
+]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo implements Cloneable {
+    @Override
+    protected Object clone() { // Violation, Object must be Foo
+    }
+}
+
+public class Foo implements Cloneable {
+    @Override
+    public Foo clone() { //Ok
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="CloneThrowsCloneNotSupportedException"
+          deprecated="true"
+          language="java"
+          since="1.9"
+          message="clone() method should throw CloneNotSupportedException"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#clonethrowsclonenotsupportedexception">
+        <description>
+            The method clone() should throw a CloneNotSupportedException.
+
+            This rule is deprecated since PMD 6.35.0 without replacement. The rule has no real value as
+            `CloneNotSupportedException` is a checked exception and therefore you need to deal with it while
+            implementing the `clone()` method. You either need to declare the exception or catch it. If you catch it,
+            then subclasses can't throw it themselves explicitly. However, `Object.clone()` will still throw this
+            exception if the `Cloneable` interface is not implemented.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//MethodDeclaration
+[
+@Name = 'clone'
+and @Arity = 0
+and count(NameList/Name[contains
+(@Image,'CloneNotSupportedException')]) = 0
+]
+[
+../../../../ClassOrInterfaceDeclaration[@Final = false()]
+]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class MyClass implements Cloneable{
+    public Object clone() { // will cause an error
+         MyClass clone = (MyClass)super.clone();
+         return clone;
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="CloseResource"
+          language="java"
+          since="1.2.2"
+          message="Ensure that resources like this {0} object are closed after use"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.CloseResourceRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#closeresource">
+        <description>
+            Ensure that resources (like `java.sql.Connection`, `java.sql.Statement`, and `java.sql.ResultSet` objects
+            and any subtype of `java.lang.AutoCloseable`) are always closed after use.
+            Failing to do so might result in resource leaks.
+
+            Note: It suffices to configure the super type, e.g. `java.lang.AutoClosable`, so that this rule automatically triggers
+            on any subtype (e.g. `java.io.FileInputStream`). Additionally specifying `java.sql.Connection` helps in detecting
+            the types, if the type resolution / auxclasspath is not correctly setup.
+
+            Note: Since PMD 6.16.0 the default value for the property `types` contains `java.lang.AutoCloseable` and detects
+            now cases where the standard `java.io.*Stream` classes are involved. In order to restore the old behaviour,
+            just remove "AutoCloseable" from the types.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class Bar {
+    public void withSQL() {
+        Connection c = pool.getConnection();
+        try {
+            // do stuff
+        } catch (SQLException ex) {
+           // handle exception
+        } finally {
+            // oops, should close the connection using 'close'!
+            // c.close();
+        }
+    }
+
+    public void withFile() {
+        InputStream file = new FileInputStream(new File("/tmp/foo"));
+        try {
+            int c = file.in();
+        } catch (IOException e) {
+            // handle exception
+        } finally {
+            // TODO: close file
+        }
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="CompareObjectsWithEquals"
+          language="java"
+          since="3.2"
+          message="Use equals() to compare object references."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#compareobjectswithequals">
+        <description>
+            Use `equals()` to compare object references; avoid comparing them with `==`.
+
+            Since comparing objects with named constants is useful in some cases (eg, when
+            defining constants for sentinel values), the rule ignores comparisons against
+            fields with all-caps name (eg `this == SENTINEL`), which is a common naming
+            convention for constant fields.
+
+            You may allow some types to be compared by reference by listing the exceptions
+            in the `typesThatCompareByReference` property.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="typesThatCompareByReference" type="List[String]" delimiter="," description="List of canonical type names for which reference comparison is allowed.">
+                <value>java.lang.Enum,java.lang.Class</value>
+            </property>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//EqualityExpression
+    [count(
+        PrimaryExpression[pmd-java:typeIs('java.lang.Object')]
+        [not(some $t in $typesThatCompareByReference satisfies pmd-java:typeIs($t))]
+       ) = 2
+    ]
+    [not(PrimaryExpression[PrimaryPrefix/@ThisModifier = true()]
+                          [not(PrimarySuffix)]
+                          [ancestor::MethodDeclaration[@Name = 'equals']])
+    ]
+    (: Is not a field access with an all-caps identifier :)
+    [not(PrimaryExpression[not(PrimarySuffix) and PrimaryPrefix/Name[upper-case(@Image)=@Image]
+     or PrimaryExpression/PrimarySuffix[last()][upper-case(@Image)=@Image]])]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+class Foo {
+  boolean bar(String a, String b) {
+    return a == b;
+  }
+}
+
+]]>
+        </example>
+    </rule>
+
+    <rule name="ComparisonWithNaN"
+          language="java"
+          since="6.36.0"
+          message="Comparisons with NaN always return false"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#comparisonwithnan">
+        <description><![CDATA[
+            Reports comparisons with double and float `NaN` (Not-a-Number) values.
+            These are [specified](https://docs.oracle.com/javase/specs/jls/se8/html/jls-15.html#jls-15.21.1)
+            to have unintuitive behavior: NaN is considered unequal to itself.
+            This means a check like `someDouble == Double.NaN` will always return
+            false, even if `someDouble` is really the NaN value. To test whether a
+            value is the NaN value, one should instead use `Double.isNaN(someDouble)`
+            (or `Float.isNaN`). The `!=` operator should be treated similarly.
+            Finally, comparisons like `someDouble <= Double.NaN` are nonsensical
+            and will always evaluate to false.
+
+            This rule has been renamed from "BadComparison" with PMD 6.36.0.
+        ]]></description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+(//EqualityExpression | //RelationalExpression)/PrimaryExpression/PrimaryPrefix/Name[@Image='Double.NaN' or @Image='Float.NaN']
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+boolean x = (y == Double.NaN);
+]]>
+        </example>
+    </rule>
+
+
+    <rule name="ConstructorCallsOverridableMethod"
+          language="java"
+          since="1.04"
+          message="Overridable {0} called during object construction"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.ConstructorCallsOverridableMethodRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#constructorcallsoverridablemethod">
+        <description>
+            Calling overridable methods during construction poses a risk of invoking methods on an incompletely
+            constructed object and can be difficult to debug.
+            It may leave the sub-class unable to construct its superclass or forced to replicate the construction
+            process completely within itself, losing the ability to call super().  If the default constructor
+            contains a call to an overridable method, the subclass may be completely uninstantiable.   Note that
+            this includes method calls throughout the control flow graph - i.e., if a constructor Foo() calls a
+            private method bar() that calls a public method buz(), this denotes a problem.
+        </description>
+        <priority>1</priority>
+        <example>
+            <![CDATA[
+public class SeniorClass {
+  public SeniorClass(){
+      toString(); //may throw NullPointerException if overridden
+  }
+  public String toString(){
+    return "IAmSeniorClass";
+  }
+}
+public class JuniorClass extends SeniorClass {
+  private String name;
+  public JuniorClass(){
+    super(); //Automatic call leads to NullPointerException
+    name = "JuniorClass";
+  }
+  public String toString(){
+    return name.toUpperCase();
+  }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="DataflowAnomalyAnalysis"
+          language="java"
+          since="3.9"
+          message="Found ''{0}''-anomaly for variable ''{1}'' (lines ''{2}''-''{3}'')."
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.DataflowAnomalyAnalysisRule"
+          dfa="true"
+          deprecated="true"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#dataflowanomalyanalysis">
+        <description>The dataflow analysis tracks local definitions, undefinitions and references to variables on different paths on the data flow.
+            From those informations there can be found various problems.
+
+            1. DU - Anomaly: A recently defined variable is undefined. These anomalies may appear in normal source text.
+            2. DD - Anomaly: A recently defined variable is redefined. This is ominous but don't have to be a bug.
+
+            This rule is deprecated. Use {% rule "java/bestpractices/UnusedAssignment" %} in category bestpractices instead.
+        </description>
+        <priority>5</priority>
+        <example>
+            <![CDATA[
+public void foo() {
+  int buz = 5;
+  buz = 6; // redefinition of buz -> dd-anomaly
+  foo(buz);
+  buz = 2;
+} // buz is undefined when leaving scope -> du-anomaly
+]]>
+        </example>
+    </rule>
+
+    <rule name="DetachedTestCase"
+          language="java"
+          since="6.13.0"
+          message="Probable detached JUnit test case."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          typeResolution="true"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#detachedtestcase">
+        <description>
+            The method appears to be a test case since it has public or default visibility,
+            non-static access, no arguments, no return value, has no annotations, but is a
+            member of a class that has one or more JUnit test cases. If it is a utility
+            method, it should likely have private visibility. If it is an ignored test, it
+            should be annotated with @Test and @Ignore.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value><![CDATA[
+//ClassOrInterfaceBodyDeclaration
+[../ClassOrInterfaceBodyDeclaration/Annotation/*/Name
+        [pmd-java:typeIs('org.junit.Test')
+         or pmd-java:typeIs('org.junit.jupiter.api.Test')
+         or pmd-java:typeIs('org.junit.jupiter.api.RepeatedTest')
+         or pmd-java:typeIs('org.junit.jupiter.api.TestFactory')
+         or pmd-java:typeIs('org.junit.jupiter.api.TestTemplate')
+         or pmd-java:typeIs('org.junit.jupiter.params.ParameterizedTest')]
+]
+[not(Annotation)]
+[MethodDeclaration[(@Public = true() or @PackagePrivate = true()) and @Static = false() and
+        ResultType[@Void = true()] and
+        MethodDeclarator/FormalParameters[@Size = 0]
+    ]
+]
+]]></value>
+            </property>
+            <property name="version" value="2.0" />
+        </properties>
+        <example>
+            <![CDATA[
+public class MyTest {
+    @Test
+    public void someTest() {
+    }
+
+    // violation: Not annotated
+    public void someOtherTest () {
+    }
+
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="DoNotCallGarbageCollectionExplicitly"
+          language="java"
+          since="4.2"
+          message="Do not explicitly trigger a garbage collection."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#donotcallgarbagecollectionexplicitly">
+        <description>
+            Calls to System.gc(), Runtime.getRuntime().gc(), and System.runFinalization() are not advised. Code should have the
+            same behavior whether the garbage collection is disabled using the option -Xdisableexplicitgc or not.
+            Moreover, "modern" jvms do a very good job handling garbage collections. If memory usage issues unrelated to memory
+            leaks develop within an application, it should be dealt with JVM options rather than within the code itself.
+        </description>
+        <priority>2</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//Name[
+(starts-with(@Image, 'System.') and
+(starts-with(@Image, 'System.gc') or
+starts-with(@Image, 'System.runFinalization'))) or
+(
+starts-with(@Image,'Runtime.getRuntime') and
+../../PrimarySuffix[ends-with(@Image,'gc')]
+)
+]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class GCCall {
+    public GCCall() {
+        // Explicit gc call !
+        System.gc();
+    }
+
+    public void doSomething() {
+        // Explicit gc call !
+        Runtime.getRuntime().gc();
+    }
+
+    public explicitGCcall() {
+        // Explicit gc call !
+        System.gc();
+    }
+
+    public void doSomething() {
+        // Explicit gc call !
+        Runtime.getRuntime().gc();
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="DoNotCallSystemExit" ref="category/java/errorprone.xml/DoNotTerminateVM" deprecated="true" />
+
+    <rule name="DoNotExtendJavaLangThrowable"
+          language="java"
+          since="6.0.0"
+          message="Exceptions should not extend java.lang.Throwable"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#donotextendjavalangthrowable">
+        <description>
+            Extend Exception or RuntimeException instead of Throwable.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//ClassOrInterfaceDeclaration/ExtendsList/ClassOrInterfaceType
+  [@Image="Throwable" or @Image="java.lang.Throwable"]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo extends Throwable { }
+]]>
+        </example>
+    </rule>
+
+    <rule name="DoNotHardCodeSDCard"
+          since="4.2.6"
+          language="java"
+          message="Do not hardcode /sdcard."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#donothardcodesdcard">
+        <description>
+            Use Environment.getExternalStorageDirectory() instead of "/sdcard"
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>//Literal[starts-with(@Image,'"/sdcard')]</value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class MyActivity extends Activity {
+    protected void foo() {
+        String storageLocation = "/sdcard/mypackage";   // hard-coded, poor approach
+
+       storageLocation = Environment.getExternalStorageDirectory() + "/mypackage"; // preferred approach
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="DoNotTerminateVM"
+          language="java"
+          since="4.1"
+          message="System.exit() should not be used in J2EE/JEE apps"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#donotterminatevm">
+        <description>
+            Web applications should not call `System.exit()`, since only the web container or the
+            application server should stop the JVM. Otherwise a web application would terminate all other applications
+            running on the same application server.
+
+            This rule also checks for the equivalent calls `Runtime.getRuntime().exit()` and `Runtime.getRuntime().halt()`.
+
+            This rule was called *DoNotCallSystemExit* until PMD 6.29.0.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//Name[
+    starts-with(@Image,'System.exit')
+    or
+    (starts-with(@Image,'Runtime.getRuntime') and ../../PrimarySuffix[ends-with(@Image,'exit') or ends-with(@Image,'halt')])
+][not(ancestor::MethodDeclaration[1][@Name="main" and @Static = true()])]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public void bar() {
+    System.exit(0);                 // never call this when running in an application server!
+}
+public void foo() {
+    Runtime.getRuntime().exit(0);   // never stop the JVM manually, the container will do this.
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="DoNotThrowExceptionInFinally"
+          language="java"
+          since="4.2"
+          message="A throw statement in a finally block makes the control flow hard to understand."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#donotthrowexceptioninfinally">
+        <description>
+            Throwing exceptions within a 'finally' block is confusing since they may mask other exceptions
+            or code defects.
+            Note: This is a PMD implementation of the Lint4j rule "A throw in a finally block"
+        </description>
+        <priority>4</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>//FinallyStatement[descendant::ThrowStatement]</value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo {
+    public void bar() {
+        try {
+            // Here do some stuff
+        } catch( Exception e) {
+            // Handling the issue
+        } finally {
+            // is this really a good idea ?
+            throw new Exception();
+        }
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="DontImportSun"
+          language="java"
+          since="1.5"
+          message="Avoid importing anything from the 'sun.*' packages"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.DontImportSunRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#dontimportsun">
+        <description>
+            Avoid importing anything from the 'sun.*' packages.  These packages are not portable and are likely to change.
+        </description>
+        <priority>4</priority>
+        <example>
+            <![CDATA[
+import sun.misc.foo;
+public class Foo {}
+]]>
+        </example>
+    </rule>
+
+    <rule name="DontUseFloatTypeForLoopIndices"
+          language="java"
+          since="4.3"
+          message="Don't use floating point for loop indices. If you must use floating point, use double."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#dontusefloattypeforloopindices">
+        <description>
+            Don't use floating point for loop indices. If you must use floating point, use double
+            unless you're certain that float provides enough precision and you have a compelling
+            performance need (space or time).
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//ForStatement/ForInit/LocalVariableDeclaration
+/Type/PrimitiveType[@Image="float"]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Count {
+  public static void main(String[] args) {
+    final int START = 2000000000;
+    int count = 0;
+    for (float f = START; f < START + 50; f++)
+      count++;
+      //Prints 0 because (float) START == (float) (START + 50).
+      System.out.println(count);
+      //The termination test misbehaves due to floating point granularity.
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="EmptyCatchBlock"
+          language="java"
+          since="0.1"
+          message="Avoid empty catch blocks"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#emptycatchblock">
+        <description>
+            Empty Catch Block finds instances where an exception is caught, but nothing is done.
+            In most circumstances, this swallows an exception which should either be acted on
+            or reported.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//CatchStatement
+ [not(Block/BlockStatement)]
+ [$allowCommentedBlocks != true() or Block/@containsComment = false()]
+ [FormalParameter/Type/ReferenceType
+   /ClassOrInterfaceType[@Image != 'InterruptedException' and @Image != 'CloneNotSupportedException']
+ ]
+ [FormalParameter/VariableDeclaratorId[not(matches(@Name, $allowExceptionNameRegex))]]
+]]>
+                </value>
+            </property>
+            <property name="allowCommentedBlocks" type="Boolean" description="Empty blocks containing comments will be skipped" value="false"/>
+            <property name="allowExceptionNameRegex" type="String" description="Empty blocks catching exceptions with names matching this regular expression will be skipped" value="^(ignored|expected)$"/>
+        </properties>
+        <example>
+            <![CDATA[
+public void doSomething() {
+    try {
+        FileInputStream fis = new FileInputStream("/tmp/bugger");
+    } catch (IOException ioe) {
+        // not good
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="EmptyFinalizer"
+          language="java"
+          since="1.5"
+          message="Avoid empty finalize methods"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#emptyfinalizer">
+        <description>
+            Empty finalize methods serve no purpose and should be removed. Note that Oracle has declared Object.finalize() as deprecated since JDK 9.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//MethodDeclaration[@Name='finalize'][@Arity = 0]
+  /Block[not(*)]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo {
+   protected void finalize() {}
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="EmptyFinallyBlock"

Review comment:
       This rule is enabled in our repo

##########
File path: check-rules/errorprone.xml
##########
@@ -0,0 +1,3721 @@
+<?xml version="1.0"?>
+
+<ruleset name="Error Prone"
+         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 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">
+
+    <description>
+        Rules to detect constructs that are either broken, extremely confusing or prone to runtime errors.
+    </description>
+
+    <rule name="AssignmentInOperand"
+          language="java"
+          since="1.03"
+          message="Avoid assignments in operands"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AssignmentInOperandRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#assignmentinoperand">
+        <description>
+            Avoid assignments in operands; this can make code more complicated and harder to read.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public void bar() {
+    int x = 2;
+    if ((x = getX()) == 3) {
+      System.out.println("3!");
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AssignmentToNonFinalStatic"
+          language="java"
+          since="2.2"
+          message="Possible unsafe assignment to a non-final static field in a constructor."
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AssignmentToNonFinalStaticRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#assignmenttononfinalstatic">
+        <description>
+            Identifies a possible unsafe usage of a static field.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class StaticField {
+   static int x;
+   public FinalFields(int y) {
+    x = y; // unsafe
+   }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidAccessibilityAlteration"
+          language="java"
+          since="4.1"
+          message="You should not modify visibility of class or methods using getDeclaredConstructors(), getDeclaredConstructor(Class[]), setAccessible() or PrivilegedAction."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidaccessibilityalteration">
+        <description>
+            Methods such as getDeclaredConstructors(), getDeclaredConstructor(Class[]) and setAccessible(),
+            as the interface PrivilegedAction, allow for the runtime alteration of variable, class, or
+            method visibility, even if they are private. This violates the principle of encapsulation.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//PrimaryExpression[
+(
+(PrimarySuffix[
+        ends-with(@Image,'getDeclaredConstructors')
+                or
+        ends-with(@Image,'getDeclaredConstructor')
+                or
+        ends-with(@Image,'setAccessible')
+        ])
+or
+(PrimaryPrefix/Name[
+        ends-with(@Image,'getDeclaredConstructor')
+        or
+        ends-with(@Image,'getDeclaredConstructors')
+        or
+        starts-with(@Image,'AccessibleObject.setAccessible')
+        ])
+)
+and
+(//ImportDeclaration/Name[
+        contains(@Image,'java.security.PrivilegedAction')])
+]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Method;
+import java.security.PrivilegedAction;
+
+public class Violation {
+  public void invalidCallsInMethod() throws SecurityException, NoSuchMethodException {
+    // Possible call to forbidden getDeclaredConstructors
+    Class[] arrayOfClass = new Class[1];
+    this.getClass().getDeclaredConstructors();
+    this.getClass().getDeclaredConstructor(arrayOfClass);
+    Class clazz = this.getClass();
+    clazz.getDeclaredConstructor(arrayOfClass);
+    clazz.getDeclaredConstructors();
+      // Possible call to forbidden setAccessible
+    clazz.getMethod("", arrayOfClass).setAccessible(false);
+    AccessibleObject.setAccessible(null, false);
+    Method.setAccessible(null, false);
+    Method[] methodsArray = clazz.getMethods();
+    int nbMethod;
+    for ( nbMethod = 0; nbMethod < methodsArray.length; nbMethod++ ) {
+      methodsArray[nbMethod].setAccessible(false);
+    }
+
+      // Possible call to forbidden PrivilegedAction
+    PrivilegedAction priv = (PrivilegedAction) new Object(); priv.run();
+  }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidAssertAsIdentifier"
+          language="java"
+          since="3.4"
+          message="Avoid using assert as an identifier; it became a reserved word in JDK 1.4"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidassertasidentifier">
+        <description>
+            Use of the term 'assert' will conflict with newer versions of Java since it is a reserved word.
+        </description>
+        <priority>2</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>//VariableDeclaratorId[@Name='assert']</value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class A {
+    public class Foo {
+        String assert = "foo";
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidBranchingStatementAsLastInLoop"
+          language="java"
+          since="5.0"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AvoidBranchingStatementAsLastInLoopRule"
+          message="Avoid using a branching statement as the last in a loop."
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidbranchingstatementaslastinloop">
+        <description>
+            Using a branching statement as the last part of a loop may be a bug, and/or is confusing.
+            Ensure that the usage is not a bug, or consider using another approach.
+        </description>
+        <priority>2</priority>
+        <example>
+            <![CDATA[
+// unusual use of branching statement in a loop
+for (int i = 0; i < 10; i++) {
+    if (i*i <= 25) {
+        continue;
+    }
+    break;
+}
+
+// this makes more sense...
+for (int i = 0; i < 10; i++) {
+    if (i*i > 25) {
+        break;
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidCallingFinalize"
+          language="java"
+          since="3.0"
+          message="Avoid calling finalize() explicitly"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AvoidCallingFinalizeRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidcallingfinalize">
+        <description>
+            The method Object.finalize() is called by the garbage collector on an object when garbage collection determines
+            that there are no more references to the object. It should not be invoked by application logic.
+
+            Note that Oracle has declared Object.finalize() as deprecated since JDK 9.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+void foo() {
+    Bar b = new Bar();
+    b.finalize();
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidCatchingNPE"
+          language="java"
+          since="1.8"
+          message="Avoid catching NullPointerException; consider removing the cause of the NPE."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidcatchingnpe">
+        <description>
+            Code should never throw NullPointerExceptions under normal circumstances.  A catch block may hide the
+            original error, causing other, more subtle problems later on.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//CatchStatement/FormalParameter/Type
+ /ReferenceType/ClassOrInterfaceType[@Image='NullPointerException']
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo {
+    void bar() {
+        try {
+            // do something
+        } catch (NullPointerException npe) {
+        }
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidCatchingThrowable"
+          language="java"
+          since="1.2"
+          message="A catch statement should never catch throwable since it includes errors."
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AvoidCatchingThrowableRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidcatchingthrowable">
+        <description>
+            Catching Throwable errors is not recommended since its scope is very broad. It includes runtime issues such as
+            OutOfMemoryError that should be exposed and managed separately.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public void bar() {
+    try {
+        // do something
+    } catch (Throwable th) {  // should not catch Throwable
+        th.printStackTrace();
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidDecimalLiteralsInBigDecimalConstructor"
+          language="java"
+          since="3.4"
+          message="Avoid creating BigDecimal with a decimal (float/double) literal. Use a String literal"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoiddecimalliteralsinbigdecimalconstructor">
+        <description>
+            One might assume that the result of "new BigDecimal(0.1)" is exactly equal to 0.1, but it is actually
+            equal to .1000000000000000055511151231257827021181583404541015625.
+            This is because 0.1 cannot be represented exactly as a double (or as a binary fraction of any finite
+            length). Thus, the long value that is being passed in to the constructor is not exactly equal to 0.1,
+            appearances notwithstanding.
+
+            The (String) constructor, on the other hand, is perfectly predictable: 'new BigDecimal("0.1")' is
+            exactly equal to 0.1, as one would expect.  Therefore, it is generally recommended that the
+            (String) constructor be used in preference to this one.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//AllocationExpression[pmd-java:typeIs('java.math.BigDecimal')]
+[Arguments/ArgumentList/Expression/PrimaryExpression
+    [
+        pmd-java:typeIs('float') or
+        pmd-java:typeIs('java.lang.Float') or
+        pmd-java:typeIs('double') or
+        pmd-java:typeIs('java.lang.Double')
+    ]
+]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+BigDecimal bd = new BigDecimal(1.123);       // loss of precision, this would trigger the rule
+
+BigDecimal bd = new BigDecimal("1.123");     // preferred approach
+
+BigDecimal bd = new BigDecimal(12);          // preferred approach, ok for integer values
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidDuplicateLiterals"
+          language="java"
+          since="1.0"
+          message="The String literal {0} appears {1} times in this file; the first occurrence is on line {2}"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AvoidDuplicateLiteralsRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidduplicateliterals">
+        <description>
+            Code containing duplicate String literals can usually be improved by declaring the String as a constant field.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+private void bar() {
+     buz("Howdy");
+     buz("Howdy");
+     buz("Howdy");
+     buz("Howdy");
+}
+private void buz(String x) {}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidEnumAsIdentifier"
+          language="java"
+          since="3.4"
+          message="Avoid using enum as an identifier; it's a reserved word in JDK 1.5"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidenumasidentifier">
+        <description>
+            Use of the term 'enum' will conflict with newer versions of Java since it is a reserved word.
+        </description>
+        <priority>2</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>//VariableDeclaratorId[@Name='enum']</value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class A {
+    public class Foo {
+        String enum = "foo";
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidFieldNameMatchingMethodName"
+          language="java"
+          since="3.0"
+          message="Field {0} has the same name as a method"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AvoidFieldNameMatchingMethodNameRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidfieldnamematchingmethodname">
+        <description>
+            It can be confusing to have a field name with the same name as a method. While this is permitted,
+            having information (field) and actions (method) is not clear naming. Developers versed in
+            Smalltalk often prefer this approach as the methods denote accessor methods.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class Foo {
+    Object bar;
+    // bar is data or an action or both?
+    void bar() {
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidFieldNameMatchingTypeName"
+          language="java"
+          since="3.0"
+          message="It is somewhat confusing to have a field name matching the declaring class name"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AvoidFieldNameMatchingTypeNameRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidfieldnamematchingtypename">
+        <description>
+            It is somewhat confusing to have a field name matching the declaring type name.
+            This probably means that type and/or field names should be chosen more carefully.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class Foo extends Bar {
+    int foo;    // There is probably a better name that can be used
+}
+public interface Operation {
+    int OPERATION = 1; // There is probably a better name that can be used
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidInstanceofChecksInCatchClause"
+          language="java"
+          since="3.0"
+          message="An instanceof check is being performed on the caught exception.  Create a separate catch clause for this exception type."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidinstanceofchecksincatchclause">
+        <description>
+            Each caught exception type should be handled in its own catch clause.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//CatchStatement/FormalParameter
+ /following-sibling::Block//InstanceOfExpression/PrimaryExpression/PrimaryPrefix
+  /Name[
+   @Image = ./ancestor::Block/preceding-sibling::FormalParameter
+    /VariableDeclaratorId/@Name
+  ]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+try { // Avoid this
+    // do something
+} catch (Exception ee) {
+    if (ee instanceof IOException) {
+        cleanup();
+    }
+}
+
+try {  // Prefer this:
+    // do something
+} catch (IOException ee) {
+    cleanup();
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidLiteralsInIfCondition"
+          language="java"
+          since="4.2.6"
+          message="Avoid using Literals in Conditional Statements"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidliteralsinifcondition">
+        <description>
+            Avoid using hard-coded literals in conditional statements. By declaring them as static variables
+            or private members with descriptive names maintainability is enhanced. By default, the literals "-1" and "0" are ignored.
+            More exceptions can be defined with the property "ignoreMagicNumbers".
+
+            The rule doesn't consider deeper expressions by default, but this can be enabled via the property `ignoreExpressions`.
+            With this property set to false, if-conditions like `i == 1 + 5` are reported as well. Note that in that case,
+            the property ignoreMagicNumbers is not taken into account, if there are multiple literals involved in such an expression.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="ignoreMagicNumbers"
+                      description="Comma-separated list of magic numbers, that should be ignored"
+                      type="String" value="-1,0"/>
+            <property name="ignoreExpressions"
+                      description="If true, only literals in simple if conditions are considered. Otherwise literals in expressions are checked, too."
+                      type="Boolean" value="true"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+(: simple case - no deep expressions :)
+//IfStatement[$ignoreExpressions = true()]/Expression/*/PrimaryExpression/PrimaryPrefix/Literal
+    [not(NullLiteral)]
+    [not(BooleanLiteral)]
+    [empty(index-of(tokenize($ignoreMagicNumbers, '\s*,\s*'), @Image))]
+|
+(: consider also deeper expressions :)
+//IfStatement[$ignoreExpressions = false()]/Expression//*[local-name() != 'UnaryExpression' or @Operator != '-']/PrimaryExpression/PrimaryPrefix/Literal
+    [not(NullLiteral)]
+    [not(BooleanLiteral)]
+    [empty(index-of(tokenize($ignoreMagicNumbers, '\s*,\s*'), @Image))]
+|
+(: consider negative literals :)
+//IfStatement[$ignoreExpressions = false()]/Expression//UnaryExpression[@Operator = '-']/PrimaryExpression/PrimaryPrefix/Literal
+    [not(NullLiteral)]
+    [not(BooleanLiteral)]
+    [empty(index-of(tokenize($ignoreMagicNumbers, '\s*,\s*'), concat('-', @Image)))]
+|
+(: consider multiple literals in expressions :)
+//IfStatement[$ignoreExpressions = false()]/Expression[count(*/PrimaryExpression/PrimaryPrefix/Literal
+    [not(NullLiteral)]
+    [not(BooleanLiteral)]) > 1]
+]]>
+                </value>
+            </property>
+            <property name="version" value="2.0"/>
+        </properties>
+        <example>
+            <![CDATA[
+private static final int MAX_NUMBER_OF_REQUESTS = 10;
+
+public void checkRequests() {
+
+    if (i == 10) {                        // magic number, buried in a method
+      doSomething();
+    }
+
+    if (i == MAX_NUMBER_OF_REQUESTS) {    // preferred approach
+      doSomething();
+    }
+
+    if (aString.indexOf('.') != -1) {}     // magic number -1, by default ignored
+    if (aString.indexOf('.') >= 0) { }     // alternative approach
+
+    if (aDouble > 0.0) {}                  // magic number 0.0
+    if (aDouble >= Double.MIN_VALUE) {}    // preferred approach
+
+    // with rule property "ignoreExpressions" set to "false"
+    if (i == pos + 5) {}  // violation: magic number 5 within an (additive) expression
+    if (i == pos + SUFFIX_LENGTH) {} // preferred approach
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidLosingExceptionInformation"
+          since="4.2.6"
+          language="java"
+          message="Avoid statements in a catch block that invoke accessors on the exception without using the information"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidlosingexceptioninformation">
+        <description>
+            Statements in a catch block that invoke accessors on the exception without using the information
+            only add to code size.  Either remove the invocation, or use the return result.
+        </description>
+        <priority>2</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//CatchStatement/Block/BlockStatement/Statement/StatementExpression/PrimaryExpression/PrimaryPrefix/Name
+[
+   @Image = concat(../../../../../../../FormalParameter/VariableDeclaratorId/@Name, '.getMessage')
+   or
+   @Image = concat(../../../../../../../FormalParameter/VariableDeclaratorId/@Name, '.getLocalizedMessage')
+   or
+   @Image = concat(../../../../../../../FormalParameter/VariableDeclaratorId/@Name, '.getCause')
+   or
+   @Image = concat(../../../../../../../FormalParameter/VariableDeclaratorId/@Name, '.getStackTrace')
+   or
+   @Image = concat(../../../../../../../FormalParameter/VariableDeclaratorId/@Name, '.toString')
+]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public void bar() {
+    try {
+        // do something
+    } catch (SomeException se) {
+        se.getMessage();
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidMultipleUnaryOperators"
+          language="java"
+          since="4.2"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AvoidMultipleUnaryOperatorsRule"
+          message="Using multiple unary operators may be a bug, and/or is confusing."
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidmultipleunaryoperators">
+        <description>
+            The use of multiple unary operators may be problematic, and/or confusing.
+            Ensure that the intended usage is not a bug, or consider simplifying the expression.
+        </description>
+        <priority>2</priority>
+        <example>
+            <![CDATA[
+// These are typo bugs, or at best needlessly complex and confusing:
+int i = - -1;
+int j = + - +1;
+int z = ~~2;
+boolean b = !!true;
+boolean c = !!!true;
+
+// These are better:
+int i = 1;
+int j = -1;
+int z = 2;
+boolean b = true;
+boolean c = false;
+
+// And these just make your brain hurt:
+int i = ~-2;
+int j = -~7;
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidUsingOctalValues"
+          language="java"
+          since="3.9"
+          message="Do not start a literal by 0 unless it's an octal value"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AvoidUsingOctalValuesRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidusingoctalvalues">
+        <description>
+            Integer literals should not start with zero since this denotes that the rest of literal will be
+            interpreted as an octal value.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+int i = 012;    // set i with 10 not 12
+int j = 010;    // set j with 8 not 10
+k = i * j;      // set k with 80 not 120
+]]>
+        </example>
+    </rule>
+
+    <rule name="BadComparison" ref="ComparisonWithNaN" deprecated="true" />
+
+    <rule name="BeanMembersShouldSerialize"
+          language="java"
+          since="1.1"
+          message="Found non-transient, non-static member. Please mark as transient or provide accessors."
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.BeanMembersShouldSerializeRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#beanmembersshouldserialize">
+        <description>
+            If a class is a bean, or is referenced by a bean directly or indirectly it needs to be serializable.
+            Member variables need to be marked as transient, static, or have accessor methods in the class. Marking
+            variables as transient is the safest and easiest modification. Accessor methods should follow the Java
+            naming conventions, i.e. for a variable named foo, getFoo() and setFoo() accessor methods should be provided.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+private transient int someFoo;  // good, it's transient
+private static int otherFoo;    // also OK
+private int moreFoo;            // OK, has proper accessors, see below
+private int badFoo;             // bad, should be marked transient
+
+private void setMoreFoo(int moreFoo){
+      this.moreFoo = moreFoo;
+}
+
+private int getMoreFoo(){
+      return this.moreFoo;
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="BrokenNullCheck"
+          language="java"
+          since="3.8"
+          message="Method call on object which may be null"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.BrokenNullCheckRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#brokennullcheck">
+        <description>
+            The null check is broken since it will throw a NullPointerException itself.
+            It is likely that you used || instead of &amp;&amp; or vice versa.
+        </description>
+        <priority>2</priority>
+        <example>
+            <![CDATA[
+public String bar(String string) {
+  // should be &&
+    if (string!=null || !string.equals(""))
+        return string;
+  // should be ||
+    if (string==null && string.equals(""))
+        return string;
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="CallSuperFirst"
+          since="4.2.5"
+          language="java"
+          message="super should be called at the start of the method"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#callsuperfirst">
+        <description>Super should be called at the start of the method</description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//MethodDeclaration[
+  @Name='onCreate' or
+  @Name='onConfigurationChanged' or
+  @Name='onPostCreate' or
+  @Name='onPostResume' or
+  @Name='onRestart' or
+  @Name='onRestoreInstanceState' or
+  @Name='onResume' or
+  @Name='onStart'
+  ]
+    /Block[not(
+      (BlockStatement[1]/Statement/StatementExpression/PrimaryExpression[./PrimaryPrefix[@SuperModifier= true()]]/PrimarySuffix[@Image= ancestor::MethodDeclaration/@Name]))]
+[ancestor::ClassOrInterfaceDeclaration[ExtendsList/ClassOrInterfaceType[
+  pmd-java:typeIs('android.app.Activity') or
+  pmd-java:typeIs('android.app.Application') or
+  pmd-java:typeIs('android.app.Service')
+]]]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class DummyActivity extends Activity {
+    public void onCreate(Bundle bundle) {
+        // missing call to super.onCreate(bundle)
+        foo();
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="CallSuperLast"
+          since="4.2.5"
+          language="java"
+          message="super should be called at the end of the method"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#callsuperlast">
+        <description>
+            Super should be called at the end of the method
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//MethodDeclaration[
+  @Name='finish' or
+  @Name='onDestroy' or
+  @Name='onPause' or
+  @Name='onSaveInstanceState' or
+  @Name='onStop' or
+  @Name='onTerminate'
+  ]
+   /Block/BlockStatement[last()]
+    [not(Statement/StatementExpression/PrimaryExpression[./PrimaryPrefix[@SuperModifier= true()]]/PrimarySuffix[@Image= ancestor::MethodDeclaration/@Name])]
+[ancestor::ClassOrInterfaceDeclaration[ExtendsList/ClassOrInterfaceType[
+  pmd-java:typeIs('android.app.Activity') or
+  pmd-java:typeIs('android.app.Application') or
+  pmd-java:typeIs('android.app.Service')
+]]]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class DummyActivity extends Activity {
+    public void onPause() {
+        foo();
+        // missing call to super.onPause()
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="CheckSkipResult"
+          language="java"
+          since="5.0"
+          message="Check the value returned by the skip() method of an InputStream to see if the requested number of bytes has been skipped."
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.CheckSkipResultRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#checkskipresult">
+        <description>
+            The skip() method may skip a smaller number of bytes than requested. Check the returned value to find out if it was the case or not.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class Foo {
+
+   private FileInputStream _s = new FileInputStream("file");
+
+   public void skip(int n) throws IOException {
+      _s.skip(n); // You are not sure that exactly n bytes are skipped
+   }
+
+   public void skipExactly(int n) throws IOException {
+      while (n != 0) {
+         long skipped = _s.skip(n);
+         if (skipped == 0)
+            throw new EOFException();
+         n -= skipped;
+      }
+   }
+]]>
+        </example>
+    </rule>
+
+    <rule name="ClassCastExceptionWithToArray"
+          language="java"
+          since="3.4"
+          message="This usage of the Collection.toArray() method will throw a ClassCastException."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#classcastexceptionwithtoarray">
+        <description>
+            When deriving an array of a specific class from your Collection, one should provide an array of
+            the same class as the parameter of the toArray() method. Doing otherwise you will will result
+            in a ClassCastException.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//CastExpression[Type/ReferenceType/ClassOrInterfaceType[@Image != "Object"]]
+    /PrimaryExpression
+    [PrimaryPrefix/Name[ends-with(@Image, '.toArray')]]
+    [PrimarySuffix/Arguments[not(*)]]
+    [count(PrimarySuffix) = 1]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+Collection c = new ArrayList();
+Integer obj = new Integer(1);
+c.add(obj);
+
+    // this would trigger the rule (and throw a ClassCastException if executed)
+Integer[] a = (Integer [])c.toArray();
+
+   // this is fine and will not trigger the rule
+Integer[] b = (Integer [])c.toArray(new Integer[c.size()]);
+]]>
+        </example>
+    </rule>
+
+    <rule name="CloneMethodMustBePublic"
+          language="java"
+          since="5.4.0"
+          message="clone() method must be public if the class implements Cloneable"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#clonemethodmustbepublic">
+        <description>
+            The java Manual says "By convention, classes that implement this interface should override
+            Object.clone (which is protected) with a public method."
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//MethodDeclaration[@Public= false()]
+  [@Name = 'clone']
+  [@Arity = 0]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo implements Cloneable {
+    @Override
+    protected Object clone() throws CloneNotSupportedException { // Violation, must be public
+    }
+}
+
+public class Foo implements Cloneable {
+    @Override
+    protected Foo clone() { // Violation, must be public
+    }
+}
+
+public class Foo implements Cloneable {
+    @Override
+    public Object clone() // Ok
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="CloneMethodMustImplementCloneable"
+          language="java"
+          since="1.9"
+          message="clone() method should be implemented only if implementing Cloneable interface"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.CloneMethodMustImplementCloneableRule"
+          typeResolution="true"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#clonemethodmustimplementcloneable">
+        <description>
+            The method clone() should only be implemented if the class implements the Cloneable interface with the exception of
+            a final method that only throws CloneNotSupportedException.
+
+            The rule can also detect, if the class implements or extends a Cloneable class.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class MyClass {
+ public Object clone() throws CloneNotSupportedException {
+  return foo;
+ }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="CloneMethodReturnTypeMustMatchClassName"
+          language="java"
+          minimumLanguageVersion="1.5"
+          since="5.4.0"
+          message="The return type of the clone() method must be the class name when implements Cloneable"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#clonemethodreturntypemustmatchclassname">
+        <description>
+            If a class implements cloneable the return type of the method clone() must be the class name. That way, the caller
+            of the clone method doesn't need to cast the returned clone to the correct type.
+
+            Note: This is only possible with Java 1.5 or higher.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//MethodDeclaration
+[
+@Name = 'clone'
+and @Arity = 0
+and not (ResultType//ClassOrInterfaceType/@Image = ancestor::ClassOrInterfaceDeclaration[1]/@SimpleName)
+]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo implements Cloneable {
+    @Override
+    protected Object clone() { // Violation, Object must be Foo
+    }
+}
+
+public class Foo implements Cloneable {
+    @Override
+    public Foo clone() { //Ok
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="CloneThrowsCloneNotSupportedException"
+          deprecated="true"
+          language="java"
+          since="1.9"
+          message="clone() method should throw CloneNotSupportedException"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#clonethrowsclonenotsupportedexception">
+        <description>
+            The method clone() should throw a CloneNotSupportedException.
+
+            This rule is deprecated since PMD 6.35.0 without replacement. The rule has no real value as
+            `CloneNotSupportedException` is a checked exception and therefore you need to deal with it while
+            implementing the `clone()` method. You either need to declare the exception or catch it. If you catch it,
+            then subclasses can't throw it themselves explicitly. However, `Object.clone()` will still throw this
+            exception if the `Cloneable` interface is not implemented.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//MethodDeclaration
+[
+@Name = 'clone'
+and @Arity = 0
+and count(NameList/Name[contains
+(@Image,'CloneNotSupportedException')]) = 0
+]
+[
+../../../../ClassOrInterfaceDeclaration[@Final = false()]
+]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class MyClass implements Cloneable{
+    public Object clone() { // will cause an error
+         MyClass clone = (MyClass)super.clone();
+         return clone;
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="CloseResource"
+          language="java"
+          since="1.2.2"
+          message="Ensure that resources like this {0} object are closed after use"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.CloseResourceRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#closeresource">
+        <description>
+            Ensure that resources (like `java.sql.Connection`, `java.sql.Statement`, and `java.sql.ResultSet` objects
+            and any subtype of `java.lang.AutoCloseable`) are always closed after use.
+            Failing to do so might result in resource leaks.
+
+            Note: It suffices to configure the super type, e.g. `java.lang.AutoClosable`, so that this rule automatically triggers
+            on any subtype (e.g. `java.io.FileInputStream`). Additionally specifying `java.sql.Connection` helps in detecting
+            the types, if the type resolution / auxclasspath is not correctly setup.
+
+            Note: Since PMD 6.16.0 the default value for the property `types` contains `java.lang.AutoCloseable` and detects
+            now cases where the standard `java.io.*Stream` classes are involved. In order to restore the old behaviour,
+            just remove "AutoCloseable" from the types.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class Bar {
+    public void withSQL() {
+        Connection c = pool.getConnection();
+        try {
+            // do stuff
+        } catch (SQLException ex) {
+           // handle exception
+        } finally {
+            // oops, should close the connection using 'close'!
+            // c.close();
+        }
+    }
+
+    public void withFile() {
+        InputStream file = new FileInputStream(new File("/tmp/foo"));
+        try {
+            int c = file.in();
+        } catch (IOException e) {
+            // handle exception
+        } finally {
+            // TODO: close file
+        }
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="CompareObjectsWithEquals"
+          language="java"
+          since="3.2"
+          message="Use equals() to compare object references."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#compareobjectswithequals">
+        <description>
+            Use `equals()` to compare object references; avoid comparing them with `==`.
+
+            Since comparing objects with named constants is useful in some cases (eg, when
+            defining constants for sentinel values), the rule ignores comparisons against
+            fields with all-caps name (eg `this == SENTINEL`), which is a common naming
+            convention for constant fields.
+
+            You may allow some types to be compared by reference by listing the exceptions
+            in the `typesThatCompareByReference` property.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="typesThatCompareByReference" type="List[String]" delimiter="," description="List of canonical type names for which reference comparison is allowed.">
+                <value>java.lang.Enum,java.lang.Class</value>
+            </property>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//EqualityExpression
+    [count(
+        PrimaryExpression[pmd-java:typeIs('java.lang.Object')]
+        [not(some $t in $typesThatCompareByReference satisfies pmd-java:typeIs($t))]
+       ) = 2
+    ]
+    [not(PrimaryExpression[PrimaryPrefix/@ThisModifier = true()]
+                          [not(PrimarySuffix)]
+                          [ancestor::MethodDeclaration[@Name = 'equals']])
+    ]
+    (: Is not a field access with an all-caps identifier :)
+    [not(PrimaryExpression[not(PrimarySuffix) and PrimaryPrefix/Name[upper-case(@Image)=@Image]
+     or PrimaryExpression/PrimarySuffix[last()][upper-case(@Image)=@Image]])]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+class Foo {
+  boolean bar(String a, String b) {
+    return a == b;
+  }
+}
+
+]]>
+        </example>
+    </rule>
+
+    <rule name="ComparisonWithNaN"
+          language="java"
+          since="6.36.0"
+          message="Comparisons with NaN always return false"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#comparisonwithnan">
+        <description><![CDATA[
+            Reports comparisons with double and float `NaN` (Not-a-Number) values.
+            These are [specified](https://docs.oracle.com/javase/specs/jls/se8/html/jls-15.html#jls-15.21.1)
+            to have unintuitive behavior: NaN is considered unequal to itself.
+            This means a check like `someDouble == Double.NaN` will always return
+            false, even if `someDouble` is really the NaN value. To test whether a
+            value is the NaN value, one should instead use `Double.isNaN(someDouble)`
+            (or `Float.isNaN`). The `!=` operator should be treated similarly.
+            Finally, comparisons like `someDouble <= Double.NaN` are nonsensical
+            and will always evaluate to false.
+
+            This rule has been renamed from "BadComparison" with PMD 6.36.0.
+        ]]></description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+(//EqualityExpression | //RelationalExpression)/PrimaryExpression/PrimaryPrefix/Name[@Image='Double.NaN' or @Image='Float.NaN']
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+boolean x = (y == Double.NaN);
+]]>
+        </example>
+    </rule>
+
+
+    <rule name="ConstructorCallsOverridableMethod"
+          language="java"
+          since="1.04"
+          message="Overridable {0} called during object construction"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.ConstructorCallsOverridableMethodRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#constructorcallsoverridablemethod">
+        <description>
+            Calling overridable methods during construction poses a risk of invoking methods on an incompletely
+            constructed object and can be difficult to debug.
+            It may leave the sub-class unable to construct its superclass or forced to replicate the construction
+            process completely within itself, losing the ability to call super().  If the default constructor
+            contains a call to an overridable method, the subclass may be completely uninstantiable.   Note that
+            this includes method calls throughout the control flow graph - i.e., if a constructor Foo() calls a
+            private method bar() that calls a public method buz(), this denotes a problem.
+        </description>
+        <priority>1</priority>
+        <example>
+            <![CDATA[
+public class SeniorClass {
+  public SeniorClass(){
+      toString(); //may throw NullPointerException if overridden
+  }
+  public String toString(){
+    return "IAmSeniorClass";
+  }
+}
+public class JuniorClass extends SeniorClass {
+  private String name;
+  public JuniorClass(){
+    super(); //Automatic call leads to NullPointerException
+    name = "JuniorClass";
+  }
+  public String toString(){
+    return name.toUpperCase();
+  }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="DataflowAnomalyAnalysis"
+          language="java"
+          since="3.9"
+          message="Found ''{0}''-anomaly for variable ''{1}'' (lines ''{2}''-''{3}'')."
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.DataflowAnomalyAnalysisRule"
+          dfa="true"
+          deprecated="true"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#dataflowanomalyanalysis">
+        <description>The dataflow analysis tracks local definitions, undefinitions and references to variables on different paths on the data flow.
+            From those informations there can be found various problems.
+
+            1. DU - Anomaly: A recently defined variable is undefined. These anomalies may appear in normal source text.
+            2. DD - Anomaly: A recently defined variable is redefined. This is ominous but don't have to be a bug.
+
+            This rule is deprecated. Use {% rule "java/bestpractices/UnusedAssignment" %} in category bestpractices instead.
+        </description>
+        <priority>5</priority>
+        <example>
+            <![CDATA[
+public void foo() {
+  int buz = 5;
+  buz = 6; // redefinition of buz -> dd-anomaly
+  foo(buz);
+  buz = 2;
+} // buz is undefined when leaving scope -> du-anomaly
+]]>
+        </example>
+    </rule>
+
+    <rule name="DetachedTestCase"
+          language="java"
+          since="6.13.0"
+          message="Probable detached JUnit test case."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          typeResolution="true"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#detachedtestcase">
+        <description>
+            The method appears to be a test case since it has public or default visibility,
+            non-static access, no arguments, no return value, has no annotations, but is a
+            member of a class that has one or more JUnit test cases. If it is a utility
+            method, it should likely have private visibility. If it is an ignored test, it
+            should be annotated with @Test and @Ignore.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value><![CDATA[
+//ClassOrInterfaceBodyDeclaration
+[../ClassOrInterfaceBodyDeclaration/Annotation/*/Name
+        [pmd-java:typeIs('org.junit.Test')
+         or pmd-java:typeIs('org.junit.jupiter.api.Test')
+         or pmd-java:typeIs('org.junit.jupiter.api.RepeatedTest')
+         or pmd-java:typeIs('org.junit.jupiter.api.TestFactory')
+         or pmd-java:typeIs('org.junit.jupiter.api.TestTemplate')
+         or pmd-java:typeIs('org.junit.jupiter.params.ParameterizedTest')]
+]
+[not(Annotation)]
+[MethodDeclaration[(@Public = true() or @PackagePrivate = true()) and @Static = false() and
+        ResultType[@Void = true()] and
+        MethodDeclarator/FormalParameters[@Size = 0]
+    ]
+]
+]]></value>
+            </property>
+            <property name="version" value="2.0" />
+        </properties>
+        <example>
+            <![CDATA[
+public class MyTest {
+    @Test
+    public void someTest() {
+    }
+
+    // violation: Not annotated
+    public void someOtherTest () {
+    }
+
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="DoNotCallGarbageCollectionExplicitly"
+          language="java"
+          since="4.2"
+          message="Do not explicitly trigger a garbage collection."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#donotcallgarbagecollectionexplicitly">
+        <description>
+            Calls to System.gc(), Runtime.getRuntime().gc(), and System.runFinalization() are not advised. Code should have the
+            same behavior whether the garbage collection is disabled using the option -Xdisableexplicitgc or not.
+            Moreover, "modern" jvms do a very good job handling garbage collections. If memory usage issues unrelated to memory
+            leaks develop within an application, it should be dealt with JVM options rather than within the code itself.
+        </description>
+        <priority>2</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//Name[
+(starts-with(@Image, 'System.') and
+(starts-with(@Image, 'System.gc') or
+starts-with(@Image, 'System.runFinalization'))) or
+(
+starts-with(@Image,'Runtime.getRuntime') and
+../../PrimarySuffix[ends-with(@Image,'gc')]
+)
+]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class GCCall {
+    public GCCall() {
+        // Explicit gc call !
+        System.gc();
+    }
+
+    public void doSomething() {
+        // Explicit gc call !
+        Runtime.getRuntime().gc();
+    }
+
+    public explicitGCcall() {
+        // Explicit gc call !
+        System.gc();
+    }
+
+    public void doSomething() {
+        // Explicit gc call !
+        Runtime.getRuntime().gc();
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="DoNotCallSystemExit" ref="category/java/errorprone.xml/DoNotTerminateVM" deprecated="true" />
+
+    <rule name="DoNotExtendJavaLangThrowable"
+          language="java"
+          since="6.0.0"
+          message="Exceptions should not extend java.lang.Throwable"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#donotextendjavalangthrowable">
+        <description>
+            Extend Exception or RuntimeException instead of Throwable.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//ClassOrInterfaceDeclaration/ExtendsList/ClassOrInterfaceType
+  [@Image="Throwable" or @Image="java.lang.Throwable"]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo extends Throwable { }
+]]>
+        </example>
+    </rule>
+
+    <rule name="DoNotHardCodeSDCard"
+          since="4.2.6"
+          language="java"
+          message="Do not hardcode /sdcard."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#donothardcodesdcard">
+        <description>
+            Use Environment.getExternalStorageDirectory() instead of "/sdcard"
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>//Literal[starts-with(@Image,'"/sdcard')]</value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class MyActivity extends Activity {
+    protected void foo() {
+        String storageLocation = "/sdcard/mypackage";   // hard-coded, poor approach
+
+       storageLocation = Environment.getExternalStorageDirectory() + "/mypackage"; // preferred approach
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="DoNotTerminateVM"
+          language="java"
+          since="4.1"
+          message="System.exit() should not be used in J2EE/JEE apps"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#donotterminatevm">
+        <description>
+            Web applications should not call `System.exit()`, since only the web container or the
+            application server should stop the JVM. Otherwise a web application would terminate all other applications
+            running on the same application server.
+
+            This rule also checks for the equivalent calls `Runtime.getRuntime().exit()` and `Runtime.getRuntime().halt()`.
+
+            This rule was called *DoNotCallSystemExit* until PMD 6.29.0.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//Name[
+    starts-with(@Image,'System.exit')
+    or
+    (starts-with(@Image,'Runtime.getRuntime') and ../../PrimarySuffix[ends-with(@Image,'exit') or ends-with(@Image,'halt')])
+][not(ancestor::MethodDeclaration[1][@Name="main" and @Static = true()])]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public void bar() {
+    System.exit(0);                 // never call this when running in an application server!
+}
+public void foo() {
+    Runtime.getRuntime().exit(0);   // never stop the JVM manually, the container will do this.
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="DoNotThrowExceptionInFinally"
+          language="java"
+          since="4.2"
+          message="A throw statement in a finally block makes the control flow hard to understand."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#donotthrowexceptioninfinally">
+        <description>
+            Throwing exceptions within a 'finally' block is confusing since they may mask other exceptions
+            or code defects.
+            Note: This is a PMD implementation of the Lint4j rule "A throw in a finally block"
+        </description>
+        <priority>4</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>//FinallyStatement[descendant::ThrowStatement]</value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo {
+    public void bar() {
+        try {
+            // Here do some stuff
+        } catch( Exception e) {
+            // Handling the issue
+        } finally {
+            // is this really a good idea ?
+            throw new Exception();
+        }
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="DontImportSun"
+          language="java"
+          since="1.5"
+          message="Avoid importing anything from the 'sun.*' packages"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.DontImportSunRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#dontimportsun">
+        <description>
+            Avoid importing anything from the 'sun.*' packages.  These packages are not portable and are likely to change.
+        </description>
+        <priority>4</priority>
+        <example>
+            <![CDATA[
+import sun.misc.foo;
+public class Foo {}
+]]>
+        </example>
+    </rule>
+
+    <rule name="DontUseFloatTypeForLoopIndices"
+          language="java"
+          since="4.3"
+          message="Don't use floating point for loop indices. If you must use floating point, use double."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#dontusefloattypeforloopindices">
+        <description>
+            Don't use floating point for loop indices. If you must use floating point, use double
+            unless you're certain that float provides enough precision and you have a compelling
+            performance need (space or time).
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//ForStatement/ForInit/LocalVariableDeclaration
+/Type/PrimitiveType[@Image="float"]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Count {
+  public static void main(String[] args) {
+    final int START = 2000000000;
+    int count = 0;
+    for (float f = START; f < START + 50; f++)
+      count++;
+      //Prints 0 because (float) START == (float) (START + 50).
+      System.out.println(count);
+      //The termination test misbehaves due to floating point granularity.
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="EmptyCatchBlock"
+          language="java"
+          since="0.1"
+          message="Avoid empty catch blocks"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#emptycatchblock">
+        <description>
+            Empty Catch Block finds instances where an exception is caught, but nothing is done.
+            In most circumstances, this swallows an exception which should either be acted on
+            or reported.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//CatchStatement
+ [not(Block/BlockStatement)]
+ [$allowCommentedBlocks != true() or Block/@containsComment = false()]
+ [FormalParameter/Type/ReferenceType
+   /ClassOrInterfaceType[@Image != 'InterruptedException' and @Image != 'CloneNotSupportedException']
+ ]
+ [FormalParameter/VariableDeclaratorId[not(matches(@Name, $allowExceptionNameRegex))]]
+]]>
+                </value>
+            </property>
+            <property name="allowCommentedBlocks" type="Boolean" description="Empty blocks containing comments will be skipped" value="false"/>
+            <property name="allowExceptionNameRegex" type="String" description="Empty blocks catching exceptions with names matching this regular expression will be skipped" value="^(ignored|expected)$"/>
+        </properties>
+        <example>
+            <![CDATA[
+public void doSomething() {
+    try {
+        FileInputStream fis = new FileInputStream("/tmp/bugger");
+    } catch (IOException ioe) {
+        // not good
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="EmptyFinalizer"
+          language="java"
+          since="1.5"
+          message="Avoid empty finalize methods"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#emptyfinalizer">
+        <description>
+            Empty finalize methods serve no purpose and should be removed. Note that Oracle has declared Object.finalize() as deprecated since JDK 9.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//MethodDeclaration[@Name='finalize'][@Arity = 0]
+  /Block[not(*)]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo {
+   protected void finalize() {}
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="EmptyFinallyBlock"
+          language="java"
+          since="0.4"
+          message="Avoid empty finally blocks"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#emptyfinallyblock">
+        <description>
+            Empty finally blocks serve no purpose and should be removed.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//FinallyStatement[not(Block/BlockStatement)]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo {
+    public void bar() {
+        try {
+            int x=2;
+        } finally {
+            // empty!
+        }
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="EmptyIfStmt"
+          language="java"
+          since="0.1"
+          message="Avoid empty 'if' statements"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#emptyifstmt">
+        <description>
+            Empty If Statement finds instances where a condition is checked but nothing is done about it.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//IfStatement/Statement
+ [EmptyStatement or Block[not(*)]]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo {
+ void bar(int x) {
+  if (x == 0) {
+   // empty!
+  }
+ }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="EmptyInitializer"
+          language="java"
+          since="5.0"
+          message="Empty initializer was found"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#emptyinitializer">
+        <description>
+            Empty initializers serve no purpose and should be removed.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>//Initializer/Block[not(*)]</value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo {
+
+   static {} // Why ?
+
+   {} // Again, why ?
+
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="EmptyStatementBlock"
+          language="java"
+          since="5.0"
+          message="Avoid empty block statements."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#emptystatementblock">
+        <description>
+            Empty block statements serve no purpose and should be removed.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>//BlockStatement/Statement/Block[not(*)]</value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo {
+
+   private int _bar;
+
+   public void setBar(int bar) {
+      { _bar = bar; } // Why not?
+      {} // But remove this.
+   }
+
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="EmptyStatementNotInLoop"
+          language="java"
+          since="1.5"
+          message="An empty statement (semicolon) not part of a loop"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#emptystatementnotinloop">
+        <description>
+            An empty statement (or a semicolon by itself) that is not used as the sole body of a 'for'
+            or 'while' loop is probably a bug.  It could also be a double semicolon, which has no purpose
+            and should be removed.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//EmptyStatement
+ [not(
+       ../../../ForStatement
+       or ../../../WhileStatement
+       or ../../../BlockStatement/ClassOrInterfaceDeclaration
+       or ../../../../../../ForStatement/Statement[1]
+        /Block[1]/BlockStatement[1]/Statement/EmptyStatement
+       or ../../../../../../WhileStatement/Statement[1]
+        /Block[1]/BlockStatement[1]/Statement/EmptyStatement)
+ ]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public void doit() {
+      // this is probably not what you meant to do
+      ;
+      // the extra semicolon here this is not necessary
+      System.out.println("look at the extra semicolon");;
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="EmptySwitchStatements"

Review comment:
       This rule is enabled in our repo

##########
File path: check-rules/errorprone.xml
##########
@@ -0,0 +1,3721 @@
+<?xml version="1.0"?>
+
+<ruleset name="Error Prone"
+         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 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">
+
+    <description>
+        Rules to detect constructs that are either broken, extremely confusing or prone to runtime errors.
+    </description>
+
+    <rule name="AssignmentInOperand"
+          language="java"
+          since="1.03"
+          message="Avoid assignments in operands"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AssignmentInOperandRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#assignmentinoperand">
+        <description>
+            Avoid assignments in operands; this can make code more complicated and harder to read.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public void bar() {
+    int x = 2;
+    if ((x = getX()) == 3) {
+      System.out.println("3!");
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AssignmentToNonFinalStatic"
+          language="java"
+          since="2.2"
+          message="Possible unsafe assignment to a non-final static field in a constructor."
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AssignmentToNonFinalStaticRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#assignmenttononfinalstatic">
+        <description>
+            Identifies a possible unsafe usage of a static field.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class StaticField {
+   static int x;
+   public FinalFields(int y) {
+    x = y; // unsafe
+   }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidAccessibilityAlteration"
+          language="java"
+          since="4.1"
+          message="You should not modify visibility of class or methods using getDeclaredConstructors(), getDeclaredConstructor(Class[]), setAccessible() or PrivilegedAction."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidaccessibilityalteration">
+        <description>
+            Methods such as getDeclaredConstructors(), getDeclaredConstructor(Class[]) and setAccessible(),
+            as the interface PrivilegedAction, allow for the runtime alteration of variable, class, or
+            method visibility, even if they are private. This violates the principle of encapsulation.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//PrimaryExpression[
+(
+(PrimarySuffix[
+        ends-with(@Image,'getDeclaredConstructors')
+                or
+        ends-with(@Image,'getDeclaredConstructor')
+                or
+        ends-with(@Image,'setAccessible')
+        ])
+or
+(PrimaryPrefix/Name[
+        ends-with(@Image,'getDeclaredConstructor')
+        or
+        ends-with(@Image,'getDeclaredConstructors')
+        or
+        starts-with(@Image,'AccessibleObject.setAccessible')
+        ])
+)
+and
+(//ImportDeclaration/Name[
+        contains(@Image,'java.security.PrivilegedAction')])
+]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Method;
+import java.security.PrivilegedAction;
+
+public class Violation {
+  public void invalidCallsInMethod() throws SecurityException, NoSuchMethodException {
+    // Possible call to forbidden getDeclaredConstructors
+    Class[] arrayOfClass = new Class[1];
+    this.getClass().getDeclaredConstructors();
+    this.getClass().getDeclaredConstructor(arrayOfClass);
+    Class clazz = this.getClass();
+    clazz.getDeclaredConstructor(arrayOfClass);
+    clazz.getDeclaredConstructors();
+      // Possible call to forbidden setAccessible
+    clazz.getMethod("", arrayOfClass).setAccessible(false);
+    AccessibleObject.setAccessible(null, false);
+    Method.setAccessible(null, false);
+    Method[] methodsArray = clazz.getMethods();
+    int nbMethod;
+    for ( nbMethod = 0; nbMethod < methodsArray.length; nbMethod++ ) {
+      methodsArray[nbMethod].setAccessible(false);
+    }
+
+      // Possible call to forbidden PrivilegedAction
+    PrivilegedAction priv = (PrivilegedAction) new Object(); priv.run();
+  }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidAssertAsIdentifier"
+          language="java"
+          since="3.4"
+          message="Avoid using assert as an identifier; it became a reserved word in JDK 1.4"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidassertasidentifier">
+        <description>
+            Use of the term 'assert' will conflict with newer versions of Java since it is a reserved word.
+        </description>
+        <priority>2</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>//VariableDeclaratorId[@Name='assert']</value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class A {
+    public class Foo {
+        String assert = "foo";
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidBranchingStatementAsLastInLoop"
+          language="java"
+          since="5.0"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AvoidBranchingStatementAsLastInLoopRule"
+          message="Avoid using a branching statement as the last in a loop."
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidbranchingstatementaslastinloop">
+        <description>
+            Using a branching statement as the last part of a loop may be a bug, and/or is confusing.
+            Ensure that the usage is not a bug, or consider using another approach.
+        </description>
+        <priority>2</priority>
+        <example>
+            <![CDATA[
+// unusual use of branching statement in a loop
+for (int i = 0; i < 10; i++) {
+    if (i*i <= 25) {
+        continue;
+    }
+    break;
+}
+
+// this makes more sense...
+for (int i = 0; i < 10; i++) {
+    if (i*i > 25) {
+        break;
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidCallingFinalize"
+          language="java"
+          since="3.0"
+          message="Avoid calling finalize() explicitly"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AvoidCallingFinalizeRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidcallingfinalize">
+        <description>
+            The method Object.finalize() is called by the garbage collector on an object when garbage collection determines
+            that there are no more references to the object. It should not be invoked by application logic.
+
+            Note that Oracle has declared Object.finalize() as deprecated since JDK 9.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+void foo() {
+    Bar b = new Bar();
+    b.finalize();
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidCatchingNPE"
+          language="java"
+          since="1.8"
+          message="Avoid catching NullPointerException; consider removing the cause of the NPE."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidcatchingnpe">
+        <description>
+            Code should never throw NullPointerExceptions under normal circumstances.  A catch block may hide the
+            original error, causing other, more subtle problems later on.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//CatchStatement/FormalParameter/Type
+ /ReferenceType/ClassOrInterfaceType[@Image='NullPointerException']
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo {
+    void bar() {
+        try {
+            // do something
+        } catch (NullPointerException npe) {
+        }
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidCatchingThrowable"
+          language="java"
+          since="1.2"
+          message="A catch statement should never catch throwable since it includes errors."
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AvoidCatchingThrowableRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidcatchingthrowable">
+        <description>
+            Catching Throwable errors is not recommended since its scope is very broad. It includes runtime issues such as
+            OutOfMemoryError that should be exposed and managed separately.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public void bar() {
+    try {
+        // do something
+    } catch (Throwable th) {  // should not catch Throwable
+        th.printStackTrace();
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidDecimalLiteralsInBigDecimalConstructor"
+          language="java"
+          since="3.4"
+          message="Avoid creating BigDecimal with a decimal (float/double) literal. Use a String literal"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoiddecimalliteralsinbigdecimalconstructor">
+        <description>
+            One might assume that the result of "new BigDecimal(0.1)" is exactly equal to 0.1, but it is actually
+            equal to .1000000000000000055511151231257827021181583404541015625.
+            This is because 0.1 cannot be represented exactly as a double (or as a binary fraction of any finite
+            length). Thus, the long value that is being passed in to the constructor is not exactly equal to 0.1,
+            appearances notwithstanding.
+
+            The (String) constructor, on the other hand, is perfectly predictable: 'new BigDecimal("0.1")' is
+            exactly equal to 0.1, as one would expect.  Therefore, it is generally recommended that the
+            (String) constructor be used in preference to this one.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//AllocationExpression[pmd-java:typeIs('java.math.BigDecimal')]
+[Arguments/ArgumentList/Expression/PrimaryExpression
+    [
+        pmd-java:typeIs('float') or
+        pmd-java:typeIs('java.lang.Float') or
+        pmd-java:typeIs('double') or
+        pmd-java:typeIs('java.lang.Double')
+    ]
+]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+BigDecimal bd = new BigDecimal(1.123);       // loss of precision, this would trigger the rule
+
+BigDecimal bd = new BigDecimal("1.123");     // preferred approach
+
+BigDecimal bd = new BigDecimal(12);          // preferred approach, ok for integer values
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidDuplicateLiterals"
+          language="java"
+          since="1.0"
+          message="The String literal {0} appears {1} times in this file; the first occurrence is on line {2}"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AvoidDuplicateLiteralsRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidduplicateliterals">
+        <description>
+            Code containing duplicate String literals can usually be improved by declaring the String as a constant field.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+private void bar() {
+     buz("Howdy");
+     buz("Howdy");
+     buz("Howdy");
+     buz("Howdy");
+}
+private void buz(String x) {}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidEnumAsIdentifier"
+          language="java"
+          since="3.4"
+          message="Avoid using enum as an identifier; it's a reserved word in JDK 1.5"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidenumasidentifier">
+        <description>
+            Use of the term 'enum' will conflict with newer versions of Java since it is a reserved word.
+        </description>
+        <priority>2</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>//VariableDeclaratorId[@Name='enum']</value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class A {
+    public class Foo {
+        String enum = "foo";
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidFieldNameMatchingMethodName"
+          language="java"
+          since="3.0"
+          message="Field {0} has the same name as a method"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AvoidFieldNameMatchingMethodNameRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidfieldnamematchingmethodname">
+        <description>
+            It can be confusing to have a field name with the same name as a method. While this is permitted,
+            having information (field) and actions (method) is not clear naming. Developers versed in
+            Smalltalk often prefer this approach as the methods denote accessor methods.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class Foo {
+    Object bar;
+    // bar is data or an action or both?
+    void bar() {
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidFieldNameMatchingTypeName"
+          language="java"
+          since="3.0"
+          message="It is somewhat confusing to have a field name matching the declaring class name"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AvoidFieldNameMatchingTypeNameRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidfieldnamematchingtypename">
+        <description>
+            It is somewhat confusing to have a field name matching the declaring type name.
+            This probably means that type and/or field names should be chosen more carefully.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class Foo extends Bar {
+    int foo;    // There is probably a better name that can be used
+}
+public interface Operation {
+    int OPERATION = 1; // There is probably a better name that can be used
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidInstanceofChecksInCatchClause"
+          language="java"
+          since="3.0"
+          message="An instanceof check is being performed on the caught exception.  Create a separate catch clause for this exception type."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidinstanceofchecksincatchclause">
+        <description>
+            Each caught exception type should be handled in its own catch clause.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//CatchStatement/FormalParameter
+ /following-sibling::Block//InstanceOfExpression/PrimaryExpression/PrimaryPrefix
+  /Name[
+   @Image = ./ancestor::Block/preceding-sibling::FormalParameter
+    /VariableDeclaratorId/@Name
+  ]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+try { // Avoid this
+    // do something
+} catch (Exception ee) {
+    if (ee instanceof IOException) {
+        cleanup();
+    }
+}
+
+try {  // Prefer this:
+    // do something
+} catch (IOException ee) {
+    cleanup();
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidLiteralsInIfCondition"
+          language="java"
+          since="4.2.6"
+          message="Avoid using Literals in Conditional Statements"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidliteralsinifcondition">
+        <description>
+            Avoid using hard-coded literals in conditional statements. By declaring them as static variables
+            or private members with descriptive names maintainability is enhanced. By default, the literals "-1" and "0" are ignored.
+            More exceptions can be defined with the property "ignoreMagicNumbers".
+
+            The rule doesn't consider deeper expressions by default, but this can be enabled via the property `ignoreExpressions`.
+            With this property set to false, if-conditions like `i == 1 + 5` are reported as well. Note that in that case,
+            the property ignoreMagicNumbers is not taken into account, if there are multiple literals involved in such an expression.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="ignoreMagicNumbers"
+                      description="Comma-separated list of magic numbers, that should be ignored"
+                      type="String" value="-1,0"/>
+            <property name="ignoreExpressions"
+                      description="If true, only literals in simple if conditions are considered. Otherwise literals in expressions are checked, too."
+                      type="Boolean" value="true"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+(: simple case - no deep expressions :)
+//IfStatement[$ignoreExpressions = true()]/Expression/*/PrimaryExpression/PrimaryPrefix/Literal
+    [not(NullLiteral)]
+    [not(BooleanLiteral)]
+    [empty(index-of(tokenize($ignoreMagicNumbers, '\s*,\s*'), @Image))]
+|
+(: consider also deeper expressions :)
+//IfStatement[$ignoreExpressions = false()]/Expression//*[local-name() != 'UnaryExpression' or @Operator != '-']/PrimaryExpression/PrimaryPrefix/Literal
+    [not(NullLiteral)]
+    [not(BooleanLiteral)]
+    [empty(index-of(tokenize($ignoreMagicNumbers, '\s*,\s*'), @Image))]
+|
+(: consider negative literals :)
+//IfStatement[$ignoreExpressions = false()]/Expression//UnaryExpression[@Operator = '-']/PrimaryExpression/PrimaryPrefix/Literal
+    [not(NullLiteral)]
+    [not(BooleanLiteral)]
+    [empty(index-of(tokenize($ignoreMagicNumbers, '\s*,\s*'), concat('-', @Image)))]
+|
+(: consider multiple literals in expressions :)
+//IfStatement[$ignoreExpressions = false()]/Expression[count(*/PrimaryExpression/PrimaryPrefix/Literal
+    [not(NullLiteral)]
+    [not(BooleanLiteral)]) > 1]
+]]>
+                </value>
+            </property>
+            <property name="version" value="2.0"/>
+        </properties>
+        <example>
+            <![CDATA[
+private static final int MAX_NUMBER_OF_REQUESTS = 10;
+
+public void checkRequests() {
+
+    if (i == 10) {                        // magic number, buried in a method
+      doSomething();
+    }
+
+    if (i == MAX_NUMBER_OF_REQUESTS) {    // preferred approach
+      doSomething();
+    }
+
+    if (aString.indexOf('.') != -1) {}     // magic number -1, by default ignored
+    if (aString.indexOf('.') >= 0) { }     // alternative approach
+
+    if (aDouble > 0.0) {}                  // magic number 0.0
+    if (aDouble >= Double.MIN_VALUE) {}    // preferred approach
+
+    // with rule property "ignoreExpressions" set to "false"
+    if (i == pos + 5) {}  // violation: magic number 5 within an (additive) expression
+    if (i == pos + SUFFIX_LENGTH) {} // preferred approach
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidLosingExceptionInformation"
+          since="4.2.6"
+          language="java"
+          message="Avoid statements in a catch block that invoke accessors on the exception without using the information"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidlosingexceptioninformation">
+        <description>
+            Statements in a catch block that invoke accessors on the exception without using the information
+            only add to code size.  Either remove the invocation, or use the return result.
+        </description>
+        <priority>2</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//CatchStatement/Block/BlockStatement/Statement/StatementExpression/PrimaryExpression/PrimaryPrefix/Name
+[
+   @Image = concat(../../../../../../../FormalParameter/VariableDeclaratorId/@Name, '.getMessage')
+   or
+   @Image = concat(../../../../../../../FormalParameter/VariableDeclaratorId/@Name, '.getLocalizedMessage')
+   or
+   @Image = concat(../../../../../../../FormalParameter/VariableDeclaratorId/@Name, '.getCause')
+   or
+   @Image = concat(../../../../../../../FormalParameter/VariableDeclaratorId/@Name, '.getStackTrace')
+   or
+   @Image = concat(../../../../../../../FormalParameter/VariableDeclaratorId/@Name, '.toString')
+]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public void bar() {
+    try {
+        // do something
+    } catch (SomeException se) {
+        se.getMessage();
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidMultipleUnaryOperators"
+          language="java"
+          since="4.2"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AvoidMultipleUnaryOperatorsRule"
+          message="Using multiple unary operators may be a bug, and/or is confusing."
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidmultipleunaryoperators">
+        <description>
+            The use of multiple unary operators may be problematic, and/or confusing.
+            Ensure that the intended usage is not a bug, or consider simplifying the expression.
+        </description>
+        <priority>2</priority>
+        <example>
+            <![CDATA[
+// These are typo bugs, or at best needlessly complex and confusing:
+int i = - -1;
+int j = + - +1;
+int z = ~~2;
+boolean b = !!true;
+boolean c = !!!true;
+
+// These are better:
+int i = 1;
+int j = -1;
+int z = 2;
+boolean b = true;
+boolean c = false;
+
+// And these just make your brain hurt:
+int i = ~-2;
+int j = -~7;
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidUsingOctalValues"
+          language="java"
+          since="3.9"
+          message="Do not start a literal by 0 unless it's an octal value"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AvoidUsingOctalValuesRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidusingoctalvalues">
+        <description>
+            Integer literals should not start with zero since this denotes that the rest of literal will be
+            interpreted as an octal value.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+int i = 012;    // set i with 10 not 12
+int j = 010;    // set j with 8 not 10
+k = i * j;      // set k with 80 not 120
+]]>
+        </example>
+    </rule>
+
+    <rule name="BadComparison" ref="ComparisonWithNaN" deprecated="true" />
+
+    <rule name="BeanMembersShouldSerialize"
+          language="java"
+          since="1.1"
+          message="Found non-transient, non-static member. Please mark as transient or provide accessors."
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.BeanMembersShouldSerializeRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#beanmembersshouldserialize">
+        <description>
+            If a class is a bean, or is referenced by a bean directly or indirectly it needs to be serializable.
+            Member variables need to be marked as transient, static, or have accessor methods in the class. Marking
+            variables as transient is the safest and easiest modification. Accessor methods should follow the Java
+            naming conventions, i.e. for a variable named foo, getFoo() and setFoo() accessor methods should be provided.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+private transient int someFoo;  // good, it's transient
+private static int otherFoo;    // also OK
+private int moreFoo;            // OK, has proper accessors, see below
+private int badFoo;             // bad, should be marked transient
+
+private void setMoreFoo(int moreFoo){
+      this.moreFoo = moreFoo;
+}
+
+private int getMoreFoo(){
+      return this.moreFoo;
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="BrokenNullCheck"
+          language="java"
+          since="3.8"
+          message="Method call on object which may be null"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.BrokenNullCheckRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#brokennullcheck">
+        <description>
+            The null check is broken since it will throw a NullPointerException itself.
+            It is likely that you used || instead of &amp;&amp; or vice versa.
+        </description>
+        <priority>2</priority>
+        <example>
+            <![CDATA[
+public String bar(String string) {
+  // should be &&
+    if (string!=null || !string.equals(""))
+        return string;
+  // should be ||
+    if (string==null && string.equals(""))
+        return string;
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="CallSuperFirst"
+          since="4.2.5"
+          language="java"
+          message="super should be called at the start of the method"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#callsuperfirst">
+        <description>Super should be called at the start of the method</description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//MethodDeclaration[
+  @Name='onCreate' or
+  @Name='onConfigurationChanged' or
+  @Name='onPostCreate' or
+  @Name='onPostResume' or
+  @Name='onRestart' or
+  @Name='onRestoreInstanceState' or
+  @Name='onResume' or
+  @Name='onStart'
+  ]
+    /Block[not(
+      (BlockStatement[1]/Statement/StatementExpression/PrimaryExpression[./PrimaryPrefix[@SuperModifier= true()]]/PrimarySuffix[@Image= ancestor::MethodDeclaration/@Name]))]
+[ancestor::ClassOrInterfaceDeclaration[ExtendsList/ClassOrInterfaceType[
+  pmd-java:typeIs('android.app.Activity') or
+  pmd-java:typeIs('android.app.Application') or
+  pmd-java:typeIs('android.app.Service')
+]]]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class DummyActivity extends Activity {
+    public void onCreate(Bundle bundle) {
+        // missing call to super.onCreate(bundle)
+        foo();
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="CallSuperLast"
+          since="4.2.5"
+          language="java"
+          message="super should be called at the end of the method"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#callsuperlast">
+        <description>
+            Super should be called at the end of the method
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//MethodDeclaration[
+  @Name='finish' or
+  @Name='onDestroy' or
+  @Name='onPause' or
+  @Name='onSaveInstanceState' or
+  @Name='onStop' or
+  @Name='onTerminate'
+  ]
+   /Block/BlockStatement[last()]
+    [not(Statement/StatementExpression/PrimaryExpression[./PrimaryPrefix[@SuperModifier= true()]]/PrimarySuffix[@Image= ancestor::MethodDeclaration/@Name])]
+[ancestor::ClassOrInterfaceDeclaration[ExtendsList/ClassOrInterfaceType[
+  pmd-java:typeIs('android.app.Activity') or
+  pmd-java:typeIs('android.app.Application') or
+  pmd-java:typeIs('android.app.Service')
+]]]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class DummyActivity extends Activity {
+    public void onPause() {
+        foo();
+        // missing call to super.onPause()
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="CheckSkipResult"
+          language="java"
+          since="5.0"
+          message="Check the value returned by the skip() method of an InputStream to see if the requested number of bytes has been skipped."
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.CheckSkipResultRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#checkskipresult">
+        <description>
+            The skip() method may skip a smaller number of bytes than requested. Check the returned value to find out if it was the case or not.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class Foo {
+
+   private FileInputStream _s = new FileInputStream("file");
+
+   public void skip(int n) throws IOException {
+      _s.skip(n); // You are not sure that exactly n bytes are skipped
+   }
+
+   public void skipExactly(int n) throws IOException {
+      while (n != 0) {
+         long skipped = _s.skip(n);
+         if (skipped == 0)
+            throw new EOFException();
+         n -= skipped;
+      }
+   }
+]]>
+        </example>
+    </rule>
+
+    <rule name="ClassCastExceptionWithToArray"
+          language="java"
+          since="3.4"
+          message="This usage of the Collection.toArray() method will throw a ClassCastException."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#classcastexceptionwithtoarray">
+        <description>
+            When deriving an array of a specific class from your Collection, one should provide an array of
+            the same class as the parameter of the toArray() method. Doing otherwise you will will result
+            in a ClassCastException.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//CastExpression[Type/ReferenceType/ClassOrInterfaceType[@Image != "Object"]]
+    /PrimaryExpression
+    [PrimaryPrefix/Name[ends-with(@Image, '.toArray')]]
+    [PrimarySuffix/Arguments[not(*)]]
+    [count(PrimarySuffix) = 1]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+Collection c = new ArrayList();
+Integer obj = new Integer(1);
+c.add(obj);
+
+    // this would trigger the rule (and throw a ClassCastException if executed)
+Integer[] a = (Integer [])c.toArray();
+
+   // this is fine and will not trigger the rule
+Integer[] b = (Integer [])c.toArray(new Integer[c.size()]);
+]]>
+        </example>
+    </rule>
+
+    <rule name="CloneMethodMustBePublic"
+          language="java"
+          since="5.4.0"
+          message="clone() method must be public if the class implements Cloneable"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#clonemethodmustbepublic">
+        <description>
+            The java Manual says "By convention, classes that implement this interface should override
+            Object.clone (which is protected) with a public method."
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//MethodDeclaration[@Public= false()]
+  [@Name = 'clone']
+  [@Arity = 0]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo implements Cloneable {
+    @Override
+    protected Object clone() throws CloneNotSupportedException { // Violation, must be public
+    }
+}
+
+public class Foo implements Cloneable {
+    @Override
+    protected Foo clone() { // Violation, must be public
+    }
+}
+
+public class Foo implements Cloneable {
+    @Override
+    public Object clone() // Ok
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="CloneMethodMustImplementCloneable"
+          language="java"
+          since="1.9"
+          message="clone() method should be implemented only if implementing Cloneable interface"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.CloneMethodMustImplementCloneableRule"
+          typeResolution="true"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#clonemethodmustimplementcloneable">
+        <description>
+            The method clone() should only be implemented if the class implements the Cloneable interface with the exception of
+            a final method that only throws CloneNotSupportedException.
+
+            The rule can also detect, if the class implements or extends a Cloneable class.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class MyClass {
+ public Object clone() throws CloneNotSupportedException {
+  return foo;
+ }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="CloneMethodReturnTypeMustMatchClassName"
+          language="java"
+          minimumLanguageVersion="1.5"
+          since="5.4.0"
+          message="The return type of the clone() method must be the class name when implements Cloneable"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#clonemethodreturntypemustmatchclassname">
+        <description>
+            If a class implements cloneable the return type of the method clone() must be the class name. That way, the caller
+            of the clone method doesn't need to cast the returned clone to the correct type.
+
+            Note: This is only possible with Java 1.5 or higher.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//MethodDeclaration
+[
+@Name = 'clone'
+and @Arity = 0
+and not (ResultType//ClassOrInterfaceType/@Image = ancestor::ClassOrInterfaceDeclaration[1]/@SimpleName)
+]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo implements Cloneable {
+    @Override
+    protected Object clone() { // Violation, Object must be Foo
+    }
+}
+
+public class Foo implements Cloneable {
+    @Override
+    public Foo clone() { //Ok
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="CloneThrowsCloneNotSupportedException"
+          deprecated="true"
+          language="java"
+          since="1.9"
+          message="clone() method should throw CloneNotSupportedException"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#clonethrowsclonenotsupportedexception">
+        <description>
+            The method clone() should throw a CloneNotSupportedException.
+
+            This rule is deprecated since PMD 6.35.0 without replacement. The rule has no real value as
+            `CloneNotSupportedException` is a checked exception and therefore you need to deal with it while
+            implementing the `clone()` method. You either need to declare the exception or catch it. If you catch it,
+            then subclasses can't throw it themselves explicitly. However, `Object.clone()` will still throw this
+            exception if the `Cloneable` interface is not implemented.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//MethodDeclaration
+[
+@Name = 'clone'
+and @Arity = 0
+and count(NameList/Name[contains
+(@Image,'CloneNotSupportedException')]) = 0
+]
+[
+../../../../ClassOrInterfaceDeclaration[@Final = false()]
+]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class MyClass implements Cloneable{
+    public Object clone() { // will cause an error
+         MyClass clone = (MyClass)super.clone();
+         return clone;
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="CloseResource"
+          language="java"
+          since="1.2.2"
+          message="Ensure that resources like this {0} object are closed after use"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.CloseResourceRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#closeresource">
+        <description>
+            Ensure that resources (like `java.sql.Connection`, `java.sql.Statement`, and `java.sql.ResultSet` objects
+            and any subtype of `java.lang.AutoCloseable`) are always closed after use.
+            Failing to do so might result in resource leaks.
+
+            Note: It suffices to configure the super type, e.g. `java.lang.AutoClosable`, so that this rule automatically triggers
+            on any subtype (e.g. `java.io.FileInputStream`). Additionally specifying `java.sql.Connection` helps in detecting
+            the types, if the type resolution / auxclasspath is not correctly setup.
+
+            Note: Since PMD 6.16.0 the default value for the property `types` contains `java.lang.AutoCloseable` and detects
+            now cases where the standard `java.io.*Stream` classes are involved. In order to restore the old behaviour,
+            just remove "AutoCloseable" from the types.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class Bar {
+    public void withSQL() {
+        Connection c = pool.getConnection();
+        try {
+            // do stuff
+        } catch (SQLException ex) {
+           // handle exception
+        } finally {
+            // oops, should close the connection using 'close'!
+            // c.close();
+        }
+    }
+
+    public void withFile() {
+        InputStream file = new FileInputStream(new File("/tmp/foo"));
+        try {
+            int c = file.in();
+        } catch (IOException e) {
+            // handle exception
+        } finally {
+            // TODO: close file
+        }
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="CompareObjectsWithEquals"
+          language="java"
+          since="3.2"
+          message="Use equals() to compare object references."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#compareobjectswithequals">
+        <description>
+            Use `equals()` to compare object references; avoid comparing them with `==`.
+
+            Since comparing objects with named constants is useful in some cases (eg, when
+            defining constants for sentinel values), the rule ignores comparisons against
+            fields with all-caps name (eg `this == SENTINEL`), which is a common naming
+            convention for constant fields.
+
+            You may allow some types to be compared by reference by listing the exceptions
+            in the `typesThatCompareByReference` property.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="typesThatCompareByReference" type="List[String]" delimiter="," description="List of canonical type names for which reference comparison is allowed.">
+                <value>java.lang.Enum,java.lang.Class</value>
+            </property>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//EqualityExpression
+    [count(
+        PrimaryExpression[pmd-java:typeIs('java.lang.Object')]
+        [not(some $t in $typesThatCompareByReference satisfies pmd-java:typeIs($t))]
+       ) = 2
+    ]
+    [not(PrimaryExpression[PrimaryPrefix/@ThisModifier = true()]
+                          [not(PrimarySuffix)]
+                          [ancestor::MethodDeclaration[@Name = 'equals']])
+    ]
+    (: Is not a field access with an all-caps identifier :)
+    [not(PrimaryExpression[not(PrimarySuffix) and PrimaryPrefix/Name[upper-case(@Image)=@Image]
+     or PrimaryExpression/PrimarySuffix[last()][upper-case(@Image)=@Image]])]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+class Foo {
+  boolean bar(String a, String b) {
+    return a == b;
+  }
+}
+
+]]>
+        </example>
+    </rule>
+
+    <rule name="ComparisonWithNaN"
+          language="java"
+          since="6.36.0"
+          message="Comparisons with NaN always return false"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#comparisonwithnan">
+        <description><![CDATA[
+            Reports comparisons with double and float `NaN` (Not-a-Number) values.
+            These are [specified](https://docs.oracle.com/javase/specs/jls/se8/html/jls-15.html#jls-15.21.1)
+            to have unintuitive behavior: NaN is considered unequal to itself.
+            This means a check like `someDouble == Double.NaN` will always return
+            false, even if `someDouble` is really the NaN value. To test whether a
+            value is the NaN value, one should instead use `Double.isNaN(someDouble)`
+            (or `Float.isNaN`). The `!=` operator should be treated similarly.
+            Finally, comparisons like `someDouble <= Double.NaN` are nonsensical
+            and will always evaluate to false.
+
+            This rule has been renamed from "BadComparison" with PMD 6.36.0.
+        ]]></description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+(//EqualityExpression | //RelationalExpression)/PrimaryExpression/PrimaryPrefix/Name[@Image='Double.NaN' or @Image='Float.NaN']
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+boolean x = (y == Double.NaN);
+]]>
+        </example>
+    </rule>
+
+
+    <rule name="ConstructorCallsOverridableMethod"
+          language="java"
+          since="1.04"
+          message="Overridable {0} called during object construction"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.ConstructorCallsOverridableMethodRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#constructorcallsoverridablemethod">
+        <description>
+            Calling overridable methods during construction poses a risk of invoking methods on an incompletely
+            constructed object and can be difficult to debug.
+            It may leave the sub-class unable to construct its superclass or forced to replicate the construction
+            process completely within itself, losing the ability to call super().  If the default constructor
+            contains a call to an overridable method, the subclass may be completely uninstantiable.   Note that
+            this includes method calls throughout the control flow graph - i.e., if a constructor Foo() calls a
+            private method bar() that calls a public method buz(), this denotes a problem.
+        </description>
+        <priority>1</priority>
+        <example>
+            <![CDATA[
+public class SeniorClass {
+  public SeniorClass(){
+      toString(); //may throw NullPointerException if overridden
+  }
+  public String toString(){
+    return "IAmSeniorClass";
+  }
+}
+public class JuniorClass extends SeniorClass {
+  private String name;
+  public JuniorClass(){
+    super(); //Automatic call leads to NullPointerException
+    name = "JuniorClass";
+  }
+  public String toString(){
+    return name.toUpperCase();
+  }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="DataflowAnomalyAnalysis"
+          language="java"
+          since="3.9"
+          message="Found ''{0}''-anomaly for variable ''{1}'' (lines ''{2}''-''{3}'')."
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.DataflowAnomalyAnalysisRule"
+          dfa="true"
+          deprecated="true"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#dataflowanomalyanalysis">
+        <description>The dataflow analysis tracks local definitions, undefinitions and references to variables on different paths on the data flow.
+            From those informations there can be found various problems.
+
+            1. DU - Anomaly: A recently defined variable is undefined. These anomalies may appear in normal source text.
+            2. DD - Anomaly: A recently defined variable is redefined. This is ominous but don't have to be a bug.
+
+            This rule is deprecated. Use {% rule "java/bestpractices/UnusedAssignment" %} in category bestpractices instead.
+        </description>
+        <priority>5</priority>
+        <example>
+            <![CDATA[
+public void foo() {
+  int buz = 5;
+  buz = 6; // redefinition of buz -> dd-anomaly
+  foo(buz);
+  buz = 2;
+} // buz is undefined when leaving scope -> du-anomaly
+]]>
+        </example>
+    </rule>
+
+    <rule name="DetachedTestCase"
+          language="java"
+          since="6.13.0"
+          message="Probable detached JUnit test case."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          typeResolution="true"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#detachedtestcase">
+        <description>
+            The method appears to be a test case since it has public or default visibility,
+            non-static access, no arguments, no return value, has no annotations, but is a
+            member of a class that has one or more JUnit test cases. If it is a utility
+            method, it should likely have private visibility. If it is an ignored test, it
+            should be annotated with @Test and @Ignore.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value><![CDATA[
+//ClassOrInterfaceBodyDeclaration
+[../ClassOrInterfaceBodyDeclaration/Annotation/*/Name
+        [pmd-java:typeIs('org.junit.Test')
+         or pmd-java:typeIs('org.junit.jupiter.api.Test')
+         or pmd-java:typeIs('org.junit.jupiter.api.RepeatedTest')
+         or pmd-java:typeIs('org.junit.jupiter.api.TestFactory')
+         or pmd-java:typeIs('org.junit.jupiter.api.TestTemplate')
+         or pmd-java:typeIs('org.junit.jupiter.params.ParameterizedTest')]
+]
+[not(Annotation)]
+[MethodDeclaration[(@Public = true() or @PackagePrivate = true()) and @Static = false() and
+        ResultType[@Void = true()] and
+        MethodDeclarator/FormalParameters[@Size = 0]
+    ]
+]
+]]></value>
+            </property>
+            <property name="version" value="2.0" />
+        </properties>
+        <example>
+            <![CDATA[
+public class MyTest {
+    @Test
+    public void someTest() {
+    }
+
+    // violation: Not annotated
+    public void someOtherTest () {
+    }
+
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="DoNotCallGarbageCollectionExplicitly"
+          language="java"
+          since="4.2"
+          message="Do not explicitly trigger a garbage collection."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#donotcallgarbagecollectionexplicitly">
+        <description>
+            Calls to System.gc(), Runtime.getRuntime().gc(), and System.runFinalization() are not advised. Code should have the
+            same behavior whether the garbage collection is disabled using the option -Xdisableexplicitgc or not.
+            Moreover, "modern" jvms do a very good job handling garbage collections. If memory usage issues unrelated to memory
+            leaks develop within an application, it should be dealt with JVM options rather than within the code itself.
+        </description>
+        <priority>2</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//Name[
+(starts-with(@Image, 'System.') and
+(starts-with(@Image, 'System.gc') or
+starts-with(@Image, 'System.runFinalization'))) or
+(
+starts-with(@Image,'Runtime.getRuntime') and
+../../PrimarySuffix[ends-with(@Image,'gc')]
+)
+]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class GCCall {
+    public GCCall() {
+        // Explicit gc call !
+        System.gc();
+    }
+
+    public void doSomething() {
+        // Explicit gc call !
+        Runtime.getRuntime().gc();
+    }
+
+    public explicitGCcall() {
+        // Explicit gc call !
+        System.gc();
+    }
+
+    public void doSomething() {
+        // Explicit gc call !
+        Runtime.getRuntime().gc();
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="DoNotCallSystemExit" ref="category/java/errorprone.xml/DoNotTerminateVM" deprecated="true" />
+
+    <rule name="DoNotExtendJavaLangThrowable"
+          language="java"
+          since="6.0.0"
+          message="Exceptions should not extend java.lang.Throwable"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#donotextendjavalangthrowable">
+        <description>
+            Extend Exception or RuntimeException instead of Throwable.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//ClassOrInterfaceDeclaration/ExtendsList/ClassOrInterfaceType
+  [@Image="Throwable" or @Image="java.lang.Throwable"]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo extends Throwable { }
+]]>
+        </example>
+    </rule>
+
+    <rule name="DoNotHardCodeSDCard"
+          since="4.2.6"
+          language="java"
+          message="Do not hardcode /sdcard."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#donothardcodesdcard">
+        <description>
+            Use Environment.getExternalStorageDirectory() instead of "/sdcard"
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>//Literal[starts-with(@Image,'"/sdcard')]</value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class MyActivity extends Activity {
+    protected void foo() {
+        String storageLocation = "/sdcard/mypackage";   // hard-coded, poor approach
+
+       storageLocation = Environment.getExternalStorageDirectory() + "/mypackage"; // preferred approach
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="DoNotTerminateVM"
+          language="java"
+          since="4.1"
+          message="System.exit() should not be used in J2EE/JEE apps"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#donotterminatevm">
+        <description>
+            Web applications should not call `System.exit()`, since only the web container or the
+            application server should stop the JVM. Otherwise a web application would terminate all other applications
+            running on the same application server.
+
+            This rule also checks for the equivalent calls `Runtime.getRuntime().exit()` and `Runtime.getRuntime().halt()`.
+
+            This rule was called *DoNotCallSystemExit* until PMD 6.29.0.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//Name[
+    starts-with(@Image,'System.exit')
+    or
+    (starts-with(@Image,'Runtime.getRuntime') and ../../PrimarySuffix[ends-with(@Image,'exit') or ends-with(@Image,'halt')])
+][not(ancestor::MethodDeclaration[1][@Name="main" and @Static = true()])]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public void bar() {
+    System.exit(0);                 // never call this when running in an application server!
+}
+public void foo() {
+    Runtime.getRuntime().exit(0);   // never stop the JVM manually, the container will do this.
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="DoNotThrowExceptionInFinally"
+          language="java"
+          since="4.2"
+          message="A throw statement in a finally block makes the control flow hard to understand."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#donotthrowexceptioninfinally">
+        <description>
+            Throwing exceptions within a 'finally' block is confusing since they may mask other exceptions
+            or code defects.
+            Note: This is a PMD implementation of the Lint4j rule "A throw in a finally block"
+        </description>
+        <priority>4</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>//FinallyStatement[descendant::ThrowStatement]</value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo {
+    public void bar() {
+        try {
+            // Here do some stuff
+        } catch( Exception e) {
+            // Handling the issue
+        } finally {
+            // is this really a good idea ?
+            throw new Exception();
+        }
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="DontImportSun"
+          language="java"
+          since="1.5"
+          message="Avoid importing anything from the 'sun.*' packages"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.DontImportSunRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#dontimportsun">
+        <description>
+            Avoid importing anything from the 'sun.*' packages.  These packages are not portable and are likely to change.
+        </description>
+        <priority>4</priority>
+        <example>
+            <![CDATA[
+import sun.misc.foo;
+public class Foo {}
+]]>
+        </example>
+    </rule>
+
+    <rule name="DontUseFloatTypeForLoopIndices"
+          language="java"
+          since="4.3"
+          message="Don't use floating point for loop indices. If you must use floating point, use double."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#dontusefloattypeforloopindices">
+        <description>
+            Don't use floating point for loop indices. If you must use floating point, use double
+            unless you're certain that float provides enough precision and you have a compelling
+            performance need (space or time).
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//ForStatement/ForInit/LocalVariableDeclaration
+/Type/PrimitiveType[@Image="float"]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Count {
+  public static void main(String[] args) {
+    final int START = 2000000000;
+    int count = 0;
+    for (float f = START; f < START + 50; f++)
+      count++;
+      //Prints 0 because (float) START == (float) (START + 50).
+      System.out.println(count);
+      //The termination test misbehaves due to floating point granularity.
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="EmptyCatchBlock"
+          language="java"
+          since="0.1"
+          message="Avoid empty catch blocks"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#emptycatchblock">
+        <description>
+            Empty Catch Block finds instances where an exception is caught, but nothing is done.
+            In most circumstances, this swallows an exception which should either be acted on
+            or reported.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//CatchStatement
+ [not(Block/BlockStatement)]
+ [$allowCommentedBlocks != true() or Block/@containsComment = false()]
+ [FormalParameter/Type/ReferenceType
+   /ClassOrInterfaceType[@Image != 'InterruptedException' and @Image != 'CloneNotSupportedException']
+ ]
+ [FormalParameter/VariableDeclaratorId[not(matches(@Name, $allowExceptionNameRegex))]]
+]]>
+                </value>
+            </property>
+            <property name="allowCommentedBlocks" type="Boolean" description="Empty blocks containing comments will be skipped" value="false"/>
+            <property name="allowExceptionNameRegex" type="String" description="Empty blocks catching exceptions with names matching this regular expression will be skipped" value="^(ignored|expected)$"/>
+        </properties>
+        <example>
+            <![CDATA[
+public void doSomething() {
+    try {
+        FileInputStream fis = new FileInputStream("/tmp/bugger");
+    } catch (IOException ioe) {
+        // not good
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="EmptyFinalizer"
+          language="java"
+          since="1.5"
+          message="Avoid empty finalize methods"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#emptyfinalizer">
+        <description>
+            Empty finalize methods serve no purpose and should be removed. Note that Oracle has declared Object.finalize() as deprecated since JDK 9.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//MethodDeclaration[@Name='finalize'][@Arity = 0]
+  /Block[not(*)]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo {
+   protected void finalize() {}
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="EmptyFinallyBlock"
+          language="java"
+          since="0.4"
+          message="Avoid empty finally blocks"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#emptyfinallyblock">
+        <description>
+            Empty finally blocks serve no purpose and should be removed.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//FinallyStatement[not(Block/BlockStatement)]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo {
+    public void bar() {
+        try {
+            int x=2;
+        } finally {
+            // empty!
+        }
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="EmptyIfStmt"
+          language="java"
+          since="0.1"
+          message="Avoid empty 'if' statements"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#emptyifstmt">
+        <description>
+            Empty If Statement finds instances where a condition is checked but nothing is done about it.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//IfStatement/Statement
+ [EmptyStatement or Block[not(*)]]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo {
+ void bar(int x) {
+  if (x == 0) {
+   // empty!
+  }
+ }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="EmptyInitializer"
+          language="java"
+          since="5.0"
+          message="Empty initializer was found"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#emptyinitializer">
+        <description>
+            Empty initializers serve no purpose and should be removed.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>//Initializer/Block[not(*)]</value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo {
+
+   static {} // Why ?
+
+   {} // Again, why ?
+
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="EmptyStatementBlock"
+          language="java"
+          since="5.0"
+          message="Avoid empty block statements."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#emptystatementblock">
+        <description>
+            Empty block statements serve no purpose and should be removed.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>//BlockStatement/Statement/Block[not(*)]</value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo {
+
+   private int _bar;
+
+   public void setBar(int bar) {
+      { _bar = bar; } // Why not?
+      {} // But remove this.
+   }
+
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="EmptyStatementNotInLoop"

Review comment:
       This rule is enabled in our repo

##########
File path: check-rules/errorprone.xml
##########
@@ -0,0 +1,3721 @@
+<?xml version="1.0"?>
+
+<ruleset name="Error Prone"
+         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 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">
+
+    <description>
+        Rules to detect constructs that are either broken, extremely confusing or prone to runtime errors.
+    </description>
+
+    <rule name="AssignmentInOperand"
+          language="java"
+          since="1.03"
+          message="Avoid assignments in operands"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AssignmentInOperandRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#assignmentinoperand">
+        <description>
+            Avoid assignments in operands; this can make code more complicated and harder to read.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public void bar() {
+    int x = 2;
+    if ((x = getX()) == 3) {
+      System.out.println("3!");
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AssignmentToNonFinalStatic"
+          language="java"
+          since="2.2"
+          message="Possible unsafe assignment to a non-final static field in a constructor."
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AssignmentToNonFinalStaticRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#assignmenttononfinalstatic">
+        <description>
+            Identifies a possible unsafe usage of a static field.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class StaticField {
+   static int x;
+   public FinalFields(int y) {
+    x = y; // unsafe
+   }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidAccessibilityAlteration"
+          language="java"
+          since="4.1"
+          message="You should not modify visibility of class or methods using getDeclaredConstructors(), getDeclaredConstructor(Class[]), setAccessible() or PrivilegedAction."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidaccessibilityalteration">
+        <description>
+            Methods such as getDeclaredConstructors(), getDeclaredConstructor(Class[]) and setAccessible(),
+            as the interface PrivilegedAction, allow for the runtime alteration of variable, class, or
+            method visibility, even if they are private. This violates the principle of encapsulation.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//PrimaryExpression[
+(
+(PrimarySuffix[
+        ends-with(@Image,'getDeclaredConstructors')
+                or
+        ends-with(@Image,'getDeclaredConstructor')
+                or
+        ends-with(@Image,'setAccessible')
+        ])
+or
+(PrimaryPrefix/Name[
+        ends-with(@Image,'getDeclaredConstructor')
+        or
+        ends-with(@Image,'getDeclaredConstructors')
+        or
+        starts-with(@Image,'AccessibleObject.setAccessible')
+        ])
+)
+and
+(//ImportDeclaration/Name[
+        contains(@Image,'java.security.PrivilegedAction')])
+]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Method;
+import java.security.PrivilegedAction;
+
+public class Violation {
+  public void invalidCallsInMethod() throws SecurityException, NoSuchMethodException {
+    // Possible call to forbidden getDeclaredConstructors
+    Class[] arrayOfClass = new Class[1];
+    this.getClass().getDeclaredConstructors();
+    this.getClass().getDeclaredConstructor(arrayOfClass);
+    Class clazz = this.getClass();
+    clazz.getDeclaredConstructor(arrayOfClass);
+    clazz.getDeclaredConstructors();
+      // Possible call to forbidden setAccessible
+    clazz.getMethod("", arrayOfClass).setAccessible(false);
+    AccessibleObject.setAccessible(null, false);
+    Method.setAccessible(null, false);
+    Method[] methodsArray = clazz.getMethods();
+    int nbMethod;
+    for ( nbMethod = 0; nbMethod < methodsArray.length; nbMethod++ ) {
+      methodsArray[nbMethod].setAccessible(false);
+    }
+
+      // Possible call to forbidden PrivilegedAction
+    PrivilegedAction priv = (PrivilegedAction) new Object(); priv.run();
+  }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidAssertAsIdentifier"
+          language="java"
+          since="3.4"
+          message="Avoid using assert as an identifier; it became a reserved word in JDK 1.4"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidassertasidentifier">
+        <description>
+            Use of the term 'assert' will conflict with newer versions of Java since it is a reserved word.
+        </description>
+        <priority>2</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>//VariableDeclaratorId[@Name='assert']</value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class A {
+    public class Foo {
+        String assert = "foo";
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidBranchingStatementAsLastInLoop"
+          language="java"
+          since="5.0"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AvoidBranchingStatementAsLastInLoopRule"
+          message="Avoid using a branching statement as the last in a loop."
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidbranchingstatementaslastinloop">
+        <description>
+            Using a branching statement as the last part of a loop may be a bug, and/or is confusing.
+            Ensure that the usage is not a bug, or consider using another approach.
+        </description>
+        <priority>2</priority>
+        <example>
+            <![CDATA[
+// unusual use of branching statement in a loop
+for (int i = 0; i < 10; i++) {
+    if (i*i <= 25) {
+        continue;
+    }
+    break;
+}
+
+// this makes more sense...
+for (int i = 0; i < 10; i++) {
+    if (i*i > 25) {
+        break;
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidCallingFinalize"
+          language="java"
+          since="3.0"
+          message="Avoid calling finalize() explicitly"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AvoidCallingFinalizeRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidcallingfinalize">
+        <description>
+            The method Object.finalize() is called by the garbage collector on an object when garbage collection determines
+            that there are no more references to the object. It should not be invoked by application logic.
+
+            Note that Oracle has declared Object.finalize() as deprecated since JDK 9.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+void foo() {
+    Bar b = new Bar();
+    b.finalize();
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidCatchingNPE"
+          language="java"
+          since="1.8"
+          message="Avoid catching NullPointerException; consider removing the cause of the NPE."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidcatchingnpe">
+        <description>
+            Code should never throw NullPointerExceptions under normal circumstances.  A catch block may hide the
+            original error, causing other, more subtle problems later on.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//CatchStatement/FormalParameter/Type
+ /ReferenceType/ClassOrInterfaceType[@Image='NullPointerException']
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo {
+    void bar() {
+        try {
+            // do something
+        } catch (NullPointerException npe) {
+        }
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidCatchingThrowable"
+          language="java"
+          since="1.2"
+          message="A catch statement should never catch throwable since it includes errors."
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AvoidCatchingThrowableRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidcatchingthrowable">
+        <description>
+            Catching Throwable errors is not recommended since its scope is very broad. It includes runtime issues such as
+            OutOfMemoryError that should be exposed and managed separately.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public void bar() {
+    try {
+        // do something
+    } catch (Throwable th) {  // should not catch Throwable
+        th.printStackTrace();
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidDecimalLiteralsInBigDecimalConstructor"
+          language="java"
+          since="3.4"
+          message="Avoid creating BigDecimal with a decimal (float/double) literal. Use a String literal"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoiddecimalliteralsinbigdecimalconstructor">
+        <description>
+            One might assume that the result of "new BigDecimal(0.1)" is exactly equal to 0.1, but it is actually
+            equal to .1000000000000000055511151231257827021181583404541015625.
+            This is because 0.1 cannot be represented exactly as a double (or as a binary fraction of any finite
+            length). Thus, the long value that is being passed in to the constructor is not exactly equal to 0.1,
+            appearances notwithstanding.
+
+            The (String) constructor, on the other hand, is perfectly predictable: 'new BigDecimal("0.1")' is
+            exactly equal to 0.1, as one would expect.  Therefore, it is generally recommended that the
+            (String) constructor be used in preference to this one.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//AllocationExpression[pmd-java:typeIs('java.math.BigDecimal')]
+[Arguments/ArgumentList/Expression/PrimaryExpression
+    [
+        pmd-java:typeIs('float') or
+        pmd-java:typeIs('java.lang.Float') or
+        pmd-java:typeIs('double') or
+        pmd-java:typeIs('java.lang.Double')
+    ]
+]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+BigDecimal bd = new BigDecimal(1.123);       // loss of precision, this would trigger the rule
+
+BigDecimal bd = new BigDecimal("1.123");     // preferred approach
+
+BigDecimal bd = new BigDecimal(12);          // preferred approach, ok for integer values
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidDuplicateLiterals"
+          language="java"
+          since="1.0"
+          message="The String literal {0} appears {1} times in this file; the first occurrence is on line {2}"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AvoidDuplicateLiteralsRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidduplicateliterals">
+        <description>
+            Code containing duplicate String literals can usually be improved by declaring the String as a constant field.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+private void bar() {
+     buz("Howdy");
+     buz("Howdy");
+     buz("Howdy");
+     buz("Howdy");
+}
+private void buz(String x) {}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidEnumAsIdentifier"
+          language="java"
+          since="3.4"
+          message="Avoid using enum as an identifier; it's a reserved word in JDK 1.5"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidenumasidentifier">
+        <description>
+            Use of the term 'enum' will conflict with newer versions of Java since it is a reserved word.
+        </description>
+        <priority>2</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>//VariableDeclaratorId[@Name='enum']</value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class A {
+    public class Foo {
+        String enum = "foo";
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidFieldNameMatchingMethodName"
+          language="java"
+          since="3.0"
+          message="Field {0} has the same name as a method"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AvoidFieldNameMatchingMethodNameRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidfieldnamematchingmethodname">
+        <description>
+            It can be confusing to have a field name with the same name as a method. While this is permitted,
+            having information (field) and actions (method) is not clear naming. Developers versed in
+            Smalltalk often prefer this approach as the methods denote accessor methods.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class Foo {
+    Object bar;
+    // bar is data or an action or both?
+    void bar() {
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidFieldNameMatchingTypeName"
+          language="java"
+          since="3.0"
+          message="It is somewhat confusing to have a field name matching the declaring class name"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AvoidFieldNameMatchingTypeNameRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidfieldnamematchingtypename">
+        <description>
+            It is somewhat confusing to have a field name matching the declaring type name.
+            This probably means that type and/or field names should be chosen more carefully.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class Foo extends Bar {
+    int foo;    // There is probably a better name that can be used
+}
+public interface Operation {
+    int OPERATION = 1; // There is probably a better name that can be used
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidInstanceofChecksInCatchClause"
+          language="java"
+          since="3.0"
+          message="An instanceof check is being performed on the caught exception.  Create a separate catch clause for this exception type."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidinstanceofchecksincatchclause">
+        <description>
+            Each caught exception type should be handled in its own catch clause.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//CatchStatement/FormalParameter
+ /following-sibling::Block//InstanceOfExpression/PrimaryExpression/PrimaryPrefix
+  /Name[
+   @Image = ./ancestor::Block/preceding-sibling::FormalParameter
+    /VariableDeclaratorId/@Name
+  ]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+try { // Avoid this
+    // do something
+} catch (Exception ee) {
+    if (ee instanceof IOException) {
+        cleanup();
+    }
+}
+
+try {  // Prefer this:
+    // do something
+} catch (IOException ee) {
+    cleanup();
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidLiteralsInIfCondition"
+          language="java"
+          since="4.2.6"
+          message="Avoid using Literals in Conditional Statements"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidliteralsinifcondition">
+        <description>
+            Avoid using hard-coded literals in conditional statements. By declaring them as static variables
+            or private members with descriptive names maintainability is enhanced. By default, the literals "-1" and "0" are ignored.
+            More exceptions can be defined with the property "ignoreMagicNumbers".
+
+            The rule doesn't consider deeper expressions by default, but this can be enabled via the property `ignoreExpressions`.
+            With this property set to false, if-conditions like `i == 1 + 5` are reported as well. Note that in that case,
+            the property ignoreMagicNumbers is not taken into account, if there are multiple literals involved in such an expression.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="ignoreMagicNumbers"
+                      description="Comma-separated list of magic numbers, that should be ignored"
+                      type="String" value="-1,0"/>
+            <property name="ignoreExpressions"
+                      description="If true, only literals in simple if conditions are considered. Otherwise literals in expressions are checked, too."
+                      type="Boolean" value="true"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+(: simple case - no deep expressions :)
+//IfStatement[$ignoreExpressions = true()]/Expression/*/PrimaryExpression/PrimaryPrefix/Literal
+    [not(NullLiteral)]
+    [not(BooleanLiteral)]
+    [empty(index-of(tokenize($ignoreMagicNumbers, '\s*,\s*'), @Image))]
+|
+(: consider also deeper expressions :)
+//IfStatement[$ignoreExpressions = false()]/Expression//*[local-name() != 'UnaryExpression' or @Operator != '-']/PrimaryExpression/PrimaryPrefix/Literal
+    [not(NullLiteral)]
+    [not(BooleanLiteral)]
+    [empty(index-of(tokenize($ignoreMagicNumbers, '\s*,\s*'), @Image))]
+|
+(: consider negative literals :)
+//IfStatement[$ignoreExpressions = false()]/Expression//UnaryExpression[@Operator = '-']/PrimaryExpression/PrimaryPrefix/Literal
+    [not(NullLiteral)]
+    [not(BooleanLiteral)]
+    [empty(index-of(tokenize($ignoreMagicNumbers, '\s*,\s*'), concat('-', @Image)))]
+|
+(: consider multiple literals in expressions :)
+//IfStatement[$ignoreExpressions = false()]/Expression[count(*/PrimaryExpression/PrimaryPrefix/Literal
+    [not(NullLiteral)]
+    [not(BooleanLiteral)]) > 1]
+]]>
+                </value>
+            </property>
+            <property name="version" value="2.0"/>
+        </properties>
+        <example>
+            <![CDATA[
+private static final int MAX_NUMBER_OF_REQUESTS = 10;
+
+public void checkRequests() {
+
+    if (i == 10) {                        // magic number, buried in a method
+      doSomething();
+    }
+
+    if (i == MAX_NUMBER_OF_REQUESTS) {    // preferred approach
+      doSomething();
+    }
+
+    if (aString.indexOf('.') != -1) {}     // magic number -1, by default ignored
+    if (aString.indexOf('.') >= 0) { }     // alternative approach
+
+    if (aDouble > 0.0) {}                  // magic number 0.0
+    if (aDouble >= Double.MIN_VALUE) {}    // preferred approach
+
+    // with rule property "ignoreExpressions" set to "false"
+    if (i == pos + 5) {}  // violation: magic number 5 within an (additive) expression
+    if (i == pos + SUFFIX_LENGTH) {} // preferred approach
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidLosingExceptionInformation"
+          since="4.2.6"
+          language="java"
+          message="Avoid statements in a catch block that invoke accessors on the exception without using the information"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidlosingexceptioninformation">
+        <description>
+            Statements in a catch block that invoke accessors on the exception without using the information
+            only add to code size.  Either remove the invocation, or use the return result.
+        </description>
+        <priority>2</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//CatchStatement/Block/BlockStatement/Statement/StatementExpression/PrimaryExpression/PrimaryPrefix/Name
+[
+   @Image = concat(../../../../../../../FormalParameter/VariableDeclaratorId/@Name, '.getMessage')
+   or
+   @Image = concat(../../../../../../../FormalParameter/VariableDeclaratorId/@Name, '.getLocalizedMessage')
+   or
+   @Image = concat(../../../../../../../FormalParameter/VariableDeclaratorId/@Name, '.getCause')
+   or
+   @Image = concat(../../../../../../../FormalParameter/VariableDeclaratorId/@Name, '.getStackTrace')
+   or
+   @Image = concat(../../../../../../../FormalParameter/VariableDeclaratorId/@Name, '.toString')
+]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public void bar() {
+    try {
+        // do something
+    } catch (SomeException se) {
+        se.getMessage();
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidMultipleUnaryOperators"
+          language="java"
+          since="4.2"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AvoidMultipleUnaryOperatorsRule"
+          message="Using multiple unary operators may be a bug, and/or is confusing."
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidmultipleunaryoperators">
+        <description>
+            The use of multiple unary operators may be problematic, and/or confusing.
+            Ensure that the intended usage is not a bug, or consider simplifying the expression.
+        </description>
+        <priority>2</priority>
+        <example>
+            <![CDATA[
+// These are typo bugs, or at best needlessly complex and confusing:
+int i = - -1;
+int j = + - +1;
+int z = ~~2;
+boolean b = !!true;
+boolean c = !!!true;
+
+// These are better:
+int i = 1;
+int j = -1;
+int z = 2;
+boolean b = true;
+boolean c = false;
+
+// And these just make your brain hurt:
+int i = ~-2;
+int j = -~7;
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidUsingOctalValues"
+          language="java"
+          since="3.9"
+          message="Do not start a literal by 0 unless it's an octal value"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AvoidUsingOctalValuesRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidusingoctalvalues">
+        <description>
+            Integer literals should not start with zero since this denotes that the rest of literal will be
+            interpreted as an octal value.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+int i = 012;    // set i with 10 not 12
+int j = 010;    // set j with 8 not 10
+k = i * j;      // set k with 80 not 120
+]]>
+        </example>
+    </rule>
+
+    <rule name="BadComparison" ref="ComparisonWithNaN" deprecated="true" />
+
+    <rule name="BeanMembersShouldSerialize"
+          language="java"
+          since="1.1"
+          message="Found non-transient, non-static member. Please mark as transient or provide accessors."
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.BeanMembersShouldSerializeRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#beanmembersshouldserialize">
+        <description>
+            If a class is a bean, or is referenced by a bean directly or indirectly it needs to be serializable.
+            Member variables need to be marked as transient, static, or have accessor methods in the class. Marking
+            variables as transient is the safest and easiest modification. Accessor methods should follow the Java
+            naming conventions, i.e. for a variable named foo, getFoo() and setFoo() accessor methods should be provided.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+private transient int someFoo;  // good, it's transient
+private static int otherFoo;    // also OK
+private int moreFoo;            // OK, has proper accessors, see below
+private int badFoo;             // bad, should be marked transient
+
+private void setMoreFoo(int moreFoo){
+      this.moreFoo = moreFoo;
+}
+
+private int getMoreFoo(){
+      return this.moreFoo;
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="BrokenNullCheck"

Review comment:
       This rule is enabled in our repo 

##########
File path: check-rules/errorprone.xml
##########
@@ -0,0 +1,3721 @@
+<?xml version="1.0"?>
+
+<ruleset name="Error Prone"
+         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 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">
+
+    <description>
+        Rules to detect constructs that are either broken, extremely confusing or prone to runtime errors.
+    </description>
+
+    <rule name="AssignmentInOperand"
+          language="java"
+          since="1.03"
+          message="Avoid assignments in operands"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AssignmentInOperandRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#assignmentinoperand">
+        <description>
+            Avoid assignments in operands; this can make code more complicated and harder to read.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public void bar() {
+    int x = 2;
+    if ((x = getX()) == 3) {
+      System.out.println("3!");
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AssignmentToNonFinalStatic"
+          language="java"
+          since="2.2"
+          message="Possible unsafe assignment to a non-final static field in a constructor."
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AssignmentToNonFinalStaticRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#assignmenttononfinalstatic">
+        <description>
+            Identifies a possible unsafe usage of a static field.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class StaticField {
+   static int x;
+   public FinalFields(int y) {
+    x = y; // unsafe
+   }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidAccessibilityAlteration"
+          language="java"
+          since="4.1"
+          message="You should not modify visibility of class or methods using getDeclaredConstructors(), getDeclaredConstructor(Class[]), setAccessible() or PrivilegedAction."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidaccessibilityalteration">
+        <description>
+            Methods such as getDeclaredConstructors(), getDeclaredConstructor(Class[]) and setAccessible(),
+            as the interface PrivilegedAction, allow for the runtime alteration of variable, class, or
+            method visibility, even if they are private. This violates the principle of encapsulation.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//PrimaryExpression[
+(
+(PrimarySuffix[
+        ends-with(@Image,'getDeclaredConstructors')
+                or
+        ends-with(@Image,'getDeclaredConstructor')
+                or
+        ends-with(@Image,'setAccessible')
+        ])
+or
+(PrimaryPrefix/Name[
+        ends-with(@Image,'getDeclaredConstructor')
+        or
+        ends-with(@Image,'getDeclaredConstructors')
+        or
+        starts-with(@Image,'AccessibleObject.setAccessible')
+        ])
+)
+and
+(//ImportDeclaration/Name[
+        contains(@Image,'java.security.PrivilegedAction')])
+]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Method;
+import java.security.PrivilegedAction;
+
+public class Violation {
+  public void invalidCallsInMethod() throws SecurityException, NoSuchMethodException {
+    // Possible call to forbidden getDeclaredConstructors
+    Class[] arrayOfClass = new Class[1];
+    this.getClass().getDeclaredConstructors();
+    this.getClass().getDeclaredConstructor(arrayOfClass);
+    Class clazz = this.getClass();
+    clazz.getDeclaredConstructor(arrayOfClass);
+    clazz.getDeclaredConstructors();
+      // Possible call to forbidden setAccessible
+    clazz.getMethod("", arrayOfClass).setAccessible(false);
+    AccessibleObject.setAccessible(null, false);
+    Method.setAccessible(null, false);
+    Method[] methodsArray = clazz.getMethods();
+    int nbMethod;
+    for ( nbMethod = 0; nbMethod < methodsArray.length; nbMethod++ ) {
+      methodsArray[nbMethod].setAccessible(false);
+    }
+
+      // Possible call to forbidden PrivilegedAction
+    PrivilegedAction priv = (PrivilegedAction) new Object(); priv.run();
+  }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidAssertAsIdentifier"
+          language="java"
+          since="3.4"
+          message="Avoid using assert as an identifier; it became a reserved word in JDK 1.4"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidassertasidentifier">
+        <description>
+            Use of the term 'assert' will conflict with newer versions of Java since it is a reserved word.
+        </description>
+        <priority>2</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>//VariableDeclaratorId[@Name='assert']</value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class A {
+    public class Foo {
+        String assert = "foo";
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidBranchingStatementAsLastInLoop"
+          language="java"
+          since="5.0"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AvoidBranchingStatementAsLastInLoopRule"
+          message="Avoid using a branching statement as the last in a loop."
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidbranchingstatementaslastinloop">
+        <description>
+            Using a branching statement as the last part of a loop may be a bug, and/or is confusing.
+            Ensure that the usage is not a bug, or consider using another approach.
+        </description>
+        <priority>2</priority>
+        <example>
+            <![CDATA[
+// unusual use of branching statement in a loop
+for (int i = 0; i < 10; i++) {
+    if (i*i <= 25) {
+        continue;
+    }
+    break;
+}
+
+// this makes more sense...
+for (int i = 0; i < 10; i++) {
+    if (i*i > 25) {
+        break;
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidCallingFinalize"
+          language="java"
+          since="3.0"
+          message="Avoid calling finalize() explicitly"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AvoidCallingFinalizeRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidcallingfinalize">
+        <description>
+            The method Object.finalize() is called by the garbage collector on an object when garbage collection determines
+            that there are no more references to the object. It should not be invoked by application logic.
+
+            Note that Oracle has declared Object.finalize() as deprecated since JDK 9.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+void foo() {
+    Bar b = new Bar();
+    b.finalize();
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidCatchingNPE"
+          language="java"
+          since="1.8"
+          message="Avoid catching NullPointerException; consider removing the cause of the NPE."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidcatchingnpe">
+        <description>
+            Code should never throw NullPointerExceptions under normal circumstances.  A catch block may hide the
+            original error, causing other, more subtle problems later on.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//CatchStatement/FormalParameter/Type
+ /ReferenceType/ClassOrInterfaceType[@Image='NullPointerException']
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo {
+    void bar() {
+        try {
+            // do something
+        } catch (NullPointerException npe) {
+        }
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidCatchingThrowable"
+          language="java"
+          since="1.2"
+          message="A catch statement should never catch throwable since it includes errors."
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AvoidCatchingThrowableRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidcatchingthrowable">
+        <description>
+            Catching Throwable errors is not recommended since its scope is very broad. It includes runtime issues such as
+            OutOfMemoryError that should be exposed and managed separately.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public void bar() {
+    try {
+        // do something
+    } catch (Throwable th) {  // should not catch Throwable
+        th.printStackTrace();
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidDecimalLiteralsInBigDecimalConstructor"
+          language="java"
+          since="3.4"
+          message="Avoid creating BigDecimal with a decimal (float/double) literal. Use a String literal"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoiddecimalliteralsinbigdecimalconstructor">
+        <description>
+            One might assume that the result of "new BigDecimal(0.1)" is exactly equal to 0.1, but it is actually
+            equal to .1000000000000000055511151231257827021181583404541015625.
+            This is because 0.1 cannot be represented exactly as a double (or as a binary fraction of any finite
+            length). Thus, the long value that is being passed in to the constructor is not exactly equal to 0.1,
+            appearances notwithstanding.
+
+            The (String) constructor, on the other hand, is perfectly predictable: 'new BigDecimal("0.1")' is
+            exactly equal to 0.1, as one would expect.  Therefore, it is generally recommended that the
+            (String) constructor be used in preference to this one.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//AllocationExpression[pmd-java:typeIs('java.math.BigDecimal')]
+[Arguments/ArgumentList/Expression/PrimaryExpression
+    [
+        pmd-java:typeIs('float') or
+        pmd-java:typeIs('java.lang.Float') or
+        pmd-java:typeIs('double') or
+        pmd-java:typeIs('java.lang.Double')
+    ]
+]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+BigDecimal bd = new BigDecimal(1.123);       // loss of precision, this would trigger the rule
+
+BigDecimal bd = new BigDecimal("1.123");     // preferred approach
+
+BigDecimal bd = new BigDecimal(12);          // preferred approach, ok for integer values
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidDuplicateLiterals"
+          language="java"
+          since="1.0"
+          message="The String literal {0} appears {1} times in this file; the first occurrence is on line {2}"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AvoidDuplicateLiteralsRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidduplicateliterals">
+        <description>
+            Code containing duplicate String literals can usually be improved by declaring the String as a constant field.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+private void bar() {
+     buz("Howdy");
+     buz("Howdy");
+     buz("Howdy");
+     buz("Howdy");
+}
+private void buz(String x) {}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidEnumAsIdentifier"
+          language="java"
+          since="3.4"
+          message="Avoid using enum as an identifier; it's a reserved word in JDK 1.5"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidenumasidentifier">
+        <description>
+            Use of the term 'enum' will conflict with newer versions of Java since it is a reserved word.
+        </description>
+        <priority>2</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>//VariableDeclaratorId[@Name='enum']</value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class A {
+    public class Foo {
+        String enum = "foo";
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidFieldNameMatchingMethodName"
+          language="java"
+          since="3.0"
+          message="Field {0} has the same name as a method"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AvoidFieldNameMatchingMethodNameRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidfieldnamematchingmethodname">
+        <description>
+            It can be confusing to have a field name with the same name as a method. While this is permitted,
+            having information (field) and actions (method) is not clear naming. Developers versed in
+            Smalltalk often prefer this approach as the methods denote accessor methods.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class Foo {
+    Object bar;
+    // bar is data or an action or both?
+    void bar() {
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidFieldNameMatchingTypeName"
+          language="java"
+          since="3.0"
+          message="It is somewhat confusing to have a field name matching the declaring class name"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AvoidFieldNameMatchingTypeNameRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidfieldnamematchingtypename">
+        <description>
+            It is somewhat confusing to have a field name matching the declaring type name.
+            This probably means that type and/or field names should be chosen more carefully.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class Foo extends Bar {
+    int foo;    // There is probably a better name that can be used
+}
+public interface Operation {
+    int OPERATION = 1; // There is probably a better name that can be used
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidInstanceofChecksInCatchClause"
+          language="java"
+          since="3.0"
+          message="An instanceof check is being performed on the caught exception.  Create a separate catch clause for this exception type."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidinstanceofchecksincatchclause">
+        <description>
+            Each caught exception type should be handled in its own catch clause.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//CatchStatement/FormalParameter
+ /following-sibling::Block//InstanceOfExpression/PrimaryExpression/PrimaryPrefix
+  /Name[
+   @Image = ./ancestor::Block/preceding-sibling::FormalParameter
+    /VariableDeclaratorId/@Name
+  ]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+try { // Avoid this
+    // do something
+} catch (Exception ee) {
+    if (ee instanceof IOException) {
+        cleanup();
+    }
+}
+
+try {  // Prefer this:
+    // do something
+} catch (IOException ee) {
+    cleanup();
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidLiteralsInIfCondition"
+          language="java"
+          since="4.2.6"
+          message="Avoid using Literals in Conditional Statements"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidliteralsinifcondition">
+        <description>
+            Avoid using hard-coded literals in conditional statements. By declaring them as static variables
+            or private members with descriptive names maintainability is enhanced. By default, the literals "-1" and "0" are ignored.
+            More exceptions can be defined with the property "ignoreMagicNumbers".
+
+            The rule doesn't consider deeper expressions by default, but this can be enabled via the property `ignoreExpressions`.
+            With this property set to false, if-conditions like `i == 1 + 5` are reported as well. Note that in that case,
+            the property ignoreMagicNumbers is not taken into account, if there are multiple literals involved in such an expression.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="ignoreMagicNumbers"
+                      description="Comma-separated list of magic numbers, that should be ignored"
+                      type="String" value="-1,0"/>
+            <property name="ignoreExpressions"
+                      description="If true, only literals in simple if conditions are considered. Otherwise literals in expressions are checked, too."
+                      type="Boolean" value="true"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+(: simple case - no deep expressions :)
+//IfStatement[$ignoreExpressions = true()]/Expression/*/PrimaryExpression/PrimaryPrefix/Literal
+    [not(NullLiteral)]
+    [not(BooleanLiteral)]
+    [empty(index-of(tokenize($ignoreMagicNumbers, '\s*,\s*'), @Image))]
+|
+(: consider also deeper expressions :)
+//IfStatement[$ignoreExpressions = false()]/Expression//*[local-name() != 'UnaryExpression' or @Operator != '-']/PrimaryExpression/PrimaryPrefix/Literal
+    [not(NullLiteral)]
+    [not(BooleanLiteral)]
+    [empty(index-of(tokenize($ignoreMagicNumbers, '\s*,\s*'), @Image))]
+|
+(: consider negative literals :)
+//IfStatement[$ignoreExpressions = false()]/Expression//UnaryExpression[@Operator = '-']/PrimaryExpression/PrimaryPrefix/Literal
+    [not(NullLiteral)]
+    [not(BooleanLiteral)]
+    [empty(index-of(tokenize($ignoreMagicNumbers, '\s*,\s*'), concat('-', @Image)))]
+|
+(: consider multiple literals in expressions :)
+//IfStatement[$ignoreExpressions = false()]/Expression[count(*/PrimaryExpression/PrimaryPrefix/Literal
+    [not(NullLiteral)]
+    [not(BooleanLiteral)]) > 1]
+]]>
+                </value>
+            </property>
+            <property name="version" value="2.0"/>
+        </properties>
+        <example>
+            <![CDATA[
+private static final int MAX_NUMBER_OF_REQUESTS = 10;
+
+public void checkRequests() {
+
+    if (i == 10) {                        // magic number, buried in a method
+      doSomething();
+    }
+
+    if (i == MAX_NUMBER_OF_REQUESTS) {    // preferred approach
+      doSomething();
+    }
+
+    if (aString.indexOf('.') != -1) {}     // magic number -1, by default ignored
+    if (aString.indexOf('.') >= 0) { }     // alternative approach
+
+    if (aDouble > 0.0) {}                  // magic number 0.0
+    if (aDouble >= Double.MIN_VALUE) {}    // preferred approach
+
+    // with rule property "ignoreExpressions" set to "false"
+    if (i == pos + 5) {}  // violation: magic number 5 within an (additive) expression
+    if (i == pos + SUFFIX_LENGTH) {} // preferred approach
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidLosingExceptionInformation"
+          since="4.2.6"
+          language="java"
+          message="Avoid statements in a catch block that invoke accessors on the exception without using the information"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidlosingexceptioninformation">
+        <description>
+            Statements in a catch block that invoke accessors on the exception without using the information
+            only add to code size.  Either remove the invocation, or use the return result.
+        </description>
+        <priority>2</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//CatchStatement/Block/BlockStatement/Statement/StatementExpression/PrimaryExpression/PrimaryPrefix/Name
+[
+   @Image = concat(../../../../../../../FormalParameter/VariableDeclaratorId/@Name, '.getMessage')
+   or
+   @Image = concat(../../../../../../../FormalParameter/VariableDeclaratorId/@Name, '.getLocalizedMessage')
+   or
+   @Image = concat(../../../../../../../FormalParameter/VariableDeclaratorId/@Name, '.getCause')
+   or
+   @Image = concat(../../../../../../../FormalParameter/VariableDeclaratorId/@Name, '.getStackTrace')
+   or
+   @Image = concat(../../../../../../../FormalParameter/VariableDeclaratorId/@Name, '.toString')
+]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public void bar() {
+    try {
+        // do something
+    } catch (SomeException se) {
+        se.getMessage();
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidMultipleUnaryOperators"
+          language="java"
+          since="4.2"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AvoidMultipleUnaryOperatorsRule"
+          message="Using multiple unary operators may be a bug, and/or is confusing."
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidmultipleunaryoperators">
+        <description>
+            The use of multiple unary operators may be problematic, and/or confusing.
+            Ensure that the intended usage is not a bug, or consider simplifying the expression.
+        </description>
+        <priority>2</priority>
+        <example>
+            <![CDATA[
+// These are typo bugs, or at best needlessly complex and confusing:
+int i = - -1;
+int j = + - +1;
+int z = ~~2;
+boolean b = !!true;
+boolean c = !!!true;
+
+// These are better:
+int i = 1;
+int j = -1;
+int z = 2;
+boolean b = true;
+boolean c = false;
+
+// And these just make your brain hurt:
+int i = ~-2;
+int j = -~7;
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidUsingOctalValues"
+          language="java"
+          since="3.9"
+          message="Do not start a literal by 0 unless it's an octal value"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AvoidUsingOctalValuesRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidusingoctalvalues">
+        <description>
+            Integer literals should not start with zero since this denotes that the rest of literal will be
+            interpreted as an octal value.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+int i = 012;    // set i with 10 not 12
+int j = 010;    // set j with 8 not 10
+k = i * j;      // set k with 80 not 120
+]]>
+        </example>
+    </rule>
+
+    <rule name="BadComparison" ref="ComparisonWithNaN" deprecated="true" />
+
+    <rule name="BeanMembersShouldSerialize"
+          language="java"
+          since="1.1"
+          message="Found non-transient, non-static member. Please mark as transient or provide accessors."
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.BeanMembersShouldSerializeRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#beanmembersshouldserialize">
+        <description>
+            If a class is a bean, or is referenced by a bean directly or indirectly it needs to be serializable.
+            Member variables need to be marked as transient, static, or have accessor methods in the class. Marking
+            variables as transient is the safest and easiest modification. Accessor methods should follow the Java
+            naming conventions, i.e. for a variable named foo, getFoo() and setFoo() accessor methods should be provided.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+private transient int someFoo;  // good, it's transient
+private static int otherFoo;    // also OK
+private int moreFoo;            // OK, has proper accessors, see below
+private int badFoo;             // bad, should be marked transient
+
+private void setMoreFoo(int moreFoo){
+      this.moreFoo = moreFoo;
+}
+
+private int getMoreFoo(){
+      return this.moreFoo;
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="BrokenNullCheck"
+          language="java"
+          since="3.8"
+          message="Method call on object which may be null"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.BrokenNullCheckRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#brokennullcheck">
+        <description>
+            The null check is broken since it will throw a NullPointerException itself.
+            It is likely that you used || instead of &amp;&amp; or vice versa.
+        </description>
+        <priority>2</priority>
+        <example>
+            <![CDATA[
+public String bar(String string) {
+  // should be &&
+    if (string!=null || !string.equals(""))
+        return string;
+  // should be ||
+    if (string==null && string.equals(""))
+        return string;
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="CallSuperFirst"
+          since="4.2.5"
+          language="java"
+          message="super should be called at the start of the method"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#callsuperfirst">
+        <description>Super should be called at the start of the method</description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//MethodDeclaration[
+  @Name='onCreate' or
+  @Name='onConfigurationChanged' or
+  @Name='onPostCreate' or
+  @Name='onPostResume' or
+  @Name='onRestart' or
+  @Name='onRestoreInstanceState' or
+  @Name='onResume' or
+  @Name='onStart'
+  ]
+    /Block[not(
+      (BlockStatement[1]/Statement/StatementExpression/PrimaryExpression[./PrimaryPrefix[@SuperModifier= true()]]/PrimarySuffix[@Image= ancestor::MethodDeclaration/@Name]))]
+[ancestor::ClassOrInterfaceDeclaration[ExtendsList/ClassOrInterfaceType[
+  pmd-java:typeIs('android.app.Activity') or
+  pmd-java:typeIs('android.app.Application') or
+  pmd-java:typeIs('android.app.Service')
+]]]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class DummyActivity extends Activity {
+    public void onCreate(Bundle bundle) {
+        // missing call to super.onCreate(bundle)
+        foo();
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="CallSuperLast"
+          since="4.2.5"
+          language="java"
+          message="super should be called at the end of the method"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#callsuperlast">
+        <description>
+            Super should be called at the end of the method
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//MethodDeclaration[
+  @Name='finish' or
+  @Name='onDestroy' or
+  @Name='onPause' or
+  @Name='onSaveInstanceState' or
+  @Name='onStop' or
+  @Name='onTerminate'
+  ]
+   /Block/BlockStatement[last()]
+    [not(Statement/StatementExpression/PrimaryExpression[./PrimaryPrefix[@SuperModifier= true()]]/PrimarySuffix[@Image= ancestor::MethodDeclaration/@Name])]
+[ancestor::ClassOrInterfaceDeclaration[ExtendsList/ClassOrInterfaceType[
+  pmd-java:typeIs('android.app.Activity') or
+  pmd-java:typeIs('android.app.Application') or
+  pmd-java:typeIs('android.app.Service')
+]]]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class DummyActivity extends Activity {
+    public void onPause() {
+        foo();
+        // missing call to super.onPause()
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="CheckSkipResult"
+          language="java"
+          since="5.0"
+          message="Check the value returned by the skip() method of an InputStream to see if the requested number of bytes has been skipped."
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.CheckSkipResultRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#checkskipresult">
+        <description>
+            The skip() method may skip a smaller number of bytes than requested. Check the returned value to find out if it was the case or not.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class Foo {
+
+   private FileInputStream _s = new FileInputStream("file");
+
+   public void skip(int n) throws IOException {
+      _s.skip(n); // You are not sure that exactly n bytes are skipped
+   }
+
+   public void skipExactly(int n) throws IOException {
+      while (n != 0) {
+         long skipped = _s.skip(n);
+         if (skipped == 0)
+            throw new EOFException();
+         n -= skipped;
+      }
+   }
+]]>
+        </example>
+    </rule>
+
+    <rule name="ClassCastExceptionWithToArray"
+          language="java"
+          since="3.4"
+          message="This usage of the Collection.toArray() method will throw a ClassCastException."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#classcastexceptionwithtoarray">
+        <description>
+            When deriving an array of a specific class from your Collection, one should provide an array of
+            the same class as the parameter of the toArray() method. Doing otherwise you will will result
+            in a ClassCastException.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//CastExpression[Type/ReferenceType/ClassOrInterfaceType[@Image != "Object"]]
+    /PrimaryExpression
+    [PrimaryPrefix/Name[ends-with(@Image, '.toArray')]]
+    [PrimarySuffix/Arguments[not(*)]]
+    [count(PrimarySuffix) = 1]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+Collection c = new ArrayList();
+Integer obj = new Integer(1);
+c.add(obj);
+
+    // this would trigger the rule (and throw a ClassCastException if executed)
+Integer[] a = (Integer [])c.toArray();
+
+   // this is fine and will not trigger the rule
+Integer[] b = (Integer [])c.toArray(new Integer[c.size()]);
+]]>
+        </example>
+    </rule>
+
+    <rule name="CloneMethodMustBePublic"
+          language="java"
+          since="5.4.0"
+          message="clone() method must be public if the class implements Cloneable"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#clonemethodmustbepublic">
+        <description>
+            The java Manual says "By convention, classes that implement this interface should override
+            Object.clone (which is protected) with a public method."
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//MethodDeclaration[@Public= false()]
+  [@Name = 'clone']
+  [@Arity = 0]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo implements Cloneable {
+    @Override
+    protected Object clone() throws CloneNotSupportedException { // Violation, must be public
+    }
+}
+
+public class Foo implements Cloneable {
+    @Override
+    protected Foo clone() { // Violation, must be public
+    }
+}
+
+public class Foo implements Cloneable {
+    @Override
+    public Object clone() // Ok
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="CloneMethodMustImplementCloneable"
+          language="java"
+          since="1.9"
+          message="clone() method should be implemented only if implementing Cloneable interface"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.CloneMethodMustImplementCloneableRule"
+          typeResolution="true"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#clonemethodmustimplementcloneable">
+        <description>
+            The method clone() should only be implemented if the class implements the Cloneable interface with the exception of
+            a final method that only throws CloneNotSupportedException.
+
+            The rule can also detect, if the class implements or extends a Cloneable class.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class MyClass {
+ public Object clone() throws CloneNotSupportedException {
+  return foo;
+ }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="CloneMethodReturnTypeMustMatchClassName"
+          language="java"
+          minimumLanguageVersion="1.5"
+          since="5.4.0"
+          message="The return type of the clone() method must be the class name when implements Cloneable"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#clonemethodreturntypemustmatchclassname">
+        <description>
+            If a class implements cloneable the return type of the method clone() must be the class name. That way, the caller
+            of the clone method doesn't need to cast the returned clone to the correct type.
+
+            Note: This is only possible with Java 1.5 or higher.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//MethodDeclaration
+[
+@Name = 'clone'
+and @Arity = 0
+and not (ResultType//ClassOrInterfaceType/@Image = ancestor::ClassOrInterfaceDeclaration[1]/@SimpleName)
+]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo implements Cloneable {
+    @Override
+    protected Object clone() { // Violation, Object must be Foo
+    }
+}
+
+public class Foo implements Cloneable {
+    @Override
+    public Foo clone() { //Ok
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="CloneThrowsCloneNotSupportedException"
+          deprecated="true"
+          language="java"
+          since="1.9"
+          message="clone() method should throw CloneNotSupportedException"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#clonethrowsclonenotsupportedexception">
+        <description>
+            The method clone() should throw a CloneNotSupportedException.
+
+            This rule is deprecated since PMD 6.35.0 without replacement. The rule has no real value as
+            `CloneNotSupportedException` is a checked exception and therefore you need to deal with it while
+            implementing the `clone()` method. You either need to declare the exception or catch it. If you catch it,
+            then subclasses can't throw it themselves explicitly. However, `Object.clone()` will still throw this
+            exception if the `Cloneable` interface is not implemented.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//MethodDeclaration
+[
+@Name = 'clone'
+and @Arity = 0
+and count(NameList/Name[contains
+(@Image,'CloneNotSupportedException')]) = 0
+]
+[
+../../../../ClassOrInterfaceDeclaration[@Final = false()]
+]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class MyClass implements Cloneable{
+    public Object clone() { // will cause an error
+         MyClass clone = (MyClass)super.clone();
+         return clone;
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="CloseResource"
+          language="java"
+          since="1.2.2"
+          message="Ensure that resources like this {0} object are closed after use"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.CloseResourceRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#closeresource">
+        <description>
+            Ensure that resources (like `java.sql.Connection`, `java.sql.Statement`, and `java.sql.ResultSet` objects
+            and any subtype of `java.lang.AutoCloseable`) are always closed after use.
+            Failing to do so might result in resource leaks.
+
+            Note: It suffices to configure the super type, e.g. `java.lang.AutoClosable`, so that this rule automatically triggers
+            on any subtype (e.g. `java.io.FileInputStream`). Additionally specifying `java.sql.Connection` helps in detecting
+            the types, if the type resolution / auxclasspath is not correctly setup.
+
+            Note: Since PMD 6.16.0 the default value for the property `types` contains `java.lang.AutoCloseable` and detects
+            now cases where the standard `java.io.*Stream` classes are involved. In order to restore the old behaviour,
+            just remove "AutoCloseable" from the types.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class Bar {
+    public void withSQL() {
+        Connection c = pool.getConnection();
+        try {
+            // do stuff
+        } catch (SQLException ex) {
+           // handle exception
+        } finally {
+            // oops, should close the connection using 'close'!
+            // c.close();
+        }
+    }
+
+    public void withFile() {
+        InputStream file = new FileInputStream(new File("/tmp/foo"));
+        try {
+            int c = file.in();
+        } catch (IOException e) {
+            // handle exception
+        } finally {
+            // TODO: close file
+        }
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="CompareObjectsWithEquals"
+          language="java"
+          since="3.2"
+          message="Use equals() to compare object references."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#compareobjectswithequals">
+        <description>
+            Use `equals()` to compare object references; avoid comparing them with `==`.
+
+            Since comparing objects with named constants is useful in some cases (eg, when
+            defining constants for sentinel values), the rule ignores comparisons against
+            fields with all-caps name (eg `this == SENTINEL`), which is a common naming
+            convention for constant fields.
+
+            You may allow some types to be compared by reference by listing the exceptions
+            in the `typesThatCompareByReference` property.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="typesThatCompareByReference" type="List[String]" delimiter="," description="List of canonical type names for which reference comparison is allowed.">
+                <value>java.lang.Enum,java.lang.Class</value>
+            </property>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//EqualityExpression
+    [count(
+        PrimaryExpression[pmd-java:typeIs('java.lang.Object')]
+        [not(some $t in $typesThatCompareByReference satisfies pmd-java:typeIs($t))]
+       ) = 2
+    ]
+    [not(PrimaryExpression[PrimaryPrefix/@ThisModifier = true()]
+                          [not(PrimarySuffix)]
+                          [ancestor::MethodDeclaration[@Name = 'equals']])
+    ]
+    (: Is not a field access with an all-caps identifier :)
+    [not(PrimaryExpression[not(PrimarySuffix) and PrimaryPrefix/Name[upper-case(@Image)=@Image]
+     or PrimaryExpression/PrimarySuffix[last()][upper-case(@Image)=@Image]])]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+class Foo {
+  boolean bar(String a, String b) {
+    return a == b;
+  }
+}
+
+]]>
+        </example>
+    </rule>
+
+    <rule name="ComparisonWithNaN"
+          language="java"
+          since="6.36.0"
+          message="Comparisons with NaN always return false"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#comparisonwithnan">
+        <description><![CDATA[
+            Reports comparisons with double and float `NaN` (Not-a-Number) values.
+            These are [specified](https://docs.oracle.com/javase/specs/jls/se8/html/jls-15.html#jls-15.21.1)
+            to have unintuitive behavior: NaN is considered unequal to itself.
+            This means a check like `someDouble == Double.NaN` will always return
+            false, even if `someDouble` is really the NaN value. To test whether a
+            value is the NaN value, one should instead use `Double.isNaN(someDouble)`
+            (or `Float.isNaN`). The `!=` operator should be treated similarly.
+            Finally, comparisons like `someDouble <= Double.NaN` are nonsensical
+            and will always evaluate to false.
+
+            This rule has been renamed from "BadComparison" with PMD 6.36.0.
+        ]]></description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+(//EqualityExpression | //RelationalExpression)/PrimaryExpression/PrimaryPrefix/Name[@Image='Double.NaN' or @Image='Float.NaN']
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+boolean x = (y == Double.NaN);
+]]>
+        </example>
+    </rule>
+
+
+    <rule name="ConstructorCallsOverridableMethod"
+          language="java"
+          since="1.04"
+          message="Overridable {0} called during object construction"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.ConstructorCallsOverridableMethodRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#constructorcallsoverridablemethod">
+        <description>
+            Calling overridable methods during construction poses a risk of invoking methods on an incompletely
+            constructed object and can be difficult to debug.
+            It may leave the sub-class unable to construct its superclass or forced to replicate the construction
+            process completely within itself, losing the ability to call super().  If the default constructor
+            contains a call to an overridable method, the subclass may be completely uninstantiable.   Note that
+            this includes method calls throughout the control flow graph - i.e., if a constructor Foo() calls a
+            private method bar() that calls a public method buz(), this denotes a problem.
+        </description>
+        <priority>1</priority>
+        <example>
+            <![CDATA[
+public class SeniorClass {
+  public SeniorClass(){
+      toString(); //may throw NullPointerException if overridden
+  }
+  public String toString(){
+    return "IAmSeniorClass";
+  }
+}
+public class JuniorClass extends SeniorClass {
+  private String name;
+  public JuniorClass(){
+    super(); //Automatic call leads to NullPointerException
+    name = "JuniorClass";
+  }
+  public String toString(){
+    return name.toUpperCase();
+  }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="DataflowAnomalyAnalysis"
+          language="java"
+          since="3.9"
+          message="Found ''{0}''-anomaly for variable ''{1}'' (lines ''{2}''-''{3}'')."
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.DataflowAnomalyAnalysisRule"
+          dfa="true"
+          deprecated="true"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#dataflowanomalyanalysis">
+        <description>The dataflow analysis tracks local definitions, undefinitions and references to variables on different paths on the data flow.
+            From those informations there can be found various problems.
+
+            1. DU - Anomaly: A recently defined variable is undefined. These anomalies may appear in normal source text.
+            2. DD - Anomaly: A recently defined variable is redefined. This is ominous but don't have to be a bug.
+
+            This rule is deprecated. Use {% rule "java/bestpractices/UnusedAssignment" %} in category bestpractices instead.
+        </description>
+        <priority>5</priority>
+        <example>
+            <![CDATA[
+public void foo() {
+  int buz = 5;
+  buz = 6; // redefinition of buz -> dd-anomaly
+  foo(buz);
+  buz = 2;
+} // buz is undefined when leaving scope -> du-anomaly
+]]>
+        </example>
+    </rule>
+
+    <rule name="DetachedTestCase"
+          language="java"
+          since="6.13.0"
+          message="Probable detached JUnit test case."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          typeResolution="true"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#detachedtestcase">
+        <description>
+            The method appears to be a test case since it has public or default visibility,
+            non-static access, no arguments, no return value, has no annotations, but is a
+            member of a class that has one or more JUnit test cases. If it is a utility
+            method, it should likely have private visibility. If it is an ignored test, it
+            should be annotated with @Test and @Ignore.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value><![CDATA[
+//ClassOrInterfaceBodyDeclaration
+[../ClassOrInterfaceBodyDeclaration/Annotation/*/Name
+        [pmd-java:typeIs('org.junit.Test')
+         or pmd-java:typeIs('org.junit.jupiter.api.Test')
+         or pmd-java:typeIs('org.junit.jupiter.api.RepeatedTest')
+         or pmd-java:typeIs('org.junit.jupiter.api.TestFactory')
+         or pmd-java:typeIs('org.junit.jupiter.api.TestTemplate')
+         or pmd-java:typeIs('org.junit.jupiter.params.ParameterizedTest')]
+]
+[not(Annotation)]
+[MethodDeclaration[(@Public = true() or @PackagePrivate = true()) and @Static = false() and
+        ResultType[@Void = true()] and
+        MethodDeclarator/FormalParameters[@Size = 0]
+    ]
+]
+]]></value>
+            </property>
+            <property name="version" value="2.0" />
+        </properties>
+        <example>
+            <![CDATA[
+public class MyTest {
+    @Test
+    public void someTest() {
+    }
+
+    // violation: Not annotated
+    public void someOtherTest () {
+    }
+
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="DoNotCallGarbageCollectionExplicitly"
+          language="java"
+          since="4.2"
+          message="Do not explicitly trigger a garbage collection."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#donotcallgarbagecollectionexplicitly">
+        <description>
+            Calls to System.gc(), Runtime.getRuntime().gc(), and System.runFinalization() are not advised. Code should have the
+            same behavior whether the garbage collection is disabled using the option -Xdisableexplicitgc or not.
+            Moreover, "modern" jvms do a very good job handling garbage collections. If memory usage issues unrelated to memory
+            leaks develop within an application, it should be dealt with JVM options rather than within the code itself.
+        </description>
+        <priority>2</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//Name[
+(starts-with(@Image, 'System.') and
+(starts-with(@Image, 'System.gc') or
+starts-with(@Image, 'System.runFinalization'))) or
+(
+starts-with(@Image,'Runtime.getRuntime') and
+../../PrimarySuffix[ends-with(@Image,'gc')]
+)
+]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class GCCall {
+    public GCCall() {
+        // Explicit gc call !
+        System.gc();
+    }
+
+    public void doSomething() {
+        // Explicit gc call !
+        Runtime.getRuntime().gc();
+    }
+
+    public explicitGCcall() {
+        // Explicit gc call !
+        System.gc();
+    }
+
+    public void doSomething() {
+        // Explicit gc call !
+        Runtime.getRuntime().gc();
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="DoNotCallSystemExit" ref="category/java/errorprone.xml/DoNotTerminateVM" deprecated="true" />
+
+    <rule name="DoNotExtendJavaLangThrowable"
+          language="java"
+          since="6.0.0"
+          message="Exceptions should not extend java.lang.Throwable"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#donotextendjavalangthrowable">
+        <description>
+            Extend Exception or RuntimeException instead of Throwable.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//ClassOrInterfaceDeclaration/ExtendsList/ClassOrInterfaceType
+  [@Image="Throwable" or @Image="java.lang.Throwable"]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo extends Throwable { }
+]]>
+        </example>
+    </rule>
+
+    <rule name="DoNotHardCodeSDCard"
+          since="4.2.6"
+          language="java"
+          message="Do not hardcode /sdcard."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#donothardcodesdcard">
+        <description>
+            Use Environment.getExternalStorageDirectory() instead of "/sdcard"
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>//Literal[starts-with(@Image,'"/sdcard')]</value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class MyActivity extends Activity {
+    protected void foo() {
+        String storageLocation = "/sdcard/mypackage";   // hard-coded, poor approach
+
+       storageLocation = Environment.getExternalStorageDirectory() + "/mypackage"; // preferred approach
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="DoNotTerminateVM"
+          language="java"
+          since="4.1"
+          message="System.exit() should not be used in J2EE/JEE apps"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#donotterminatevm">
+        <description>
+            Web applications should not call `System.exit()`, since only the web container or the
+            application server should stop the JVM. Otherwise a web application would terminate all other applications
+            running on the same application server.
+
+            This rule also checks for the equivalent calls `Runtime.getRuntime().exit()` and `Runtime.getRuntime().halt()`.
+
+            This rule was called *DoNotCallSystemExit* until PMD 6.29.0.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//Name[
+    starts-with(@Image,'System.exit')
+    or
+    (starts-with(@Image,'Runtime.getRuntime') and ../../PrimarySuffix[ends-with(@Image,'exit') or ends-with(@Image,'halt')])
+][not(ancestor::MethodDeclaration[1][@Name="main" and @Static = true()])]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public void bar() {
+    System.exit(0);                 // never call this when running in an application server!
+}
+public void foo() {
+    Runtime.getRuntime().exit(0);   // never stop the JVM manually, the container will do this.
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="DoNotThrowExceptionInFinally"
+          language="java"
+          since="4.2"
+          message="A throw statement in a finally block makes the control flow hard to understand."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#donotthrowexceptioninfinally">
+        <description>
+            Throwing exceptions within a 'finally' block is confusing since they may mask other exceptions
+            or code defects.
+            Note: This is a PMD implementation of the Lint4j rule "A throw in a finally block"
+        </description>
+        <priority>4</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>//FinallyStatement[descendant::ThrowStatement]</value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo {
+    public void bar() {
+        try {
+            // Here do some stuff
+        } catch( Exception e) {
+            // Handling the issue
+        } finally {
+            // is this really a good idea ?
+            throw new Exception();
+        }
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="DontImportSun"
+          language="java"
+          since="1.5"
+          message="Avoid importing anything from the 'sun.*' packages"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.DontImportSunRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#dontimportsun">
+        <description>
+            Avoid importing anything from the 'sun.*' packages.  These packages are not portable and are likely to change.
+        </description>
+        <priority>4</priority>
+        <example>
+            <![CDATA[
+import sun.misc.foo;
+public class Foo {}
+]]>
+        </example>
+    </rule>
+
+    <rule name="DontUseFloatTypeForLoopIndices"
+          language="java"
+          since="4.3"
+          message="Don't use floating point for loop indices. If you must use floating point, use double."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#dontusefloattypeforloopindices">
+        <description>
+            Don't use floating point for loop indices. If you must use floating point, use double
+            unless you're certain that float provides enough precision and you have a compelling
+            performance need (space or time).
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//ForStatement/ForInit/LocalVariableDeclaration
+/Type/PrimitiveType[@Image="float"]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Count {
+  public static void main(String[] args) {
+    final int START = 2000000000;
+    int count = 0;
+    for (float f = START; f < START + 50; f++)
+      count++;
+      //Prints 0 because (float) START == (float) (START + 50).
+      System.out.println(count);
+      //The termination test misbehaves due to floating point granularity.
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="EmptyCatchBlock"
+          language="java"
+          since="0.1"
+          message="Avoid empty catch blocks"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#emptycatchblock">
+        <description>
+            Empty Catch Block finds instances where an exception is caught, but nothing is done.
+            In most circumstances, this swallows an exception which should either be acted on
+            or reported.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//CatchStatement
+ [not(Block/BlockStatement)]
+ [$allowCommentedBlocks != true() or Block/@containsComment = false()]
+ [FormalParameter/Type/ReferenceType
+   /ClassOrInterfaceType[@Image != 'InterruptedException' and @Image != 'CloneNotSupportedException']
+ ]
+ [FormalParameter/VariableDeclaratorId[not(matches(@Name, $allowExceptionNameRegex))]]
+]]>
+                </value>
+            </property>
+            <property name="allowCommentedBlocks" type="Boolean" description="Empty blocks containing comments will be skipped" value="false"/>
+            <property name="allowExceptionNameRegex" type="String" description="Empty blocks catching exceptions with names matching this regular expression will be skipped" value="^(ignored|expected)$"/>
+        </properties>
+        <example>
+            <![CDATA[
+public void doSomething() {
+    try {
+        FileInputStream fis = new FileInputStream("/tmp/bugger");
+    } catch (IOException ioe) {
+        // not good
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="EmptyFinalizer"
+          language="java"
+          since="1.5"
+          message="Avoid empty finalize methods"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#emptyfinalizer">
+        <description>
+            Empty finalize methods serve no purpose and should be removed. Note that Oracle has declared Object.finalize() as deprecated since JDK 9.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//MethodDeclaration[@Name='finalize'][@Arity = 0]
+  /Block[not(*)]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo {
+   protected void finalize() {}
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="EmptyFinallyBlock"
+          language="java"
+          since="0.4"
+          message="Avoid empty finally blocks"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#emptyfinallyblock">
+        <description>
+            Empty finally blocks serve no purpose and should be removed.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//FinallyStatement[not(Block/BlockStatement)]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo {
+    public void bar() {
+        try {
+            int x=2;
+        } finally {
+            // empty!
+        }
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="EmptyIfStmt"
+          language="java"
+          since="0.1"
+          message="Avoid empty 'if' statements"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#emptyifstmt">
+        <description>
+            Empty If Statement finds instances where a condition is checked but nothing is done about it.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//IfStatement/Statement
+ [EmptyStatement or Block[not(*)]]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo {
+ void bar(int x) {
+  if (x == 0) {
+   // empty!
+  }
+ }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="EmptyInitializer"
+          language="java"
+          since="5.0"
+          message="Empty initializer was found"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#emptyinitializer">
+        <description>
+            Empty initializers serve no purpose and should be removed.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>//Initializer/Block[not(*)]</value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo {
+
+   static {} // Why ?
+
+   {} // Again, why ?
+
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="EmptyStatementBlock"
+          language="java"
+          since="5.0"
+          message="Avoid empty block statements."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#emptystatementblock">
+        <description>
+            Empty block statements serve no purpose and should be removed.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>//BlockStatement/Statement/Block[not(*)]</value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo {
+
+   private int _bar;
+
+   public void setBar(int bar) {
+      { _bar = bar; } // Why not?
+      {} // But remove this.
+   }
+
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="EmptyStatementNotInLoop"
+          language="java"
+          since="1.5"
+          message="An empty statement (semicolon) not part of a loop"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#emptystatementnotinloop">
+        <description>
+            An empty statement (or a semicolon by itself) that is not used as the sole body of a 'for'
+            or 'while' loop is probably a bug.  It could also be a double semicolon, which has no purpose
+            and should be removed.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//EmptyStatement
+ [not(
+       ../../../ForStatement
+       or ../../../WhileStatement
+       or ../../../BlockStatement/ClassOrInterfaceDeclaration
+       or ../../../../../../ForStatement/Statement[1]
+        /Block[1]/BlockStatement[1]/Statement/EmptyStatement
+       or ../../../../../../WhileStatement/Statement[1]
+        /Block[1]/BlockStatement[1]/Statement/EmptyStatement)
+ ]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public void doit() {
+      // this is probably not what you meant to do
+      ;
+      // the extra semicolon here this is not necessary
+      System.out.println("look at the extra semicolon");;
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="EmptySwitchStatements"
+          language="java"
+          since="1.0"
+          message="Avoid empty switch statements"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#emptyswitchstatements">
+        <description>
+            Empty switch statements serve no purpose and should be removed.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>//SwitchStatement[count(*) = 1]</value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public void bar() {
+    int x = 2;
+    switch (x) {
+        // once there was code here
+        // but it's been commented out or something
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="EmptySynchronizedBlock"

Review comment:
       This rule is enabled in our repo

##########
File path: check-rules/errorprone.xml
##########
@@ -0,0 +1,3721 @@
+<?xml version="1.0"?>
+
+<ruleset name="Error Prone"
+         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 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">
+
+    <description>
+        Rules to detect constructs that are either broken, extremely confusing or prone to runtime errors.
+    </description>
+
+    <rule name="AssignmentInOperand"
+          language="java"
+          since="1.03"
+          message="Avoid assignments in operands"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AssignmentInOperandRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#assignmentinoperand">
+        <description>
+            Avoid assignments in operands; this can make code more complicated and harder to read.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public void bar() {
+    int x = 2;
+    if ((x = getX()) == 3) {
+      System.out.println("3!");
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AssignmentToNonFinalStatic"
+          language="java"
+          since="2.2"
+          message="Possible unsafe assignment to a non-final static field in a constructor."
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AssignmentToNonFinalStaticRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#assignmenttononfinalstatic">
+        <description>
+            Identifies a possible unsafe usage of a static field.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class StaticField {
+   static int x;
+   public FinalFields(int y) {
+    x = y; // unsafe
+   }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidAccessibilityAlteration"
+          language="java"
+          since="4.1"
+          message="You should not modify visibility of class or methods using getDeclaredConstructors(), getDeclaredConstructor(Class[]), setAccessible() or PrivilegedAction."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidaccessibilityalteration">
+        <description>
+            Methods such as getDeclaredConstructors(), getDeclaredConstructor(Class[]) and setAccessible(),
+            as the interface PrivilegedAction, allow for the runtime alteration of variable, class, or
+            method visibility, even if they are private. This violates the principle of encapsulation.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//PrimaryExpression[
+(
+(PrimarySuffix[
+        ends-with(@Image,'getDeclaredConstructors')
+                or
+        ends-with(@Image,'getDeclaredConstructor')
+                or
+        ends-with(@Image,'setAccessible')
+        ])
+or
+(PrimaryPrefix/Name[
+        ends-with(@Image,'getDeclaredConstructor')
+        or
+        ends-with(@Image,'getDeclaredConstructors')
+        or
+        starts-with(@Image,'AccessibleObject.setAccessible')
+        ])
+)
+and
+(//ImportDeclaration/Name[
+        contains(@Image,'java.security.PrivilegedAction')])
+]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Method;
+import java.security.PrivilegedAction;
+
+public class Violation {
+  public void invalidCallsInMethod() throws SecurityException, NoSuchMethodException {
+    // Possible call to forbidden getDeclaredConstructors
+    Class[] arrayOfClass = new Class[1];
+    this.getClass().getDeclaredConstructors();
+    this.getClass().getDeclaredConstructor(arrayOfClass);
+    Class clazz = this.getClass();
+    clazz.getDeclaredConstructor(arrayOfClass);
+    clazz.getDeclaredConstructors();
+      // Possible call to forbidden setAccessible
+    clazz.getMethod("", arrayOfClass).setAccessible(false);
+    AccessibleObject.setAccessible(null, false);
+    Method.setAccessible(null, false);
+    Method[] methodsArray = clazz.getMethods();
+    int nbMethod;
+    for ( nbMethod = 0; nbMethod < methodsArray.length; nbMethod++ ) {
+      methodsArray[nbMethod].setAccessible(false);
+    }
+
+      // Possible call to forbidden PrivilegedAction
+    PrivilegedAction priv = (PrivilegedAction) new Object(); priv.run();
+  }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidAssertAsIdentifier"
+          language="java"
+          since="3.4"
+          message="Avoid using assert as an identifier; it became a reserved word in JDK 1.4"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidassertasidentifier">
+        <description>
+            Use of the term 'assert' will conflict with newer versions of Java since it is a reserved word.
+        </description>
+        <priority>2</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>//VariableDeclaratorId[@Name='assert']</value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class A {
+    public class Foo {
+        String assert = "foo";
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidBranchingStatementAsLastInLoop"
+          language="java"
+          since="5.0"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AvoidBranchingStatementAsLastInLoopRule"
+          message="Avoid using a branching statement as the last in a loop."
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidbranchingstatementaslastinloop">
+        <description>
+            Using a branching statement as the last part of a loop may be a bug, and/or is confusing.
+            Ensure that the usage is not a bug, or consider using another approach.
+        </description>
+        <priority>2</priority>
+        <example>
+            <![CDATA[
+// unusual use of branching statement in a loop
+for (int i = 0; i < 10; i++) {
+    if (i*i <= 25) {
+        continue;
+    }
+    break;
+}
+
+// this makes more sense...
+for (int i = 0; i < 10; i++) {
+    if (i*i > 25) {
+        break;
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidCallingFinalize"
+          language="java"
+          since="3.0"
+          message="Avoid calling finalize() explicitly"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AvoidCallingFinalizeRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidcallingfinalize">
+        <description>
+            The method Object.finalize() is called by the garbage collector on an object when garbage collection determines
+            that there are no more references to the object. It should not be invoked by application logic.
+
+            Note that Oracle has declared Object.finalize() as deprecated since JDK 9.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+void foo() {
+    Bar b = new Bar();
+    b.finalize();
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidCatchingNPE"
+          language="java"
+          since="1.8"
+          message="Avoid catching NullPointerException; consider removing the cause of the NPE."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidcatchingnpe">
+        <description>
+            Code should never throw NullPointerExceptions under normal circumstances.  A catch block may hide the
+            original error, causing other, more subtle problems later on.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//CatchStatement/FormalParameter/Type
+ /ReferenceType/ClassOrInterfaceType[@Image='NullPointerException']
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo {
+    void bar() {
+        try {
+            // do something
+        } catch (NullPointerException npe) {
+        }
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidCatchingThrowable"
+          language="java"
+          since="1.2"
+          message="A catch statement should never catch throwable since it includes errors."
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AvoidCatchingThrowableRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidcatchingthrowable">
+        <description>
+            Catching Throwable errors is not recommended since its scope is very broad. It includes runtime issues such as
+            OutOfMemoryError that should be exposed and managed separately.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public void bar() {
+    try {
+        // do something
+    } catch (Throwable th) {  // should not catch Throwable
+        th.printStackTrace();
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidDecimalLiteralsInBigDecimalConstructor"
+          language="java"
+          since="3.4"
+          message="Avoid creating BigDecimal with a decimal (float/double) literal. Use a String literal"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoiddecimalliteralsinbigdecimalconstructor">
+        <description>
+            One might assume that the result of "new BigDecimal(0.1)" is exactly equal to 0.1, but it is actually
+            equal to .1000000000000000055511151231257827021181583404541015625.
+            This is because 0.1 cannot be represented exactly as a double (or as a binary fraction of any finite
+            length). Thus, the long value that is being passed in to the constructor is not exactly equal to 0.1,
+            appearances notwithstanding.
+
+            The (String) constructor, on the other hand, is perfectly predictable: 'new BigDecimal("0.1")' is
+            exactly equal to 0.1, as one would expect.  Therefore, it is generally recommended that the
+            (String) constructor be used in preference to this one.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//AllocationExpression[pmd-java:typeIs('java.math.BigDecimal')]
+[Arguments/ArgumentList/Expression/PrimaryExpression
+    [
+        pmd-java:typeIs('float') or
+        pmd-java:typeIs('java.lang.Float') or
+        pmd-java:typeIs('double') or
+        pmd-java:typeIs('java.lang.Double')
+    ]
+]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+BigDecimal bd = new BigDecimal(1.123);       // loss of precision, this would trigger the rule
+
+BigDecimal bd = new BigDecimal("1.123");     // preferred approach
+
+BigDecimal bd = new BigDecimal(12);          // preferred approach, ok for integer values
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidDuplicateLiterals"
+          language="java"
+          since="1.0"
+          message="The String literal {0} appears {1} times in this file; the first occurrence is on line {2}"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AvoidDuplicateLiteralsRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidduplicateliterals">
+        <description>
+            Code containing duplicate String literals can usually be improved by declaring the String as a constant field.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+private void bar() {
+     buz("Howdy");
+     buz("Howdy");
+     buz("Howdy");
+     buz("Howdy");
+}
+private void buz(String x) {}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidEnumAsIdentifier"
+          language="java"
+          since="3.4"
+          message="Avoid using enum as an identifier; it's a reserved word in JDK 1.5"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidenumasidentifier">
+        <description>
+            Use of the term 'enum' will conflict with newer versions of Java since it is a reserved word.
+        </description>
+        <priority>2</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>//VariableDeclaratorId[@Name='enum']</value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class A {
+    public class Foo {
+        String enum = "foo";
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidFieldNameMatchingMethodName"
+          language="java"
+          since="3.0"
+          message="Field {0} has the same name as a method"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AvoidFieldNameMatchingMethodNameRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidfieldnamematchingmethodname">
+        <description>
+            It can be confusing to have a field name with the same name as a method. While this is permitted,
+            having information (field) and actions (method) is not clear naming. Developers versed in
+            Smalltalk often prefer this approach as the methods denote accessor methods.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class Foo {
+    Object bar;
+    // bar is data or an action or both?
+    void bar() {
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidFieldNameMatchingTypeName"
+          language="java"
+          since="3.0"
+          message="It is somewhat confusing to have a field name matching the declaring class name"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AvoidFieldNameMatchingTypeNameRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidfieldnamematchingtypename">
+        <description>
+            It is somewhat confusing to have a field name matching the declaring type name.
+            This probably means that type and/or field names should be chosen more carefully.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class Foo extends Bar {
+    int foo;    // There is probably a better name that can be used
+}
+public interface Operation {
+    int OPERATION = 1; // There is probably a better name that can be used
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidInstanceofChecksInCatchClause"
+          language="java"
+          since="3.0"
+          message="An instanceof check is being performed on the caught exception.  Create a separate catch clause for this exception type."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidinstanceofchecksincatchclause">
+        <description>
+            Each caught exception type should be handled in its own catch clause.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//CatchStatement/FormalParameter
+ /following-sibling::Block//InstanceOfExpression/PrimaryExpression/PrimaryPrefix
+  /Name[
+   @Image = ./ancestor::Block/preceding-sibling::FormalParameter
+    /VariableDeclaratorId/@Name
+  ]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+try { // Avoid this
+    // do something
+} catch (Exception ee) {
+    if (ee instanceof IOException) {
+        cleanup();
+    }
+}
+
+try {  // Prefer this:
+    // do something
+} catch (IOException ee) {
+    cleanup();
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidLiteralsInIfCondition"
+          language="java"
+          since="4.2.6"
+          message="Avoid using Literals in Conditional Statements"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidliteralsinifcondition">
+        <description>
+            Avoid using hard-coded literals in conditional statements. By declaring them as static variables
+            or private members with descriptive names maintainability is enhanced. By default, the literals "-1" and "0" are ignored.
+            More exceptions can be defined with the property "ignoreMagicNumbers".
+
+            The rule doesn't consider deeper expressions by default, but this can be enabled via the property `ignoreExpressions`.
+            With this property set to false, if-conditions like `i == 1 + 5` are reported as well. Note that in that case,
+            the property ignoreMagicNumbers is not taken into account, if there are multiple literals involved in such an expression.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="ignoreMagicNumbers"
+                      description="Comma-separated list of magic numbers, that should be ignored"
+                      type="String" value="-1,0"/>
+            <property name="ignoreExpressions"
+                      description="If true, only literals in simple if conditions are considered. Otherwise literals in expressions are checked, too."
+                      type="Boolean" value="true"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+(: simple case - no deep expressions :)
+//IfStatement[$ignoreExpressions = true()]/Expression/*/PrimaryExpression/PrimaryPrefix/Literal
+    [not(NullLiteral)]
+    [not(BooleanLiteral)]
+    [empty(index-of(tokenize($ignoreMagicNumbers, '\s*,\s*'), @Image))]
+|
+(: consider also deeper expressions :)
+//IfStatement[$ignoreExpressions = false()]/Expression//*[local-name() != 'UnaryExpression' or @Operator != '-']/PrimaryExpression/PrimaryPrefix/Literal
+    [not(NullLiteral)]
+    [not(BooleanLiteral)]
+    [empty(index-of(tokenize($ignoreMagicNumbers, '\s*,\s*'), @Image))]
+|
+(: consider negative literals :)
+//IfStatement[$ignoreExpressions = false()]/Expression//UnaryExpression[@Operator = '-']/PrimaryExpression/PrimaryPrefix/Literal
+    [not(NullLiteral)]
+    [not(BooleanLiteral)]
+    [empty(index-of(tokenize($ignoreMagicNumbers, '\s*,\s*'), concat('-', @Image)))]
+|
+(: consider multiple literals in expressions :)
+//IfStatement[$ignoreExpressions = false()]/Expression[count(*/PrimaryExpression/PrimaryPrefix/Literal
+    [not(NullLiteral)]
+    [not(BooleanLiteral)]) > 1]
+]]>
+                </value>
+            </property>
+            <property name="version" value="2.0"/>
+        </properties>
+        <example>
+            <![CDATA[
+private static final int MAX_NUMBER_OF_REQUESTS = 10;
+
+public void checkRequests() {
+
+    if (i == 10) {                        // magic number, buried in a method
+      doSomething();
+    }
+
+    if (i == MAX_NUMBER_OF_REQUESTS) {    // preferred approach
+      doSomething();
+    }
+
+    if (aString.indexOf('.') != -1) {}     // magic number -1, by default ignored
+    if (aString.indexOf('.') >= 0) { }     // alternative approach
+
+    if (aDouble > 0.0) {}                  // magic number 0.0
+    if (aDouble >= Double.MIN_VALUE) {}    // preferred approach
+
+    // with rule property "ignoreExpressions" set to "false"
+    if (i == pos + 5) {}  // violation: magic number 5 within an (additive) expression
+    if (i == pos + SUFFIX_LENGTH) {} // preferred approach
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidLosingExceptionInformation"
+          since="4.2.6"
+          language="java"
+          message="Avoid statements in a catch block that invoke accessors on the exception without using the information"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidlosingexceptioninformation">
+        <description>
+            Statements in a catch block that invoke accessors on the exception without using the information
+            only add to code size.  Either remove the invocation, or use the return result.
+        </description>
+        <priority>2</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//CatchStatement/Block/BlockStatement/Statement/StatementExpression/PrimaryExpression/PrimaryPrefix/Name
+[
+   @Image = concat(../../../../../../../FormalParameter/VariableDeclaratorId/@Name, '.getMessage')
+   or
+   @Image = concat(../../../../../../../FormalParameter/VariableDeclaratorId/@Name, '.getLocalizedMessage')
+   or
+   @Image = concat(../../../../../../../FormalParameter/VariableDeclaratorId/@Name, '.getCause')
+   or
+   @Image = concat(../../../../../../../FormalParameter/VariableDeclaratorId/@Name, '.getStackTrace')
+   or
+   @Image = concat(../../../../../../../FormalParameter/VariableDeclaratorId/@Name, '.toString')
+]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public void bar() {
+    try {
+        // do something
+    } catch (SomeException se) {
+        se.getMessage();
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidMultipleUnaryOperators"
+          language="java"
+          since="4.2"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AvoidMultipleUnaryOperatorsRule"
+          message="Using multiple unary operators may be a bug, and/or is confusing."
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidmultipleunaryoperators">
+        <description>
+            The use of multiple unary operators may be problematic, and/or confusing.
+            Ensure that the intended usage is not a bug, or consider simplifying the expression.
+        </description>
+        <priority>2</priority>
+        <example>
+            <![CDATA[
+// These are typo bugs, or at best needlessly complex and confusing:
+int i = - -1;
+int j = + - +1;
+int z = ~~2;
+boolean b = !!true;
+boolean c = !!!true;
+
+// These are better:
+int i = 1;
+int j = -1;
+int z = 2;
+boolean b = true;
+boolean c = false;
+
+// And these just make your brain hurt:
+int i = ~-2;
+int j = -~7;
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidUsingOctalValues"
+          language="java"
+          since="3.9"
+          message="Do not start a literal by 0 unless it's an octal value"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AvoidUsingOctalValuesRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidusingoctalvalues">
+        <description>
+            Integer literals should not start with zero since this denotes that the rest of literal will be
+            interpreted as an octal value.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+int i = 012;    // set i with 10 not 12
+int j = 010;    // set j with 8 not 10
+k = i * j;      // set k with 80 not 120
+]]>
+        </example>
+    </rule>
+
+    <rule name="BadComparison" ref="ComparisonWithNaN" deprecated="true" />
+
+    <rule name="BeanMembersShouldSerialize"
+          language="java"
+          since="1.1"
+          message="Found non-transient, non-static member. Please mark as transient or provide accessors."
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.BeanMembersShouldSerializeRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#beanmembersshouldserialize">
+        <description>
+            If a class is a bean, or is referenced by a bean directly or indirectly it needs to be serializable.
+            Member variables need to be marked as transient, static, or have accessor methods in the class. Marking
+            variables as transient is the safest and easiest modification. Accessor methods should follow the Java
+            naming conventions, i.e. for a variable named foo, getFoo() and setFoo() accessor methods should be provided.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+private transient int someFoo;  // good, it's transient
+private static int otherFoo;    // also OK
+private int moreFoo;            // OK, has proper accessors, see below
+private int badFoo;             // bad, should be marked transient
+
+private void setMoreFoo(int moreFoo){
+      this.moreFoo = moreFoo;
+}
+
+private int getMoreFoo(){
+      return this.moreFoo;
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="BrokenNullCheck"
+          language="java"
+          since="3.8"
+          message="Method call on object which may be null"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.BrokenNullCheckRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#brokennullcheck">
+        <description>
+            The null check is broken since it will throw a NullPointerException itself.
+            It is likely that you used || instead of &amp;&amp; or vice versa.
+        </description>
+        <priority>2</priority>
+        <example>
+            <![CDATA[
+public String bar(String string) {
+  // should be &&
+    if (string!=null || !string.equals(""))
+        return string;
+  // should be ||
+    if (string==null && string.equals(""))
+        return string;
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="CallSuperFirst"
+          since="4.2.5"
+          language="java"
+          message="super should be called at the start of the method"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#callsuperfirst">
+        <description>Super should be called at the start of the method</description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//MethodDeclaration[
+  @Name='onCreate' or
+  @Name='onConfigurationChanged' or
+  @Name='onPostCreate' or
+  @Name='onPostResume' or
+  @Name='onRestart' or
+  @Name='onRestoreInstanceState' or
+  @Name='onResume' or
+  @Name='onStart'
+  ]
+    /Block[not(
+      (BlockStatement[1]/Statement/StatementExpression/PrimaryExpression[./PrimaryPrefix[@SuperModifier= true()]]/PrimarySuffix[@Image= ancestor::MethodDeclaration/@Name]))]
+[ancestor::ClassOrInterfaceDeclaration[ExtendsList/ClassOrInterfaceType[
+  pmd-java:typeIs('android.app.Activity') or
+  pmd-java:typeIs('android.app.Application') or
+  pmd-java:typeIs('android.app.Service')
+]]]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class DummyActivity extends Activity {
+    public void onCreate(Bundle bundle) {
+        // missing call to super.onCreate(bundle)
+        foo();
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="CallSuperLast"
+          since="4.2.5"
+          language="java"
+          message="super should be called at the end of the method"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#callsuperlast">
+        <description>
+            Super should be called at the end of the method
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//MethodDeclaration[
+  @Name='finish' or
+  @Name='onDestroy' or
+  @Name='onPause' or
+  @Name='onSaveInstanceState' or
+  @Name='onStop' or
+  @Name='onTerminate'
+  ]
+   /Block/BlockStatement[last()]
+    [not(Statement/StatementExpression/PrimaryExpression[./PrimaryPrefix[@SuperModifier= true()]]/PrimarySuffix[@Image= ancestor::MethodDeclaration/@Name])]
+[ancestor::ClassOrInterfaceDeclaration[ExtendsList/ClassOrInterfaceType[
+  pmd-java:typeIs('android.app.Activity') or
+  pmd-java:typeIs('android.app.Application') or
+  pmd-java:typeIs('android.app.Service')
+]]]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class DummyActivity extends Activity {
+    public void onPause() {
+        foo();
+        // missing call to super.onPause()
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="CheckSkipResult"
+          language="java"
+          since="5.0"
+          message="Check the value returned by the skip() method of an InputStream to see if the requested number of bytes has been skipped."
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.CheckSkipResultRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#checkskipresult">
+        <description>
+            The skip() method may skip a smaller number of bytes than requested. Check the returned value to find out if it was the case or not.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class Foo {
+
+   private FileInputStream _s = new FileInputStream("file");
+
+   public void skip(int n) throws IOException {
+      _s.skip(n); // You are not sure that exactly n bytes are skipped
+   }
+
+   public void skipExactly(int n) throws IOException {
+      while (n != 0) {
+         long skipped = _s.skip(n);
+         if (skipped == 0)
+            throw new EOFException();
+         n -= skipped;
+      }
+   }
+]]>
+        </example>
+    </rule>
+
+    <rule name="ClassCastExceptionWithToArray"
+          language="java"
+          since="3.4"
+          message="This usage of the Collection.toArray() method will throw a ClassCastException."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#classcastexceptionwithtoarray">
+        <description>
+            When deriving an array of a specific class from your Collection, one should provide an array of
+            the same class as the parameter of the toArray() method. Doing otherwise you will will result
+            in a ClassCastException.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//CastExpression[Type/ReferenceType/ClassOrInterfaceType[@Image != "Object"]]
+    /PrimaryExpression
+    [PrimaryPrefix/Name[ends-with(@Image, '.toArray')]]
+    [PrimarySuffix/Arguments[not(*)]]
+    [count(PrimarySuffix) = 1]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+Collection c = new ArrayList();
+Integer obj = new Integer(1);
+c.add(obj);
+
+    // this would trigger the rule (and throw a ClassCastException if executed)
+Integer[] a = (Integer [])c.toArray();
+
+   // this is fine and will not trigger the rule
+Integer[] b = (Integer [])c.toArray(new Integer[c.size()]);
+]]>
+        </example>
+    </rule>
+
+    <rule name="CloneMethodMustBePublic"
+          language="java"
+          since="5.4.0"
+          message="clone() method must be public if the class implements Cloneable"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#clonemethodmustbepublic">
+        <description>
+            The java Manual says "By convention, classes that implement this interface should override
+            Object.clone (which is protected) with a public method."
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//MethodDeclaration[@Public= false()]
+  [@Name = 'clone']
+  [@Arity = 0]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo implements Cloneable {
+    @Override
+    protected Object clone() throws CloneNotSupportedException { // Violation, must be public
+    }
+}
+
+public class Foo implements Cloneable {
+    @Override
+    protected Foo clone() { // Violation, must be public
+    }
+}
+
+public class Foo implements Cloneable {
+    @Override
+    public Object clone() // Ok
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="CloneMethodMustImplementCloneable"
+          language="java"
+          since="1.9"
+          message="clone() method should be implemented only if implementing Cloneable interface"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.CloneMethodMustImplementCloneableRule"
+          typeResolution="true"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#clonemethodmustimplementcloneable">
+        <description>
+            The method clone() should only be implemented if the class implements the Cloneable interface with the exception of
+            a final method that only throws CloneNotSupportedException.
+
+            The rule can also detect, if the class implements or extends a Cloneable class.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class MyClass {
+ public Object clone() throws CloneNotSupportedException {
+  return foo;
+ }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="CloneMethodReturnTypeMustMatchClassName"
+          language="java"
+          minimumLanguageVersion="1.5"
+          since="5.4.0"
+          message="The return type of the clone() method must be the class name when implements Cloneable"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#clonemethodreturntypemustmatchclassname">
+        <description>
+            If a class implements cloneable the return type of the method clone() must be the class name. That way, the caller
+            of the clone method doesn't need to cast the returned clone to the correct type.
+
+            Note: This is only possible with Java 1.5 or higher.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//MethodDeclaration
+[
+@Name = 'clone'
+and @Arity = 0
+and not (ResultType//ClassOrInterfaceType/@Image = ancestor::ClassOrInterfaceDeclaration[1]/@SimpleName)
+]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo implements Cloneable {
+    @Override
+    protected Object clone() { // Violation, Object must be Foo
+    }
+}
+
+public class Foo implements Cloneable {
+    @Override
+    public Foo clone() { //Ok
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="CloneThrowsCloneNotSupportedException"
+          deprecated="true"
+          language="java"
+          since="1.9"
+          message="clone() method should throw CloneNotSupportedException"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#clonethrowsclonenotsupportedexception">
+        <description>
+            The method clone() should throw a CloneNotSupportedException.
+
+            This rule is deprecated since PMD 6.35.0 without replacement. The rule has no real value as
+            `CloneNotSupportedException` is a checked exception and therefore you need to deal with it while
+            implementing the `clone()` method. You either need to declare the exception or catch it. If you catch it,
+            then subclasses can't throw it themselves explicitly. However, `Object.clone()` will still throw this
+            exception if the `Cloneable` interface is not implemented.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//MethodDeclaration
+[
+@Name = 'clone'
+and @Arity = 0
+and count(NameList/Name[contains
+(@Image,'CloneNotSupportedException')]) = 0
+]
+[
+../../../../ClassOrInterfaceDeclaration[@Final = false()]
+]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class MyClass implements Cloneable{
+    public Object clone() { // will cause an error
+         MyClass clone = (MyClass)super.clone();
+         return clone;
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="CloseResource"
+          language="java"
+          since="1.2.2"
+          message="Ensure that resources like this {0} object are closed after use"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.CloseResourceRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#closeresource">
+        <description>
+            Ensure that resources (like `java.sql.Connection`, `java.sql.Statement`, and `java.sql.ResultSet` objects
+            and any subtype of `java.lang.AutoCloseable`) are always closed after use.
+            Failing to do so might result in resource leaks.
+
+            Note: It suffices to configure the super type, e.g. `java.lang.AutoClosable`, so that this rule automatically triggers
+            on any subtype (e.g. `java.io.FileInputStream`). Additionally specifying `java.sql.Connection` helps in detecting
+            the types, if the type resolution / auxclasspath is not correctly setup.
+
+            Note: Since PMD 6.16.0 the default value for the property `types` contains `java.lang.AutoCloseable` and detects
+            now cases where the standard `java.io.*Stream` classes are involved. In order to restore the old behaviour,
+            just remove "AutoCloseable" from the types.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class Bar {
+    public void withSQL() {
+        Connection c = pool.getConnection();
+        try {
+            // do stuff
+        } catch (SQLException ex) {
+           // handle exception
+        } finally {
+            // oops, should close the connection using 'close'!
+            // c.close();
+        }
+    }
+
+    public void withFile() {
+        InputStream file = new FileInputStream(new File("/tmp/foo"));
+        try {
+            int c = file.in();
+        } catch (IOException e) {
+            // handle exception
+        } finally {
+            // TODO: close file
+        }
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="CompareObjectsWithEquals"
+          language="java"
+          since="3.2"
+          message="Use equals() to compare object references."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#compareobjectswithequals">
+        <description>
+            Use `equals()` to compare object references; avoid comparing them with `==`.
+
+            Since comparing objects with named constants is useful in some cases (eg, when
+            defining constants for sentinel values), the rule ignores comparisons against
+            fields with all-caps name (eg `this == SENTINEL`), which is a common naming
+            convention for constant fields.
+
+            You may allow some types to be compared by reference by listing the exceptions
+            in the `typesThatCompareByReference` property.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="typesThatCompareByReference" type="List[String]" delimiter="," description="List of canonical type names for which reference comparison is allowed.">
+                <value>java.lang.Enum,java.lang.Class</value>
+            </property>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//EqualityExpression
+    [count(
+        PrimaryExpression[pmd-java:typeIs('java.lang.Object')]
+        [not(some $t in $typesThatCompareByReference satisfies pmd-java:typeIs($t))]
+       ) = 2
+    ]
+    [not(PrimaryExpression[PrimaryPrefix/@ThisModifier = true()]
+                          [not(PrimarySuffix)]
+                          [ancestor::MethodDeclaration[@Name = 'equals']])
+    ]
+    (: Is not a field access with an all-caps identifier :)
+    [not(PrimaryExpression[not(PrimarySuffix) and PrimaryPrefix/Name[upper-case(@Image)=@Image]
+     or PrimaryExpression/PrimarySuffix[last()][upper-case(@Image)=@Image]])]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+class Foo {
+  boolean bar(String a, String b) {
+    return a == b;
+  }
+}
+
+]]>
+        </example>
+    </rule>
+
+    <rule name="ComparisonWithNaN"
+          language="java"
+          since="6.36.0"
+          message="Comparisons with NaN always return false"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#comparisonwithnan">
+        <description><![CDATA[
+            Reports comparisons with double and float `NaN` (Not-a-Number) values.
+            These are [specified](https://docs.oracle.com/javase/specs/jls/se8/html/jls-15.html#jls-15.21.1)
+            to have unintuitive behavior: NaN is considered unequal to itself.
+            This means a check like `someDouble == Double.NaN` will always return
+            false, even if `someDouble` is really the NaN value. To test whether a
+            value is the NaN value, one should instead use `Double.isNaN(someDouble)`
+            (or `Float.isNaN`). The `!=` operator should be treated similarly.
+            Finally, comparisons like `someDouble <= Double.NaN` are nonsensical
+            and will always evaluate to false.
+
+            This rule has been renamed from "BadComparison" with PMD 6.36.0.
+        ]]></description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+(//EqualityExpression | //RelationalExpression)/PrimaryExpression/PrimaryPrefix/Name[@Image='Double.NaN' or @Image='Float.NaN']
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+boolean x = (y == Double.NaN);
+]]>
+        </example>
+    </rule>
+
+
+    <rule name="ConstructorCallsOverridableMethod"
+          language="java"
+          since="1.04"
+          message="Overridable {0} called during object construction"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.ConstructorCallsOverridableMethodRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#constructorcallsoverridablemethod">
+        <description>
+            Calling overridable methods during construction poses a risk of invoking methods on an incompletely
+            constructed object and can be difficult to debug.
+            It may leave the sub-class unable to construct its superclass or forced to replicate the construction
+            process completely within itself, losing the ability to call super().  If the default constructor
+            contains a call to an overridable method, the subclass may be completely uninstantiable.   Note that
+            this includes method calls throughout the control flow graph - i.e., if a constructor Foo() calls a
+            private method bar() that calls a public method buz(), this denotes a problem.
+        </description>
+        <priority>1</priority>
+        <example>
+            <![CDATA[
+public class SeniorClass {
+  public SeniorClass(){
+      toString(); //may throw NullPointerException if overridden
+  }
+  public String toString(){
+    return "IAmSeniorClass";
+  }
+}
+public class JuniorClass extends SeniorClass {
+  private String name;
+  public JuniorClass(){
+    super(); //Automatic call leads to NullPointerException
+    name = "JuniorClass";
+  }
+  public String toString(){
+    return name.toUpperCase();
+  }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="DataflowAnomalyAnalysis"
+          language="java"
+          since="3.9"
+          message="Found ''{0}''-anomaly for variable ''{1}'' (lines ''{2}''-''{3}'')."
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.DataflowAnomalyAnalysisRule"
+          dfa="true"
+          deprecated="true"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#dataflowanomalyanalysis">
+        <description>The dataflow analysis tracks local definitions, undefinitions and references to variables on different paths on the data flow.
+            From those informations there can be found various problems.
+
+            1. DU - Anomaly: A recently defined variable is undefined. These anomalies may appear in normal source text.
+            2. DD - Anomaly: A recently defined variable is redefined. This is ominous but don't have to be a bug.
+
+            This rule is deprecated. Use {% rule "java/bestpractices/UnusedAssignment" %} in category bestpractices instead.
+        </description>
+        <priority>5</priority>
+        <example>
+            <![CDATA[
+public void foo() {
+  int buz = 5;
+  buz = 6; // redefinition of buz -> dd-anomaly
+  foo(buz);
+  buz = 2;
+} // buz is undefined when leaving scope -> du-anomaly
+]]>
+        </example>
+    </rule>
+
+    <rule name="DetachedTestCase"
+          language="java"
+          since="6.13.0"
+          message="Probable detached JUnit test case."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          typeResolution="true"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#detachedtestcase">
+        <description>
+            The method appears to be a test case since it has public or default visibility,
+            non-static access, no arguments, no return value, has no annotations, but is a
+            member of a class that has one or more JUnit test cases. If it is a utility
+            method, it should likely have private visibility. If it is an ignored test, it
+            should be annotated with @Test and @Ignore.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value><![CDATA[
+//ClassOrInterfaceBodyDeclaration
+[../ClassOrInterfaceBodyDeclaration/Annotation/*/Name
+        [pmd-java:typeIs('org.junit.Test')
+         or pmd-java:typeIs('org.junit.jupiter.api.Test')
+         or pmd-java:typeIs('org.junit.jupiter.api.RepeatedTest')
+         or pmd-java:typeIs('org.junit.jupiter.api.TestFactory')
+         or pmd-java:typeIs('org.junit.jupiter.api.TestTemplate')
+         or pmd-java:typeIs('org.junit.jupiter.params.ParameterizedTest')]
+]
+[not(Annotation)]
+[MethodDeclaration[(@Public = true() or @PackagePrivate = true()) and @Static = false() and
+        ResultType[@Void = true()] and
+        MethodDeclarator/FormalParameters[@Size = 0]
+    ]
+]
+]]></value>
+            </property>
+            <property name="version" value="2.0" />
+        </properties>
+        <example>
+            <![CDATA[
+public class MyTest {
+    @Test
+    public void someTest() {
+    }
+
+    // violation: Not annotated
+    public void someOtherTest () {
+    }
+
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="DoNotCallGarbageCollectionExplicitly"
+          language="java"
+          since="4.2"
+          message="Do not explicitly trigger a garbage collection."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#donotcallgarbagecollectionexplicitly">
+        <description>
+            Calls to System.gc(), Runtime.getRuntime().gc(), and System.runFinalization() are not advised. Code should have the
+            same behavior whether the garbage collection is disabled using the option -Xdisableexplicitgc or not.
+            Moreover, "modern" jvms do a very good job handling garbage collections. If memory usage issues unrelated to memory
+            leaks develop within an application, it should be dealt with JVM options rather than within the code itself.
+        </description>
+        <priority>2</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//Name[
+(starts-with(@Image, 'System.') and
+(starts-with(@Image, 'System.gc') or
+starts-with(@Image, 'System.runFinalization'))) or
+(
+starts-with(@Image,'Runtime.getRuntime') and
+../../PrimarySuffix[ends-with(@Image,'gc')]
+)
+]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class GCCall {
+    public GCCall() {
+        // Explicit gc call !
+        System.gc();
+    }
+
+    public void doSomething() {
+        // Explicit gc call !
+        Runtime.getRuntime().gc();
+    }
+
+    public explicitGCcall() {
+        // Explicit gc call !
+        System.gc();
+    }
+
+    public void doSomething() {
+        // Explicit gc call !
+        Runtime.getRuntime().gc();
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="DoNotCallSystemExit" ref="category/java/errorprone.xml/DoNotTerminateVM" deprecated="true" />
+
+    <rule name="DoNotExtendJavaLangThrowable"
+          language="java"
+          since="6.0.0"
+          message="Exceptions should not extend java.lang.Throwable"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#donotextendjavalangthrowable">
+        <description>
+            Extend Exception or RuntimeException instead of Throwable.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//ClassOrInterfaceDeclaration/ExtendsList/ClassOrInterfaceType
+  [@Image="Throwable" or @Image="java.lang.Throwable"]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo extends Throwable { }
+]]>
+        </example>
+    </rule>
+
+    <rule name="DoNotHardCodeSDCard"
+          since="4.2.6"
+          language="java"
+          message="Do not hardcode /sdcard."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#donothardcodesdcard">
+        <description>
+            Use Environment.getExternalStorageDirectory() instead of "/sdcard"
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>//Literal[starts-with(@Image,'"/sdcard')]</value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class MyActivity extends Activity {
+    protected void foo() {
+        String storageLocation = "/sdcard/mypackage";   // hard-coded, poor approach
+
+       storageLocation = Environment.getExternalStorageDirectory() + "/mypackage"; // preferred approach
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="DoNotTerminateVM"
+          language="java"
+          since="4.1"
+          message="System.exit() should not be used in J2EE/JEE apps"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#donotterminatevm">
+        <description>
+            Web applications should not call `System.exit()`, since only the web container or the
+            application server should stop the JVM. Otherwise a web application would terminate all other applications
+            running on the same application server.
+
+            This rule also checks for the equivalent calls `Runtime.getRuntime().exit()` and `Runtime.getRuntime().halt()`.
+
+            This rule was called *DoNotCallSystemExit* until PMD 6.29.0.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//Name[
+    starts-with(@Image,'System.exit')
+    or
+    (starts-with(@Image,'Runtime.getRuntime') and ../../PrimarySuffix[ends-with(@Image,'exit') or ends-with(@Image,'halt')])
+][not(ancestor::MethodDeclaration[1][@Name="main" and @Static = true()])]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public void bar() {
+    System.exit(0);                 // never call this when running in an application server!
+}
+public void foo() {
+    Runtime.getRuntime().exit(0);   // never stop the JVM manually, the container will do this.
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="DoNotThrowExceptionInFinally"
+          language="java"
+          since="4.2"
+          message="A throw statement in a finally block makes the control flow hard to understand."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#donotthrowexceptioninfinally">
+        <description>
+            Throwing exceptions within a 'finally' block is confusing since they may mask other exceptions
+            or code defects.
+            Note: This is a PMD implementation of the Lint4j rule "A throw in a finally block"
+        </description>
+        <priority>4</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>//FinallyStatement[descendant::ThrowStatement]</value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo {
+    public void bar() {
+        try {
+            // Here do some stuff
+        } catch( Exception e) {
+            // Handling the issue
+        } finally {
+            // is this really a good idea ?
+            throw new Exception();
+        }
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="DontImportSun"
+          language="java"
+          since="1.5"
+          message="Avoid importing anything from the 'sun.*' packages"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.DontImportSunRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#dontimportsun">
+        <description>
+            Avoid importing anything from the 'sun.*' packages.  These packages are not portable and are likely to change.
+        </description>
+        <priority>4</priority>
+        <example>
+            <![CDATA[
+import sun.misc.foo;
+public class Foo {}
+]]>
+        </example>
+    </rule>
+
+    <rule name="DontUseFloatTypeForLoopIndices"
+          language="java"
+          since="4.3"
+          message="Don't use floating point for loop indices. If you must use floating point, use double."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#dontusefloattypeforloopindices">
+        <description>
+            Don't use floating point for loop indices. If you must use floating point, use double
+            unless you're certain that float provides enough precision and you have a compelling
+            performance need (space or time).
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//ForStatement/ForInit/LocalVariableDeclaration
+/Type/PrimitiveType[@Image="float"]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Count {
+  public static void main(String[] args) {
+    final int START = 2000000000;
+    int count = 0;
+    for (float f = START; f < START + 50; f++)
+      count++;
+      //Prints 0 because (float) START == (float) (START + 50).
+      System.out.println(count);
+      //The termination test misbehaves due to floating point granularity.
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="EmptyCatchBlock"
+          language="java"
+          since="0.1"
+          message="Avoid empty catch blocks"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#emptycatchblock">
+        <description>
+            Empty Catch Block finds instances where an exception is caught, but nothing is done.
+            In most circumstances, this swallows an exception which should either be acted on
+            or reported.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//CatchStatement
+ [not(Block/BlockStatement)]
+ [$allowCommentedBlocks != true() or Block/@containsComment = false()]
+ [FormalParameter/Type/ReferenceType
+   /ClassOrInterfaceType[@Image != 'InterruptedException' and @Image != 'CloneNotSupportedException']
+ ]
+ [FormalParameter/VariableDeclaratorId[not(matches(@Name, $allowExceptionNameRegex))]]
+]]>
+                </value>
+            </property>
+            <property name="allowCommentedBlocks" type="Boolean" description="Empty blocks containing comments will be skipped" value="false"/>
+            <property name="allowExceptionNameRegex" type="String" description="Empty blocks catching exceptions with names matching this regular expression will be skipped" value="^(ignored|expected)$"/>
+        </properties>
+        <example>
+            <![CDATA[
+public void doSomething() {
+    try {
+        FileInputStream fis = new FileInputStream("/tmp/bugger");
+    } catch (IOException ioe) {
+        // not good
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="EmptyFinalizer"
+          language="java"
+          since="1.5"
+          message="Avoid empty finalize methods"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#emptyfinalizer">
+        <description>
+            Empty finalize methods serve no purpose and should be removed. Note that Oracle has declared Object.finalize() as deprecated since JDK 9.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//MethodDeclaration[@Name='finalize'][@Arity = 0]
+  /Block[not(*)]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo {
+   protected void finalize() {}
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="EmptyFinallyBlock"
+          language="java"
+          since="0.4"
+          message="Avoid empty finally blocks"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#emptyfinallyblock">
+        <description>
+            Empty finally blocks serve no purpose and should be removed.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//FinallyStatement[not(Block/BlockStatement)]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo {
+    public void bar() {
+        try {
+            int x=2;
+        } finally {
+            // empty!
+        }
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="EmptyIfStmt"
+          language="java"
+          since="0.1"
+          message="Avoid empty 'if' statements"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#emptyifstmt">
+        <description>
+            Empty If Statement finds instances where a condition is checked but nothing is done about it.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//IfStatement/Statement
+ [EmptyStatement or Block[not(*)]]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo {
+ void bar(int x) {
+  if (x == 0) {
+   // empty!
+  }
+ }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="EmptyInitializer"
+          language="java"
+          since="5.0"
+          message="Empty initializer was found"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#emptyinitializer">
+        <description>
+            Empty initializers serve no purpose and should be removed.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>//Initializer/Block[not(*)]</value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo {
+
+   static {} // Why ?
+
+   {} // Again, why ?
+
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="EmptyStatementBlock"
+          language="java"
+          since="5.0"
+          message="Avoid empty block statements."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#emptystatementblock">
+        <description>
+            Empty block statements serve no purpose and should be removed.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>//BlockStatement/Statement/Block[not(*)]</value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo {
+
+   private int _bar;
+
+   public void setBar(int bar) {
+      { _bar = bar; } // Why not?
+      {} // But remove this.
+   }
+
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="EmptyStatementNotInLoop"
+          language="java"
+          since="1.5"
+          message="An empty statement (semicolon) not part of a loop"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#emptystatementnotinloop">
+        <description>
+            An empty statement (or a semicolon by itself) that is not used as the sole body of a 'for'
+            or 'while' loop is probably a bug.  It could also be a double semicolon, which has no purpose
+            and should be removed.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//EmptyStatement
+ [not(
+       ../../../ForStatement
+       or ../../../WhileStatement
+       or ../../../BlockStatement/ClassOrInterfaceDeclaration
+       or ../../../../../../ForStatement/Statement[1]
+        /Block[1]/BlockStatement[1]/Statement/EmptyStatement
+       or ../../../../../../WhileStatement/Statement[1]
+        /Block[1]/BlockStatement[1]/Statement/EmptyStatement)
+ ]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public void doit() {
+      // this is probably not what you meant to do
+      ;
+      // the extra semicolon here this is not necessary
+      System.out.println("look at the extra semicolon");;
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="EmptySwitchStatements"
+          language="java"
+          since="1.0"
+          message="Avoid empty switch statements"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#emptyswitchstatements">
+        <description>
+            Empty switch statements serve no purpose and should be removed.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>//SwitchStatement[count(*) = 1]</value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public void bar() {
+    int x = 2;
+    switch (x) {
+        // once there was code here
+        // but it's been commented out or something
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="EmptySynchronizedBlock"
+          language="java"
+          since="1.3"
+          message="Avoid empty synchronized blocks"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#emptysynchronizedblock">
+        <description>
+            Empty synchronized blocks serve no purpose and should be removed.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>//SynchronizedStatement/Block[1][not(*)]</value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo {
+    public void bar() {
+        synchronized (this) {
+            // empty!
+        }
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="EmptyTryBlock"
+          language="java"
+          since="0.4"
+          message="Avoid empty try blocks"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#emptytryblock">
+        <description>
+            Avoid empty try blocks - what's the point?
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//TryStatement[not(ResourceSpecification)]/Block[1][not(*)]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo {
+    public void bar() {
+        try {
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="EmptyWhileStmt"
+          language="java"
+          since="0.2"
+          message="Avoid empty 'while' statements"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#emptywhilestmt">
+        <description>
+            Empty While Statement finds all instances where a while statement does nothing.
+            If it is a timing loop, then you should use Thread.sleep() for it; if it is
+            a while loop that does a lot in the exit expression, rewrite it to make it clearer.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//WhileStatement/Statement[Block[not(*)] or EmptyStatement]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+void bar(int a, int b) {
+    while (a == b) {
+        // empty!
+    }
+}
+ ]]>
+        </example>
+    </rule>
+
+    <rule name="EqualsNull"
+          language="java"
+          since="1.9"
+          message="Avoid using equals() to compare against null"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#equalsnull">
+        <description>
+            Tests for null should not use the equals() method. The '==' operator should be used instead.
+        </description>
+        <priority>1</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//PrimaryExpression
+  [
+    PrimaryPrefix[Name[ends-with(@Image, 'equals')]]
+      [following-sibling::node()/Arguments/ArgumentList[count(Expression)=1]
+          /Expression/PrimaryExpression/PrimaryPrefix/Literal/NullLiteral]
+
+    or
+
+    PrimarySuffix[ends-with(@Image, 'equals')]
+      [following-sibling::node()/Arguments/ArgumentList[count(Expression)=1]
+          /Expression/PrimaryExpression/PrimaryPrefix/Literal/NullLiteral]
+
+  ]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+String x = "foo";
+
+if (x.equals(null)) {   // bad form
+    doSomething();
+}
+
+if (x == null) {        // preferred
+    doSomething();
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="FinalizeDoesNotCallSuperFinalize"
+          language="java"
+          since="1.5"
+          message="Last statement in finalize method should be a call to super.finalize()"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#finalizedoesnotcallsuperfinalize">
+        <description>
+            If the finalize() is implemented, its last action should be to call super.finalize. Note that Oracle has declared Object.finalize() as deprecated since JDK 9.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <!-- in English: a method declaration of finalize(), with no arguments, containing
+                    a block whose last statement is NOT a call to super.finalize -->
+                    <![CDATA[
+//MethodDeclaration[@Name='finalize'][@Arity = 0]
+   /Block
+      /BlockStatement[last()]
+      [not(Statement/StatementExpression/PrimaryExpression
+            [./PrimaryPrefix[@SuperModifier= true()]]
+            [./PrimarySuffix[@Image='finalize']]
+          )
+      ]
+      [not(Statement/TryStatement/FinallyStatement
+       /Block/BlockStatement/Statement/StatementExpression/PrimaryExpression
+            [./PrimaryPrefix[@SuperModifier= true()]]
+            [./PrimarySuffix[@Image='finalize']]
+          )
+      ]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+protected void finalize() {
+    something();
+    // neglected to call super.finalize()
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="FinalizeOnlyCallsSuperFinalize"
+          language="java"
+          since="1.5"
+          message="Finalize should do something besides just calling super.finalize()"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#finalizeonlycallssuperfinalize">
+        <description>
+            If the finalize() is implemented, it should do something besides just calling super.finalize(). Note that Oracle has declared Object.finalize() as deprecated since JDK 9.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//MethodDeclaration[@Name='finalize'][@Arity = 0]
+   /Block[count(BlockStatement)=1]
+     /BlockStatement[
+       Statement/StatementExpression/PrimaryExpression
+       [./PrimaryPrefix[@SuperModifier= true()]]
+       [./PrimarySuffix[@Image='finalize']]
+     ]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+protected void finalize() {
+    super.finalize();
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="FinalizeOverloaded"
+          language="java"
+          since="1.5"
+          message="Finalize methods should not be overloaded"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#finalizeoverloaded">
+        <description>
+            Methods named finalize() should not have parameters.  It is confusing and most likely an attempt to
+            overload Object.finalize(). It will not be called by the VM.
+
+            Note that Oracle has declared Object.finalize() as deprecated since JDK 9.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//MethodDeclaration[@Name='finalize'][@Arity > 0]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo {
+    // this is confusing and probably a bug
+    protected void finalize(int a) {
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="FinalizeShouldBeProtected"
+          language="java"
+          since="1.1"
+          message="If you override finalize(), make it protected"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#finalizeshouldbeprotected">
+        <description>
+            When overriding the finalize(), the new method should be set as protected.  If made public,
+            other classes may invoke it at inappropriate times.
+
+            Note that Oracle has declared Object.finalize() as deprecated since JDK 9.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//MethodDeclaration[@Protected=false()][@Name='finalize'][@Arity = 0]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public void finalize() {
+    // do something
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="IdempotentOperations"
+          language="java"
+          since="2.0"
+          message="Avoid idempotent operations (like assigning a variable to itself)."
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.IdempotentOperationsRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#idempotentoperations">
+        <description>
+            Avoid idempotent operations - they have no effect.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class Foo {
+ public void bar() {
+  int x = 2;
+  x = x;
+ }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="ImplicitSwitchFallThrough"
+          language="java"
+          since="3.0"
+          message="A switch statement does not contain a break"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#implicitswitchfallthrough">
+        <description>
+            Switch statements without break or return statements for each case option
+            may indicate problematic behaviour. Empty cases are ignored as these indicate an intentional fall-through.
+
+            This rule has been renamed from "MissingBreakInSwitch" with PMD 6.37.0.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//SwitchStatement
+[(count(.//BreakStatement)
+ + count(BlockStatement//Statement/ReturnStatement)
+ + count(BlockStatement//Statement/ContinueStatement)
+ + count(BlockStatement//Statement/ThrowStatement)
+ + count(BlockStatement//Statement/IfStatement[@Else= true() and Statement[2][ReturnStatement|ContinueStatement|ThrowStatement]]/Statement[1][ReturnStatement|ContinueStatement|ThrowStatement])
+ + count(SwitchLabel[ following-sibling::node()[1][self::SwitchLabel] ])
+ + count(SwitchLabel[count(following-sibling::node()) = 0])
+  < count (SwitchLabel))]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public void bar(int status) {
+    switch(status) {
+      case CANCELLED:
+        doCancelled();
+        // break; hm, should this be commented out?
+      case NEW:
+        doNew();
+        // is this really a fall-through?
+      case REMOVED:
+        doRemoved();
+        // what happens if you add another case after this one?
+      case OTHER: // empty case - this is interpreted as an intentional fall-through
+      case ERROR:
+        doErrorHandling();
+        break;
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="ImportFromSamePackage"
+          language="java"
+          since="1.02"
+          deprecated="true"
+          message="No need to import a type that lives in the same package"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.ImportFromSamePackageRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#importfromsamepackage">
+        <description>
+            There is no need to import a type that lives in the same package.
+
+            This rule is deprecated since PMD 6.34.0. Use the rule {% rule "java/codestyle/UnnecessaryImport" %}
+            from category codestyle instead.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+package foo;
+
+import foo.Buz;     // no need for this
+import foo.*;       // or this
+
+public class Bar{}
+]]>
+        </example>
+    </rule>
+
+    <rule name="InstantiationToGetClass"
+          language="java"
+          since="2.0"
+          message="Avoid instantiating an object just to call getClass() on it; use the .class public member instead"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#instantiationtogetclass">
+        <description>
+            Avoid instantiating an object just to call getClass() on it; use the .class public member instead.
+        </description>
+        <priority>4</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//PrimarySuffix
+ [@Image='getClass']
+ [parent::PrimaryExpression
+  [PrimaryPrefix/AllocationExpression]
+  [count(PrimarySuffix) = 2]
+ ]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+// replace this
+Class c = new String().getClass();
+
+// with this:
+Class c = String.class;
+]]>
+        </example>
+    </rule>
+
+    <rule name="InvalidSlf4jMessageFormat"
+          ref="category/java/errorprone.xml/InvalidLogMessageFormat"
+          deprecated="true" />
+
+    <rule name="InvalidLogMessageFormat"
+          language="java"
+          since="5.5.0"
+          message="Invalid message format"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.InvalidLogMessageFormatRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#invalidlogmessageformat">
+        <description>
+            Check for messages in slf4j and log4j2 (since 6.19.0) loggers with non matching number of arguments and placeholders.
+
+            Since 6.32.0 in addition to parameterized message placeholders (`{}`) also format specifiers of string formatted
+            messages are supported (`%s`).
+        </description>
+        <priority>5</priority>
+        <example>
+            <![CDATA[
+LOGGER.error("forget the arg {}");
+LOGGER.error("forget the arg %s");
+LOGGER.error("too many args {}", "arg1", "arg2");
+LOGGER.error("param {}", "arg1", new IllegalStateException("arg")); //The exception is shown separately, so is correct.
+]]>
+        </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_errorprone.html#jumbledincrementer">
+        <description>
+            Avoid jumbled loop incrementers - its usually a mistake, and is confusing even if intentional.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value><![CDATA[
+//ForStatement
+  [
+    ForUpdate/StatementExpressionList/StatementExpression/PostfixExpression/PrimaryExpression/PrimaryPrefix/Name/@Image
+    =
+    ancestor::ForStatement/ForInit//VariableDeclaratorId/@Name
+  ]
+]]>
+                </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="JUnitSpelling"
+          language="java"
+          since="1.0"
+          message="You may have misspelled a JUnit framework method (setUp or tearDown)"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.JUnitSpellingRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#junitspelling">
+        <description>
+            In JUnit 3, the setUp method is used to set up all data entities required in running tests.
+            The tearDown method is used to clean up all data entities required in running tests.
+            You should not misspell method name if you want your test to set up and clean up everything correctly.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+import junit.framework.*;
+
+public class Foo extends TestCase {
+    public void setup() {}    // oops, should be setUp
+    public void TearDown() {} // oops, should be tearDown
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="JUnitStaticSuite"
+          language="java"
+          since="1.0"
+          message="You have a suite() method that is not both public and static, so JUnit won't call it to get your TestSuite.  Is that what you wanted to do?"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.JUnitStaticSuiteRule"
+          typeResolution="true"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#junitstaticsuite">
+        <description>
+            The suite() method in a JUnit test needs to be both public and static.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+import junit.framework.*;
+
+public class Foo extends TestCase {
+    public void suite() {}         // oops, should be static
+    private static void suite() {} // oops, should be public
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="LoggerIsNotStaticFinal"
+          language="java"
+          since="2.0"
+          message="The Logger variable declaration does not contain the static and final modifiers"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#loggerisnotstaticfinal"
+          deprecated="true">
+        <description>
+            In most cases, the Logger reference can be declared as static and final.
+
+            This rule is deprecated and will be removed with PMD 7.0.0.
+            The rule is replaced by {% rule java/errorprone/ProperLogger %}.
+        </description>
+        <priority>2</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//VariableDeclarator
+ [parent::FieldDeclaration]
+ [../Type/ReferenceType
+  /ClassOrInterfaceType[@Image='Logger']
+   and
+  (..[@Final= false()] or ..[@Static = false()] ) ]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo{
+    Logger log = Logger.getLogger(Foo.class.getName());                 // not recommended
+
+    static final Logger log = Logger.getLogger(Foo.class.getName());    // preferred approach
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="MethodWithSameNameAsEnclosingClass"
+          language="java"
+          since="1.5"
+          message="Classes should not have non-constructor methods with the same name as the class"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.MethodWithSameNameAsEnclosingClassRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#methodwithsamenameasenclosingclass">
+        <description>
+            Non-constructor methods should not have the same name as the enclosing class.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class MyClass {
+
+    public MyClass() {}         // this is OK because it is a constructor
+
+    public void MyClass() {}    // this is bad because it is a method
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="MisplacedNullCheck"
+          language="java"
+          since="3.5"
+          message="The null check here is misplaced; if the variable ''{0}'' is null there will be a NullPointerException"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#misplacednullcheck">
+        <description>
+            The null check here is misplaced. If the variable is null a NullPointerException will be thrown.
+            Either the check is useless (the variable will never be "null") or it is incorrect.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//ConditionalAndExpression
+  /EqualityExpression
+    [@Image = '!=']
+    (: one side is null :)
+    [PrimaryExpression/PrimaryPrefix/Literal/NullLiteral]
+    (: other side checks for the variable used somewhere in the first child of conditional and expression :)
+    [some $var in preceding-sibling::PrimaryExpression//Name
+      [not(ancestor::ConditionalOrExpression/EqualityExpression[@Image = '=='])]
+      /@Image
+      satisfies starts-with($var, concat(PrimaryExpression/PrimaryPrefix/Name/@Image, '.'))]
+  /PrimaryExpression/PrimaryPrefix/Name
+|
+//ConditionalOrExpression
+  /EqualityExpression
+    [@Image = '==']
+    (: one side is null :)
+    [PrimaryExpression/PrimaryPrefix/Literal/NullLiteral]
+    (: other side checks for the variable used somewhere in the first child of conditional or expression :)
+    [some $var in preceding-sibling::PrimaryExpression//Name
+      [not(ancestor::ConditionalAndExpression/EqualityExpression[@Image = '!='])]
+      /@Image
+      satisfies starts-with($var, concat(PrimaryExpression/PrimaryPrefix/Name/@Image, '.'))]
+  /PrimaryExpression/PrimaryPrefix/Name
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo {
+    void bar() {
+        if (a.equals(baz) && a != null) {} // a could be null, misplaced null check
+
+        if (a != null && a.equals(baz)) {} // correct null check
+    }
+}
+]]>
+        </example>
+        <example>
+            <![CDATA[
+public class Foo {
+    void bar() {
+        if (a.equals(baz) || a == null) {} // a could be null, misplaced null check
+
+        if (a == null || a.equals(baz)) {} // correct null check
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="MissingBreakInSwitch" ref="ImplicitSwitchFallThrough" deprecated="true"/>
+
+    <rule name="MissingSerialVersionUID"
+          language="java"
+          since="3.0"
+          message="Classes implementing Serializable should set a serialVersionUID"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          typeResolution="true"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#missingserialversionuid">
+        <description>
+            Serializable classes should provide a serialVersionUID field.
+            The serialVersionUID field is also needed for abstract base classes. Each individual class in the inheritance
+            chain needs an own serialVersionUID field. See also [Should an abstract class have a serialVersionUID](https://stackoverflow.com/questions/893259/should-an-abstract-class-have-a-serialversionuid).
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//ClassOrInterfaceDeclaration
+    [@Interface = false()]
+    [count(ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration
+        /FieldDeclaration/VariableDeclarator/VariableDeclaratorId[@Name='serialVersionUID']) = 0]
+    [(ImplementsList | ExtendsList)/ClassOrInterfaceType[pmd-java:typeIs('java.io.Serializable')]]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo implements java.io.Serializable {
+    String name;
+    // Define serialization id to avoid serialization related bugs
+    // i.e., public static final long serialVersionUID = 4328743;
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="MissingStaticMethodInNonInstantiatableClass"
+          language="java"
+          since="3.0"
+          message="Class cannot be instantiated and does not provide any static methods or fields"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#missingstaticmethodinnoninstantiatableclass">
+        <description>
+            A class that has private constructors and does not have any static methods or fields cannot be used.
+
+            When one of the private constructors is annotated with one of the annotations, then the class is not considered
+            non-instantiatable anymore and no violation will be reported.
+            See the property `annotations`.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="annotations" type="List[String]" delimiter="," value="org.springframework.beans.factory.annotation.Autowired,javax.inject.Inject" description="If a constructor is annotated with one of these annotations, then the class is ignored."/>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//ClassOrInterfaceDeclaration[@Nested= false()]
+[
+  (
+    (: at least one constructor :)
+    ./ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration/ConstructorDeclaration
+    and
+    (: only private constructors :)count(./ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration/ConstructorDeclaration) = count(./ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration/ConstructorDeclaration[@Private= true()])
+    and
+    (: all constructors must not be annotated :)
+    (every $x in $annotations satisfies
+      not(./ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration/ConstructorDeclaration/
+            ../Annotation/MarkerAnnotation/Name[pmd-java:typeIs($x)]))
+  )
+  and
+  (: no static methods :)not(.//MethodDeclaration[@Static= true()])
+  and
+  (: no (public, package-private, protected) static fields :)not(.//FieldDeclaration[@Private= false()][@Static= true()])
+  and
+  (: no nested classes, that are public and static, and have no constructors at all or a public constructor :)
+  (: and have a method returning the outer class type :)
+  (: or the inner class extends the outer class :)not(.//ClassOrInterfaceDeclaration[@Nested= true()]
+           [@Public= true()]
+           [@Static= true()]
+           [not(./ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration/ConstructorDeclaration) or ./ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration/ConstructorDeclaration[@Public= true()]]
+           [(./ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration/MethodDeclaration
+                [@Public= true()]
+                [./ResultType/Type/ReferenceType/ClassOrInterfaceType
+                    [@Image = //ClassOrInterfaceDeclaration[@Nested= false()]/@SimpleName]
+                ]
+            ) or (
+                ./ExtendsList/ClassOrInterfaceType[@Image = //ClassOrInterfaceDeclaration[@Nested=false()]/@SimpleName]
+            )]
+        )
+]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+// This class is unusable, since it cannot be
+// instantiated (private constructor),
+// and no static method can be called.
+
+public class Foo {
+  private Foo() {}
+  void foo() {}
+}
+
+]]>
+        </example>
+    </rule>
+
+    <rule name="MoreThanOneLogger"
+          language="java"
+          since="2.0"
+          message="Class contains more than one logger."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#morethanonelogger">
+        <description>
+            Normally only one logger is used in each class. This rule supports slf4j, log4j, Java Util Logging and
+            log4j2 (since 6.19.0).
+        </description>
+        <priority>2</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value><![CDATA[
+//ClassOrInterfaceDeclaration[
+  count(
+    ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration/FieldDeclaration//ClassOrInterfaceType[
+      pmd-java:typeIs("org.apache.log4j.Logger") or
+      pmd-java:typeIs("org.apache.logging.log4j.Logger") or
+      pmd-java:typeIs("java.util.logging.Logger") or
+      pmd-java:typeIs("org.slf4j.Logger")
+    ]
+  ) > 1
+]
+                ]]></value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo {
+    Logger log = Logger.getLogger(Foo.class.getName());
+    // It is very rare to see two loggers on a class, normally
+    // log information is multiplexed by levels
+    Logger log2= Logger.getLogger(Foo.class.getName());
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="NonCaseLabelInSwitchStatement"
+          language="java"
+          since="1.5"
+          message="A non-case label was present in a switch statement"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#noncaselabelinswitchstatement">
+        <description>
+            A non-case label (e.g. a named break/continue label) was present in a switch statement.
+            This legal, but confusing. It is easy to mix up the case labels and the non-case labels.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>//SwitchStatement//BlockStatement/Statement/LabeledStatement</value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo {
+  void bar(int a) {
+   switch (a) {
+     case 1:
+       // do something
+       break;
+     mylabel: // this is legal, but confusing!
+       break;
+     default:
+       break;
+    }
+  }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="NonStaticInitializer"
+          language="java"
+          since="1.5"
+          message="Non-static initializers are confusing"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#nonstaticinitializer">
+        <description>
+            A non-static initializer block will be called any time a constructor is invoked (just prior to
+            invoking the constructor).  While this is a valid language construct, it is rarely used and is
+            confusing.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0" />
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//Initializer[@Static=false()][not(ancestor::*[3][self::AllocationExpression or self::EnumConstant])]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class MyClass {
+  // this block gets run before any call to a constructor
+  {
+    System.out.println("I am about to construct myself");
+  }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="NullAssignment"
+          language="java"
+          since="1.02"
+          message="Assigning an Object to null is a code smell.  Consider refactoring."
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.NullAssignmentRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#nullassignment">
+        <description>
+            Assigning a "null" to a variable (outside of its declaration) is usually bad form.  Sometimes, this type
+            of assignment is an indication that the programmer doesn't completely understand what is going on in the code.
+
+            NOTE: This sort of assignment may used in some cases to dereference objects and encourage garbage collection.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public void bar() {
+  Object x = null; // this is OK
+  x = new Object();
+     // big, complex piece of code here
+  x = null; // this is not required
+     // big, complex piece of code here
+}
+]]>
+        </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.errorprone.OverrideBothEqualsAndHashcodeRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.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>
+
+    <rule name="ProperCloneImplementation"
+          language="java"
+          since="1.4"
+          message="Object clone() should be implemented with super.clone()"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.ProperCloneImplementationRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#propercloneimplementation">
+        <description>
+            Object clone() should be implemented with super.clone().
+        </description>
+        <priority>2</priority>
+        <example>
+            <![CDATA[
+class Foo{
+    public Object clone(){
+        return new Foo(); // This is bad
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="ProperLogger"
+          language="java"
+          since="3.3"
+          message="Logger should be defined private static final and have the correct class"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#properlogger"
+          typeResolution="true">
+        <description>
+            A logger should normally be defined private static final and be associated with the correct class.
+            `private final Log log;` is also allowed for rare cases where loggers need to be passed around,
+            with the restriction that the logger needs to be passed into the constructor.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//FieldDeclaration
+[Type/ReferenceType/ClassOrInterfaceType[pmd-java:typeIs($loggerClass)]]
+[
+    (: check modifiers :)
+    (@Private = false() or @Final = false())
+    (: check logger name :)
+    or (@Static and VariableDeclarator/VariableDeclaratorId[@Name != $staticLoggerName])
+    or (@Static = false() and VariableDeclarator/VariableDeclaratorId[@Name != $loggerName])
+
+    (: check logger argument type matches class or enum name :)
+    or .//ArgumentList//ClassOrInterfaceType[@Image != ancestor::ClassOrInterfaceDeclaration/@SimpleName]
+    or .//ArgumentList//ClassOrInterfaceType[@Image != ancestor::EnumDeclaration/@SimpleName]
+]
+[not(
+     (: special case - final logger initialized inside constructor :)
+     not(VariableDeclarator/VariableInitializer)
+     and @Static = false()
+     and
+     ancestor::ClassOrInterfaceBody//ConstructorDeclaration//StatementExpression
+        [PrimaryExpression[PrimaryPrefix[@ThisModifier]]/PrimarySuffix[@Image=$loggerName]]
+        [AssignmentOperator[@Image = '=']]
+        [Expression/PrimaryExpression/PrimaryPrefix/Name[@Image = ancestor::ConstructorDeclaration//FormalParameter/VariableDeclaratorId/@Name]]
+        [not(.//AllocationExpression)]
+  )
+]
+]]>
+                </value>
+            </property>
+            <property name="staticLoggerName" type="String" description="Name of the static Logger variable" value="LOG"/>
+            <property name="loggerName" type="String" description="Name of the Logger instance variable" value="log"/>
+            <property name="loggerClass" type="String" description="Class name of the logger" value="Log"/>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo {
+
+    private static final Log LOG = LogFactory.getLog(Foo.class);    // proper way
+
+    protected Log LOG = LogFactory.getLog(Testclass.class);         // wrong approach
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="ReturnEmptyArrayRatherThanNull"
+          language="java"
+          since="4.2"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          deprecated="true"
+          message="Return an empty array rather than 'null'."
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#returnemptyarrayratherthannull">
+        <description>
+            For any method that returns an array, it is a better to return an empty array rather than a
+            null reference. This removes the need for null checking all results and avoids inadvertent
+            NullPointerExceptions.
+
+            Deprecated since PMD 6.37.0, use {% rule java/errorprone/ReturnEmptyCollectionRatherThanNull %} instead.
+        </description>
+        <priority>1</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//MethodDeclaration
+[
+(./ResultType/Type[@ArrayType= true()])
+and
+(./Block/BlockStatement/Statement/ReturnStatement/Expression/PrimaryExpression/PrimaryPrefix/Literal/NullLiteral)
+]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Example {
+    // Not a good idea...
+    public int[] badBehavior() {
+        // ...
+        return null;
+    }
+
+    // Good behavior
+    public String[] bonnePratique() {
+        //...
+        return new String[0];
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="ReturnEmptyCollectionRatherThanNull"
+          language="java"
+          since="6.37.0"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          message="Return an empty collection rather than 'null'."
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#returnemptycollectionratherthannull">
+        <description>
+            For any method that returns an collection (such as an array, Collection or Map), it is better to return
+            an empty one rather than a null reference. This removes the need for null checking all results and avoids
+            inadvertent NullPointerExceptions.
+
+            See Effective Java, 3rd Edition, Item 54: Return empty collections or arrays instead of null
+        </description>
+        <priority>1</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//MethodDeclaration
+[
+(./ResultType/Type[pmd-java:typeIs('java.util.Collection') or pmd-java:typeIs('java.util.Map') or @ArrayType=true()])
+and
+(./Block/BlockStatement/Statement/ReturnStatement/Expression/PrimaryExpression/PrimaryPrefix/Literal/NullLiteral)
+]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Example {
+    // Not a good idea...
+    public int[] badBehavior() {
+        // ...
+        return null;
+    }
+
+    // Good behavior
+    public String[] bonnePratique() {
+        //...
+        return new String[0];
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="ReturnFromFinallyBlock"
+          language="java"
+          since="1.05"
+          message="Avoid returning from a finally block"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#returnfromfinallyblock">
+        <description>
+            Avoid returning from a finally block, this can discard exceptions.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>//FinallyStatement//ReturnStatement except //FinallyStatement//(MethodDeclaration|LambdaExpression)//ReturnStatement</value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Bar {
+    public String foo() {
+        try {
+            throw new Exception( "My Exception" );
+        } catch (Exception e) {
+            throw e;
+        } finally {
+            return "A. O. K."; // return not recommended here
+        }
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="SimpleDateFormatNeedsLocale"
+          language="java"
+          since="2.0"
+          message="When instantiating a SimpleDateFormat object, specify a Locale"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#simpledateformatneedslocale">
+        <description>
+            Be sure to specify a Locale when creating SimpleDateFormat instances to ensure that locale-appropriate
+            formatting is used.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//AllocationExpression
+ [ClassOrInterfaceType[@Image='SimpleDateFormat']]
+ [Arguments[@Size=1]]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo {
+  // Should specify Locale.US (or whatever)
+  private SimpleDateFormat sdf = new SimpleDateFormat("pattern");
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="SingleMethodSingleton"
+          language="java"
+          since="5.4"
+          message="Class contains multiple getInstance methods. Please review."
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.SingleMethodSingletonRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#singlemethodsingleton">
+        <description>
+            Some classes contain overloaded getInstance. The problem with overloaded getInstance methods
+            is that the instance created using the overloaded method is not cached and so,
+            for each call and new objects will be created for every invocation.
+        </description>
+        <priority>2</priority>
+        <example>
+            <![CDATA[
+public class Singleton {
+
+    private static Singleton singleton = new Singleton( );
+
+    private Singleton(){ }
+
+    public static Singleton getInstance( ) {
+        return singleton;
+    }
+
+    public static Singleton getInstance(Object obj){
+        Singleton singleton = (Singleton) obj;
+        return singleton;           //violation
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="SingletonClassReturningNewInstance"
+          language="java"
+          since="5.4"
+          message="getInstance method always creates a new object and hence does not comply to Singleton Design Pattern behaviour. Please review"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.SingletonClassReturningNewInstanceRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#singletonclassreturningnewinstance">
+        <description>
+            A singleton class should only ever have one instance. Failure to check
+            whether an instance has already been created may result in multiple
+            instances being created.
+        </description>
+        <priority>2</priority>
+        <example>
+            <![CDATA[
+class Singleton {
+    private static Singleton instance = null;
+    public static Singleton getInstance() {
+        synchronized(Singleton.class) {
+            return new Singleton(); // this should be assigned to the field
+        }
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="StaticEJBFieldShouldBeFinal"
+          language="java"
+          since="4.1"
+          message="EJB's shouldn't have non-final static fields"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#staticejbfieldshouldbefinal">
+        <description>
+            According to the J2EE specification, an EJB should not have any static fields
+            with write access. However, static read-only fields are allowed. This ensures proper
+            behavior especially when instances are distributed by the container on several JREs.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//ClassOrInterfaceDeclaration[
+    (
+    (./ImplementsList/ClassOrInterfaceType[ends-with(@Image,'SessionBean')])
+    or
+    (./ImplementsList/ClassOrInterfaceType[ends-with(@Image,'EJBHome')])
+    or
+    (./ImplementsList/ClassOrInterfaceType[ends-with(@Image,'EJBLocalObject')])
+    or
+    (./ImplementsList/ClassOrInterfaceType[ends-with(@Image,'EJBLocalHome')])
+    or
+    (./ExtendsList/ClassOrInterfaceType[ends-with(@Image,'EJBObject')])
+    )
+    and
+    (./ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration[
+         (./FieldDeclaration[@Static = true()])
+         and
+         (./FieldDeclaration[@Final = false()])
+    ])
+]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class SomeEJB extends EJBObject implements EJBLocalHome {
+
+    private static int CountA;          // poor, field can be edited
+
+    private static final int CountB;    // preferred, read-only access
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="StringBufferInstantiationWithChar"
+          language="java"
+          since="3.9"
+          message="Do not instantiate a StringBuffer or StringBuilder with a char"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#stringbufferinstantiationwithchar">
+        <description>
+            Individual character values provided as initialization arguments will be converted into integers.
+            This can lead to internal buffer sizes that are larger than expected. Some examples:
+
+            ```
+            new StringBuffer()      //  16
+            new StringBuffer(6)     //  6
+            new StringBuffer("hello world")  // 11 + 16 = 27
+            new StringBuffer('A')   //  chr(A) = 65
+            new StringBuffer("A")   //  1 + 16 = 17
+
+            new StringBuilder()     //  16
+            new StringBuilder(6)    //  6
+            new StringBuilder("hello world")  // 11 + 16 = 27
+            new StringBuilder('C')   //  chr(C) = 67
+            new StringBuilder("A")   //  1 + 16 = 17
+            ```
+        </description>
+        <priority>4</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//AllocationExpression/ClassOrInterfaceType
+[@Image='StringBuffer' or @Image='StringBuilder']
+/../Arguments/ArgumentList/Expression/PrimaryExpression
+/PrimaryPrefix/
+Literal
+  [starts-with(@Image, "'")]
+  [ends-with(@Image, "'")]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+// misleading instantiation, these buffers
+// are actually sized to 99 characters long
+StringBuffer  sb1 = new StringBuffer('c');
+StringBuilder sb2 = new StringBuilder('c');
+
+// in these forms, just single characters are allocated
+StringBuffer  sb3 = new StringBuffer("c");
+StringBuilder sb4 = new StringBuilder("c");
+]]>
+        </example>
+    </rule>
+
+    <rule name="SuspiciousEqualsMethodName"
+          language="java"
+          since="2.0"
+          message="The method name and parameter number are suspiciously close to equals(Object)"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#suspiciousequalsmethodname">
+        <description>
+            The method name and parameter number are suspiciously close to `Object.equals`, which can denote an
+            intention to override it. However, the method does not override `Object.equals`, but overloads it instead.
+            Overloading `Object.equals` method is confusing for other programmers, error-prone and hard to maintain,
+            especially when using inheritance, because `@Override` annotations used in subclasses can provide a false
+            sense of security. For more information on `Object.equals` method, see Effective Java, 3rd Edition,
+            Item 10: Obey the general contract when overriding equals.
+        </description>
+        <priority>2</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//MethodDeclaration[@Name = 'equals']
+[
+    (@Arity = 1
+    and not (MethodDeclarator/FormalParameters/FormalParameter/Type/ReferenceType/ClassOrInterfaceType
+        [@Image = 'Object' or @Image = 'java.lang.Object'])
+    or not (ResultType/Type/PrimitiveType[@Image = 'boolean'])
+    )  or  (
+    @Arity = 2
+    and ResultType/Type/PrimitiveType[@Image = 'boolean']
+    and MethodDeclarator/FormalParameters//ClassOrInterfaceType[@Image = 'Object' or @Image = 'java.lang.Object']
+    and not(../Annotation/MarkerAnnotation/Name[@Image='Override'])
+    )
+]
+| //MethodDeclaration[@Name = 'equal']
+[
+    @Arity = 1
+    and MethodDeclarator/FormalParameters/FormalParameter/Type/ReferenceType/ClassOrInterfaceType
+        [@Image = 'Object' or @Image = 'java.lang.Object']
+]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo {
+   public int equals(Object o) {
+     // oops, this probably was supposed to be boolean equals
+   }
+   public boolean equals(String s) {
+     // oops, this probably was supposed to be equals(Object)
+   }
+   public boolean equals(Object o1, Object o2) {
+     // oops, this probably was supposed to be equals(Object)
+   }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="SuspiciousHashcodeMethodName"
+          language="java"
+          since="1.5"
+          message="The method name and return type are suspiciously close to hashCode()"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.SuspiciousHashcodeMethodNameRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#suspicioushashcodemethodname">
+        <description>
+            The method name and return type are suspiciously close to hashCode(), which may denote an intention
+            to override the hashCode() method.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class Foo {
+    public int hashcode() { // oops, this probably was supposed to be 'hashCode'
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="SuspiciousOctalEscape"
+          language="java"
+          since="1.5"
+          message="Suspicious decimal characters following octal escape in string literal"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.SuspiciousOctalEscapeRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#suspiciousoctalescape">
+        <description>
+            A suspicious octal escape sequence was found inside a String literal.
+            The Java language specification (section 3.10.6) says an octal
+            escape sequence inside a literal String shall consist of a backslash
+            followed by:
+
+            OctalDigit | OctalDigit OctalDigit | ZeroToThree OctalDigit OctalDigit
+
+            Any octal escape sequence followed by non-octal digits can be confusing,
+            e.g. "\038" is interpreted as the octal escape sequence "\03" followed by
+            the literal character "8".
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public void foo() {
+  // interpreted as octal 12, followed by character '8'
+  System.out.println("suspicious: \128");
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="TestClassWithoutTestCases"
+          language="java"
+          since="3.0"
+          message="This class name ends with 'Test' but contains no test cases"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.TestClassWithoutTestCasesRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#testclasswithouttestcases">
+        <description>
+            Test classes end with the suffix Test. Having a non-test class with that name is not a good practice,
+            since most people will assume it is a test case. Test classes have test methods named testXXX.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+//Consider changing the name of the class if it is not a test
+//Consider adding test methods if it is a test
+public class CarTest {
+   public static void main(String[] args) {
+    // do something
+   }
+   // code
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="UnconditionalIfStatement"
+          language="java"
+          since="1.5"
+          message="Do not use 'if' statements that are always true or always false"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#unconditionalifstatement">
+        <description>
+            Do not use "if" statements whose conditionals are always true or always false.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//IfStatement/Expression
+ [count(PrimaryExpression)=1]
+ /PrimaryExpression/PrimaryPrefix/Literal/BooleanLiteral
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo {
+    public void close() {
+        if (true) {        // fixed conditional, not recommended
+            // ...
+        }
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="UnnecessaryBooleanAssertion"
+          language="java"
+          since="3.0"
+          message="assertTrue(true) or similar statements are unnecessary"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          typeResolution="true"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#unnecessarybooleanassertion">
+        <description>
+            A JUnit test assertion with a boolean literal is unnecessary since it always will evaluate to the same thing.
+            Consider using flow control (in case of assertTrue(false) or similar) or simply removing
+            statements like assertTrue(true) and assertFalse(false).  If you just want a test to halt after finding
+            an error, use the fail() method and provide an indication message of why it did.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//ClassOrInterfaceDeclaration[
+    pmd-java:typeIs('junit.framework.TestCase')
+    or .//MarkerAnnotation/Name[
+        pmd-java:typeIs('org.junit.Test')
+        or pmd-java:typeIs('org.junit.jupiter.api.Test')
+        or pmd-java:typeIs('org.junit.jupiter.api.RepeatedTest')
+        or pmd-java:typeIs('org.junit.jupiter.api.TestFactory')
+        or pmd-java:typeIs('org.junit.jupiter.api.TestTemplate')
+        or pmd-java:typeIs('org.junit.jupiter.params.ParameterizedTest')
+        ]
+    ]
+//StatementExpression
+[
+    PrimaryExpression/PrimaryPrefix/Name[@Image='assertTrue' or  @Image='assertFalse']
+    and
+    PrimaryExpression/PrimarySuffix/Arguments/ArgumentList/Expression[
+        PrimaryExpression/PrimaryPrefix/Literal/BooleanLiteral
+        or
+        UnaryExpressionNotPlusMinus[@Image='!']
+            /PrimaryExpression/PrimaryPrefix[Literal/BooleanLiteral or Name[count(../../*)=1]]
+    ]
+]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class SimpleTest extends TestCase {
+    public void testX() {
+        assertTrue(true);       // serves no real purpose
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="UnnecessaryCaseChange"
+          language="java"
+          since="3.3"
+          message="Using equalsIgnoreCase() is cleaner than using toUpperCase/toLowerCase().equals()."
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.UnnecessaryCaseChangeRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#unnecessarycasechange">
+        <description>
+            Using equalsIgnoreCase() is faster than using toUpperCase/toLowerCase().equals()
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+boolean answer1 = buz.toUpperCase().equals("baz");              // should be buz.equalsIgnoreCase("baz")
+
+boolean answer2 = buz.toUpperCase().equalsIgnoreCase("baz");    // another unnecessary toUpperCase()
+]]>
+        </example>
+    </rule>
+
+    <rule name="UnnecessaryConversionTemporary"
+          language="java"
+          since="0.1"
+          message="Avoid unnecessary temporaries when converting primitives to Strings"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.UnnecessaryConversionTemporaryRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#unnecessaryconversiontemporary">
+        <description>
+            Avoid the use temporary objects when converting primitives to Strings. Use the static conversion methods
+            on the wrapper classes instead.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public String convert(int x) {
+    String foo = new Integer(x).toString(); // this wastes an object
+
+    return Integer.toString(x);             // preferred approach
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="UnusedNullCheckInEquals"
+          language="java"
+          since="3.5"
+          message="Invoke equals() on the object you''ve already ensured is not null"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#unusednullcheckinequals">
+        <description>
+            After checking an object reference for null, you should invoke equals() on that object rather than passing it to another object's equals() method.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+(//PrimaryPrefix[ends-with(Name/@Image, '.equals') and Name/@Image != 'Arrays.equals'] | //PrimarySuffix[@Image='equals' and not(../PrimaryPrefix/Literal)])
+ /following-sibling::PrimarySuffix/Arguments/ArgumentList/Expression
+ /PrimaryExpression[not(PrimarySuffix)]/PrimaryPrefix
+ /Name[@Image = ./../../../../../../../../../../Expression/ConditionalAndExpression
+ /EqualityExpression[@Image="!=" and not(./preceding-sibling::*) and
+ ./PrimaryExpression/PrimaryPrefix/Literal/NullLiteral]
+  /PrimaryExpression/PrimaryPrefix/Name/@Image]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Test {
+
+    public String method1() { return "ok";}
+    public String method2() { return null;}
+
+    public void method(String a) {
+        String b;
+        // I don't know it method1() can be "null"
+        // but I know "a" is not null..
+        // I'd better write a.equals(method1())
+
+        if (a!=null && method1().equals(a)) { // will trigger the rule
+            //whatever
+        }
+
+        if (method1().equals(a) && a != null) { // won't trigger the rule
+            //whatever
+        }
+
+        if (a!=null && method1().equals(b)) { // won't trigger the rule
+            //whatever
+        }
+
+        if (a!=null && "LITERAL".equals(a)) { // won't trigger the rule
+            //whatever
+        }
+
+        if (a!=null && !a.equals("go")) { // won't trigger the rule
+            a=method2();
+            if (method1().equals(a)) {
+                //whatever
+            }
+        }
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="UseCorrectExceptionLogging"
+          language="java"
+          since="3.2"
+          message="Use the correct logging statement for logging exceptions"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#usecorrectexceptionlogging">
+        <description>
+            To make sure the full stacktrace is printed out, use the logging statement with two arguments: a String and a Throwable.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//CatchStatement/Block/BlockStatement/Statement/StatementExpression
+    /PrimaryExpression
+        [PrimaryPrefix/Name
+            [starts-with(@Image,
+             concat((ancestor::ClassOrInterfaceDeclaration/ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration/FieldDeclaration
+                [Type//ClassOrInterfaceType[@Image='Log']]
+                /VariableDeclarator/VariableDeclaratorId/@Name)[1], '.'))
+            ]
+        ]
+        [PrimarySuffix/Arguments[@Size= 1]]
+        [PrimarySuffix/Arguments//Name/@Image = ancestor::CatchStatement/FormalParameter/VariableDeclaratorId/@Name]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Main {
+    private static final Log _LOG = LogFactory.getLog( Main.class );
+    void bar() {
+        try {
+        } catch( Exception e ) {
+            _LOG.error( e ); //Wrong!
+        } catch( OtherException oe ) {
+            _LOG.error( oe.getMessage(), oe ); //Correct
+        }
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="UseEqualsToCompareStrings"
+          language="java"
+          since="4.1"
+          message="Use equals() to compare strings instead of ''=='' or ''!=''"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#useequalstocomparestrings">
+        <description>
+            Using '==' or '!=' to compare strings only works if intern version is used on both sides.
+            Use the equals() method instead.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//EqualityExpression
+    [count(PrimaryExpression[pmd-java:typeIs('java.lang.String')]) = 2]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public boolean test(String s) {
+    if (s == "one") return true;        // unreliable
+    if ("two".equals(s)) return true;   // better
+    return false;
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="UselessOperationOnImmutable"

Review comment:
       This rule is enabled in our repo




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] alievmirza commented on a change in pull request #327: review pmd check rules

Posted by GitBox <gi...@apache.org>.
alievmirza commented on a change in pull request #327:
URL: https://github.com/apache/ignite-3/pull/327#discussion_r705398714



##########
File path: check-rules/bestpractices.xml
##########
@@ -0,0 +1,2130 @@
+<?xml version="1.0"?>
+
+<ruleset name="Best Practices"
+         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 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">
+
+    <description>
+        Rules which enforce generally accepted best practices.
+    </description>
+
+    <rule name="AbstractClassWithoutAbstractMethod"
+          language="java"
+          since="3.0"
+          message="This abstract class does not have any abstract methods"
+          class="net.sourceforge.pmd.lang.java.rule.bestpractices.AbstractClassWithoutAbstractMethodRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#abstractclasswithoutabstractmethod">
+        <description>
+            The abstract class does not contain any abstract methods. An abstract class suggests
+            an incomplete implementation, which is to be completed by subclasses implementing the
+            abstract methods. If the class is intended to be used as a base class only (not to be instantiated
+            directly) a protected constructor can be provided prevent direct instantiation.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public abstract class Foo {
+  void int method1() { ... }
+  void int method2() { ... }
+  // consider using abstract methods or removing
+  // the abstract modifier and adding protected constructors
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AccessorClassGeneration"
+          language="java"
+          since="1.04"
+          maximumLanguageVersion="10"
+          message="Avoid instantiation through private constructors from outside of the constructor's class."
+          class="net.sourceforge.pmd.lang.java.rule.bestpractices.AccessorClassGenerationRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#accessorclassgeneration">
+        <description>
+            Instantiation by way of private constructors from outside of the constructor's class often causes the
+            generation of an accessor. A factory method, or non-privatization of the constructor can eliminate this
+            situation. The generated class file is actually an interface.  It gives the accessing class the ability
+            to invoke a new hidden package scope constructor that takes the interface as a supplementary parameter.
+            This turns a private constructor effectively into one with package scope, and is challenging to discern.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class Outer {
+ void method(){
+  Inner ic = new Inner();//Causes generation of accessor class
+ }
+ public class Inner {
+  private Inner(){}
+ }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AccessorMethodGeneration"
+          language="java"
+          since="5.5.4"
+          maximumLanguageVersion="10"
+          message="Avoid autogenerated methods to access private fields and methods of inner / outer classes"
+          class="net.sourceforge.pmd.lang.java.rule.bestpractices.AccessorMethodGenerationRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#accessormethodgeneration">
+        <description>
+            When accessing private fields / methods from another class, the Java compiler will generate accessor methods
+            with package-private visibility. This adds overhead, and to the dex method count on Android. This situation can
+            be avoided by changing the visibility of the field / method from private to package-private.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class OuterClass {
+    private int counter;
+    /* package */ int id;
+    public class InnerClass {
+        InnerClass() {
+            OuterClass.this.counter++; // wrong accessor method will be generated
+        }
+        public int getOuterClassId() {
+            return OuterClass.this.id; // id is package-private, no accessor method needed
+        }
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="ArrayIsStoredDirectly"
+          language="java"
+          since="2.2"
+          message="The user-supplied array ''{0}'' is stored directly."
+          class="net.sourceforge.pmd.lang.java.rule.bestpractices.ArrayIsStoredDirectlyRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#arrayisstoreddirectly">
+        <description>
+            Constructors and methods receiving arrays should clone objects and store the copy.
+            This prevents future changes from the user from affecting the original array.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class Foo {
+    private String [] x;
+        public void foo (String [] param) {
+        // Don't do this, make a copy of the array at least
+        this.x=param;
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidMessageDigestField"
+          language="java"
+          since="6.18.0"
+          message="You shouldn't declare field of MessageDigest type, because unsynchronized access could cause problems"
+          typeResolution="true"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#avoidmessagedigestfield">
+        <description>
+            Declaring a MessageDigest instance as a field make this instance directly available to multiple threads.
+            Such sharing of MessageDigest instances should be avoided if possible since it leads to wrong results
+            if the access is not synchronized correctly.
+            Just create a new instance and use it locally, where you need it.
+            Creating a new instance is easier than synchronizing access to a shared instance.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//FieldDeclaration[pmd-java:typeIs('java.security.MessageDigest')]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+import java.security.MessageDigest;
+public class AvoidMessageDigestFieldExample {
+    private final MessageDigest sharedMd;
+    public AvoidMessageDigestFieldExample() throws Exception {
+        sharedMd = MessageDigest.getInstance("SHA-256");
+    }
+    public byte[] calculateHashShared(byte[] data) {
+        // sharing a MessageDigest like this without synchronizing access
+        // might lead to wrong results
+        sharedMd.reset();
+        sharedMd.update(data);
+        return sharedMd.digest();
+    }
+    // better
+    public byte[] calculateHash(byte[] data) throws Exception {
+        MessageDigest md = MessageDigest.getInstance("SHA-256");
+        md.update(data);
+        return md.digest();
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidPrintStackTrace"
+          language="java"
+          since="3.2"
+          message="Avoid printStackTrace(); use a logger call instead."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#avoidprintstacktrace">
+        <description>
+            Avoid printStackTrace(); use a logger call instead.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//PrimaryExpression[
+   ( PrimaryPrefix[Name[contains(@Image,'printStackTrace')]]
+   | PrimarySuffix[@Image='printStackTrace']
+   )/following-sibling::*[1][self::PrimarySuffix/Arguments[@Size=0]]
+]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+class Foo {
+    void bar() {
+        try {
+            // do something
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidReassigningCatchVariables"
+          language="java"
+          since="6.27.0"
+          message="Avoid reassigning caught exception ''{0}''"
+          class="net.sourceforge.pmd.lang.java.rule.bestpractices.AvoidReassigningCatchVariablesRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#avoidreassigningcatchvariables">
+        <description>
+            Reassigning exception variables caught in a catch statement should be avoided because of:
+
+            1) If it is needed, multi catch can be easily added and code will still compile.
+
+            2) Following the principle of least surprise we want to make sure that a variable caught in a catch statement
+            is always the one thrown in a try block.
+        </description>
+        <priority>3</priority>
+        <example><![CDATA[
+public class Foo {
+    public void foo() {
+        try {
+            // do something
+        } catch (Exception e) {
+            e = new NullPointerException(); // not recommended
+        }
+        try {
+            // do something
+        } catch (MyException | ServerException e) {
+            e = new RuntimeException(); // won't compile
+        }
+    }
+}
+        ]]></example>
+    </rule>
+
+    <rule name="AvoidReassigningLoopVariables"
+          language="java"
+          since="6.11.0"
+          message="Avoid reassigning the loop control variable ''{0}''"
+          class="net.sourceforge.pmd.lang.java.rule.bestpractices.AvoidReassigningLoopVariablesRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#avoidreassigningloopvariables">
+        <description>
+            Reassigning loop variables can lead to hard-to-find bugs. Prevent or limit how these variables can be changed.
+
+            In foreach-loops, configured by the `foreachReassign` property:
+            - `deny`: Report any reassignment of the loop variable in the loop body. _This is the default._
+            - `allow`: Don't check the loop variable.
+            - `firstOnly`: Report any reassignments of the loop variable, except as the first statement in the loop body.
+            _This is useful if some kind of normalization or clean-up of the value before using is permitted, but any other change of the variable is not._
+
+            In for-loops, configured by the `forReassign` property:
+            - `deny`: Report any reassignment of the control variable in the loop body. _This is the default._
+            - `allow`: Don't check the control variable.
+            - `skip`: Report any reassignments of the control variable, except conditional increments/decrements (`++`, `--`, `+=`, `-=`).
+            _This prevents accidental reassignments or unconditional increments of the control variable._
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class Foo {
+  private void foo() {
+    for (String s : listOfStrings()) {
+      s = s.trim(); // OK, when foreachReassign is "firstOnly" or "allow"
+      doSomethingWith(s);
+      s = s.toUpper(); // OK, when foreachReassign is "allow"
+      doSomethingElseWith(s);
+    }
+    for (int i=0; i < 10; i++) {
+      if (check(i)) {
+        i++; // OK, when forReassign is "skip" or "allow"
+      }
+      i = 5;  // OK, when forReassign is "allow"
+      doSomethingWith(i);
+    }
+  }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidReassigningParameters"
+          language="java"
+          since="1.0"
+          message="Avoid reassigning parameters such as ''{0}''"
+          class="net.sourceforge.pmd.lang.java.rule.bestpractices.AvoidReassigningParametersRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#avoidreassigningparameters">
+        <description>
+            Reassigning values to incoming parameters of a method or constructor is not recommended, as this can
+            make the code more difficult to understand. The code is often read with the assumption that parameter values
+            don't change and an assignment violates therefore the principle of least astonishment. This is especially a
+            problem if the parameter is documented e.g. in the method's javadoc and the new content differs from the original
+            documented content.
+
+            Use temporary local variables instead. This allows you to assign a new name, which makes the code better
+            understandable.
+
+            Note that this rule considers both methods and constructors. If there are multiple assignments for a formal
+            parameter, then only the first assignment is reported.
+        </description>
+        <priority>2</priority>
+        <example>
+            <![CDATA[
+public class Hello {
+  private void greet(String name) {
+    name = name.trim();
+    System.out.println("Hello " + name);
+    // preferred
+    String trimmedName = name.trim();
+    System.out.println("Hello " + trimmedName);
+  }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidStringBufferField"
+          language="java"
+          since="4.2"
+          message="StringBuffers can grow quite a lot, and so may become a source of memory leak (if the owning class has a long life time)."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#avoidstringbufferfield">
+        <description>
+            StringBuffers/StringBuilders can grow considerably, and so may become a source of memory leaks
+            if held within objects with long lifetimes.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//FieldDeclaration/Type/ReferenceType/ClassOrInterfaceType[@Image = 'StringBuffer' or @Image = 'StringBuilder']
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo {
+    private StringBuffer buffer;    // potential memory leak as an instance variable;
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidUsingHardCodedIP"
+          language="java"
+          since="4.1"
+          message="Do not hard code the IP address ${variableName}"
+          class="net.sourceforge.pmd.lang.java.rule.bestpractices.AvoidUsingHardCodedIPRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#avoidusinghardcodedip">
+        <description>
+            Application with hard-coded IP addresses can become impossible to deploy in some cases.
+            Externalizing IP adresses is preferable.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class Foo {
+    private String ip = "127.0.0.1";     // not recommended
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="CheckResultSet"
+          language="java"
+          since="4.1"
+          class="net.sourceforge.pmd.lang.java.rule.bestpractices.CheckResultSetRule"
+          message="Always check the return of one of the navigation method (next,previous,first,last) of a ResultSet."
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#checkresultset">
+        <description>
+            Always check the return values of navigation methods (next, previous, first, last) of a ResultSet.
+            If the value return is 'false', it should be handled properly.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+Statement stat = conn.createStatement();
+ResultSet rst = stat.executeQuery("SELECT name FROM person");
+rst.next();     // what if it returns false? bad form
+String firstName = rst.getString(1);
+Statement stat = conn.createStatement();
+ResultSet rst = stat.executeQuery("SELECT name FROM person");
+if (rst.next()) {    // result is properly examined and used
+    String firstName = rst.getString(1);
+    } else  {
+        // handle missing data
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="ConstantsInInterface"
+          language="java"
+          since="5.5"
+          message="Avoid constants in interfaces. Interfaces define types, constants are implementation details better placed in classes or enums. See Effective Java, item 19."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#constantsininterface">
+        <description>
+            Avoid constants in interfaces. Interfaces should define types, constants are implementation details
+            better placed in classes or enums. See Effective Java, item 19.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="ignoreIfHasMethods" type="Boolean" description="Whether to ignore constants in interfaces if the interface defines any methods" value="true"/>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//ClassOrInterfaceDeclaration[@Interface= true()][$ignoreIfHasMethods= false() or not(.//MethodDeclaration)]//FieldDeclaration
+ ]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public interface ConstantInterface {
+    public static final int CONST1 = 1; // violation, no fields allowed in interface!
+    static final int CONST2 = 1;        // violation, no fields allowed in interface!
+    final int CONST3 = 1;               // violation, no fields allowed in interface!
+    int CONST4 = 1;                     // violation, no fields allowed in interface!
+}
+// with ignoreIfHasMethods = false
+public interface AnotherConstantInterface {
+    public static final int CONST1 = 1; // violation, no fields allowed in interface!
+    int anyMethod();
+}
+// with ignoreIfHasMethods = true
+public interface YetAnotherConstantInterface {
+    public static final int CONST1 = 1; // no violation
+    int anyMethod();
+}
+ ]]>
+        </example>
+    </rule>
+
+    <rule name="DefaultLabelNotLastInSwitchStmt"
+          language="java"
+          since="1.5"
+          message="The default label should be the last label in a switch statement"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#defaultlabelnotlastinswitchstmt">
+        <description>
+            By convention, the default label should be the last label in a switch statement.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//SwitchStatement
+ [not(SwitchLabel[position() = last()][@Default= true()])]
+ [SwitchLabel[@Default= true()]]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo {
+  void bar(int a) {
+   switch (a) {
+    case 1:  // do something
+       break;
+    default:  // the default case should be last, by convention
+       break;
+    case 2:
+       break;
+   }
+  }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="DoubleBraceInitialization"
+          language="java"
+          since="6.16.0"
+          message="Double-brace initialization should be avoided"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#doublebraceinitialization">
+        <description>
+            Double brace initialisation is a pattern to initialise eg collections concisely. But it implicitly
+            generates a new .class file, and the object holds a strong reference to the enclosing object. For those
+            reasons, it is preferable to initialize the object normally, even though it's verbose.
+
+            This rule counts any anonymous class which only has a single initializer as an instance of double-brace
+            initialization. There is currently no way to find out whether a method called in the initializer is not
+            accessible from outside the anonymous class, and those legit cases should be suppressed for the time being.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//AllocationExpression/ClassOrInterfaceBody[count(*)=1]/*/Initializer[@Static=false()]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example><![CDATA[
+// this is double-brace initialization
+return new ArrayList<String>(){{
+    add("a");
+    add("b");
+    add("c");
+}};
+// the better way is to not create an anonymous class:
+List<String> a = new ArrayList<>();
+a.add("a");
+a.add("b");
+a.add("c");
+return a;
+]]>
+        </example>
+    </rule>
+
+
+    <rule name="ForLoopCanBeForeach"
+          language="java"
+          since="6.0.0"
+          message="This 'for' loop can be replaced by a 'foreach' loop"
+          typeResolution="true"
+          minimumLanguageVersion="1.5"
+          class="net.sourceforge.pmd.lang.java.rule.bestpractices.ForLoopCanBeForeachRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#forloopcanbeforeach">
+        <description>
+            Reports loops that can be safely replaced with the foreach syntax. The rule considers loops over
+            lists, arrays and iterators. A loop is safe to replace if it only uses the index variable to
+            access an element of the list or array, only has one update statement, and loops through *every*
+            element of the list or array left to right.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class MyClass {
+  void loop(List<String> l) {
+    for (int i = 0; i < l.size(); i++) { // pre Java 1.5
+      System.out.println(l.get(i));
+    }
+    for (String s : l) {        // post Java 1.5
+      System.out.println(s);
+    }
+  }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="ForLoopVariableCount"
+          language="java"
+          since="6.11.0"
+          message="Too many control variables in the 'for' statement"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#forloopvariablecount">
+        <description>
+            Having a lot of control variables in a 'for' loop makes it harder to see what range of values
+            the loop iterates over. By default this rule allows a regular 'for' loop with only one variable.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="maximumVariables" type="Integer"
+                      description="A regular for statement will have 1 control variable" min="0" max="100" value="1"/>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>//ForInit/LocalVariableDeclaration[count(VariableDeclarator) > $maximumVariables]</value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+// this will be reported with the default setting of at most one control variable in a for loop
+for (int i = 0, j = 0; i < 10; i++, j += 2) {
+   foo();
+]]>
+        </example>
+    </rule>
+
+    <rule name="GuardLogStatement"
+          language="java"
+          since="5.1.0"
+          message="Logger calls should be surrounded by log level guards."
+          class="net.sourceforge.pmd.lang.java.rule.bestpractices.GuardLogStatementRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#guardlogstatement">
+        <description>
+            Whenever using a log level, one should check if the loglevel is actually enabled, or
+            otherwise skip the associate String creation and manipulation.
+
+            An alternative to checking the log level are substituting parameters, formatters or lazy logging
+            with lambdas. The available alternatives depend on the actual logging framework.
+        </description>
+        <priority>2</priority>
+        <example>
+            <![CDATA[
+// Add this for performance
+if (log.isDebugEnabled()) {
+    log.debug("log something" + param1 + " and " + param2 + "concat strings");
+}
+// Avoid the guarding if statement with substituting parameters
+log.debug("log something {} and {}", param1, param2);
+// Avoid the guarding if statement with formatters
+log.debug("log something %s and %s", param1, param2);
+// Avoid the guarding if statement with lazy logging and lambdas
+log.debug("log something expensive: {}", () -> calculateExpensiveLoggingText());
+]]>
+        </example>
+    </rule>
+
+    <rule name="JUnit4SuitesShouldUseSuiteAnnotation"
+          language="java"
+          since="4.0"
+          message="JUnit 4 indicates test suites via annotations, not the suite method."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          typeResolution="true"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#junit4suitesshouldusesuiteannotation">
+        <description>
+            In JUnit 3, test suites are indicated by the suite() method. In JUnit 4, suites are indicated
+            through the @RunWith(Suite.class) annotation.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//ClassOrInterfaceBodyDeclaration
+[MethodDeclaration[@Name='suite']/ResultType/Type/ReferenceType/ClassOrInterfaceType[pmd-java:typeIs('junit.framework.Test')]]
+[not(MethodDeclaration/Block/BlockStatement/Statement/ReturnStatement//ClassOrInterfaceType[pmd-java:typeIs('junit.framework.JUnit4TestAdapter')])]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class BadExample extends TestCase{
+    public static Test suite(){
+        return new Suite();
+    }
+}
+@RunWith(Suite.class)
+@SuiteClasses( { TestOne.class, TestTwo.class })
+public class GoodTest {
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="JUnit4TestShouldUseAfterAnnotation"
+          language="java"
+          since="4.0"
+          message="JUnit 4 tests that clean up tests should use the @After annotation, JUnit5 tests should use @AfterEach or @AfterAll"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          typeResolution="true"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#junit4testshoulduseafterannotation">
+        <description>
+            In JUnit 3, the tearDown method was used to clean up all data entities required in running tests.
+            JUnit 4 skips the tearDown method and executes all methods annotated with @After after running each test.
+            JUnit 5 introduced @AfterEach and @AfterAll annotations to execute methods after each test or after all tests in the class, respectively.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//ClassOrInterfaceBodyDeclaration
+    [MethodDeclaration[@Name='tearDown']]
+    [not(Annotation/*/Name[
+           pmd-java:typeIs('org.junit.After')
+        or pmd-java:typeIs('org.junit.jupiter.api.AfterEach')
+        or pmd-java:typeIs('org.junit.jupiter.api.AfterAll')
+        or pmd-java:typeIs('org.testng.annotations.AfterMethod')])]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class MyTest {
+    public void tearDown() {
+        bad();
+    }
+}
+public class MyTest2 {
+    @After public void tearDown() {
+        good();
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="JUnit4TestShouldUseBeforeAnnotation"
+          language="java"
+          since="4.0"
+          message="JUnit 4 tests that set up tests should use the @Before annotation, JUnit5 tests should use @BeforeEach or @BeforeAll"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          typeResolution="true"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#junit4testshouldusebeforeannotation">
+        <description>
+            In JUnit 3, the setUp method was used to set up all data entities required in running tests.
+            JUnit 4 skips the setUp method and executes all methods annotated with @Before before all tests.
+            JUnit 5 introduced @BeforeEach and @BeforeAll annotations to execute methods before each test or before all tests in the class, respectively.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//ClassOrInterfaceBodyDeclaration
+    [MethodDeclaration[@Name='setUp']]
+    [not(Annotation/*/Name[
+           pmd-java:typeIs('org.junit.Before')
+        or pmd-java:typeIs('org.junit.jupiter.api.BeforeEach')
+        or pmd-java:typeIs('org.junit.jupiter.api.BeforeAll')
+        or pmd-java:typeIs('org.testng.annotations.BeforeMethod')])]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class MyTest {
+    public void setUp() {
+        bad();
+    }
+}
+public class MyTest2 {
+    @Before public void setUp() {
+        good();
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="JUnit4TestShouldUseTestAnnotation"
+          language="java"
+          since="4.0"
+          message="JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          typeResolution="true"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#junit4testshouldusetestannotation">
+        <description>
+            In JUnit 3, the framework executed all methods which started with the word test as a unit test.
+            In JUnit 4, only methods annotated with the @Test annotation are executed.
+            In JUnit 5, one of the following annotations should be used for tests: @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//ClassOrInterfaceDeclaration[
+       matches(@SimpleName, $testClassPattern)
+        or ExtendsList/ClassOrInterfaceType[pmd-java:typeIs('junit.framework.TestCase')]]
+    /ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration[MethodDeclaration[@Public=true() and starts-with(@Name, 'test')]]
+    [not(Annotation//Name[
+        pmd-java:typeIs('org.junit.Test')
+        or pmd-java:typeIs('org.junit.jupiter.api.Test') or pmd-java:typeIs('org.junit.jupiter.api.RepeatedTest')
+        or pmd-java:typeIs('org.junit.jupiter.api.TestFactory') or pmd-java:typeIs('org.junit.jupiter.api.TestTemplate')
+        or pmd-java:typeIs('org.junit.jupiter.params.ParameterizedTest')
+    ])]
+]]>
+                </value>
+            </property>
+            <property name="testClassPattern" type="Regex" description="The regex pattern used to identify test classes" value="Test" />
+            <property name="version" value="2.0"/>
+        </properties>
+        <example>
+            <![CDATA[
+public class MyTest {
+    public void testBad() {
+        doSomething();
+    }
+    @Test
+    public void testGood() {
+        doSomething();
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="JUnit5TestShouldBePackagePrivate"
+          language="java"
+          since="6.35.0"
+          message="JUnit 5 tests should be package-private."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          typeResolution="true"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#junit5testshouldbepackageprivate">
+        <description><![CDATA[
+Reports JUnit 5 test classes and methods that are not package-private.
+Contrary to JUnit 4 tests, which required public visibility to be run by the engine,
+JUnit 5 tests can also be run if they're package-private. Marking them as such
+is a good practice to limit their visibility.
+Test methods are identified as those which use `@Test`, `@RepeatedTest`,
+`@TestFactory`, `@TestTemplate` or `@ParameterizedTest`.
+            ]]></description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//ClassOrInterfaceDeclaration[
+    (: a Junit 5 test class, ie, it has methods with the annotation :)
+    @Interface=false() and
+    ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration
+        [Annotation//Name[
+            pmd-java:typeIs('org.junit.jupiter.api.Test') or pmd-java:typeIs('org.junit.jupiter.api.RepeatedTest')
+            or pmd-java:typeIs('org.junit.jupiter.api.TestFactory') or pmd-java:typeIs('org.junit.jupiter.api.TestTemplate')
+            or pmd-java:typeIs('org.junit.jupiter.params.ParameterizedTest')
+        ]]
+        [MethodDeclaration]
+]/(
+    self::*[@Abstract=false() and (@Public=true() or @Protected=true())]
+|   ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration
+        [Annotation//Name[
+            pmd-java:typeIs('org.junit.jupiter.api.Test') or pmd-java:typeIs('org.junit.jupiter.api.RepeatedTest')
+            or pmd-java:typeIs('org.junit.jupiter.api.TestFactory') or pmd-java:typeIs('org.junit.jupiter.api.TestTemplate')
+            or pmd-java:typeIs('org.junit.jupiter.params.ParameterizedTest')
+        ]]
+        /MethodDeclaration[@Public=true() or @Protected=true()]
+)
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+class MyTest { // not public, that's fine
+    @Test
+    public void testBad() { } // should not have a public modifier
+    @Test
+    protected void testAlsoBad() { } // should not have a protected modifier
+    @Test
+    private void testNoRun() { } // should not have a private modifier
+    @Test
+    void testGood() { } // package private as expected
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="JUnitAssertionsShouldIncludeMessage"
+          language="java"
+          since="1.04"
+          message="JUnit assertions should include a message"
+          class="net.sourceforge.pmd.lang.java.rule.bestpractices.JUnitAssertionsShouldIncludeMessageRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#junitassertionsshouldincludemessage">
+        <description>
+            JUnit assertions should include an informative message - i.e., use the three-argument version of
+            assertEquals(), not the two-argument version.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class Foo extends TestCase {
+    public void testSomething() {
+        assertEquals("foo", "bar");
+        // Use the form:
+        // assertEquals("Foo does not equals bar", "foo", "bar");
+        // instead
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="JUnitTestContainsTooManyAsserts"
+          language="java"
+          since="5.0"
+          message="Unit tests should not contain more than ${maximumAsserts} assert(s)."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          typeResolution="true"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#junittestcontainstoomanyasserts">
+        <description>
+            Unit tests should not contain too many asserts. Many asserts are indicative of a complex test, for which
+            it is harder to verify correctness.  Consider breaking the test scenario into multiple, shorter test scenarios.
+            Customize the maximum number of assertions used by this Rule to suit your needs.
+
+            This rule checks for JUnit4, JUnit5 and TestNG Tests, as well as methods starting with "test".
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="maximumAsserts" type="Integer" min="1" max="1000" description="Maximum number of Asserts in a test method" value="1"/>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//MethodDeclaration[@Name[matches(.,'^test')] or ../Annotation/MarkerAnnotation/Name[
+           pmd-java:typeIs('org.junit.Test')
+        or pmd-java:typeIs('org.junit.jupiter.api.Test')
+        or pmd-java:typeIs('org.junit.jupiter.api.RepeatedTest')
+        or pmd-java:typeIs('org.junit.jupiter.api.TestFactory')
+        or pmd-java:typeIs('org.junit.jupiter.api.TestTemplate')
+        or pmd-java:typeIs('org.junit.jupiter.params.ParameterizedTest')
+        or pmd-java:typeIs('org.testng.annotations.Test')
+    ]]
+    [count(.//PrimaryPrefix/Name[@Image[matches(.,'^assert')]]) > $maximumAsserts]
+]]>
+                </value>
+            </property>
+            <property name="version" value="2.0"/>
+        </properties>
+        <example>
+            <![CDATA[
+public class MyTestCase extends TestCase {
+    // Ok
+    public void testMyCaseWithOneAssert() {
+        boolean myVar = false;
+        assertFalse("should be false", myVar);
+    }
+    // Bad, too many asserts (assuming max=1)
+    public void testMyCaseWithMoreAsserts() {
+        boolean myVar = false;
+        assertFalse("myVar should be false", myVar);
+        assertEquals("should equals false", false, myVar);
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="JUnitTestsShouldIncludeAssert"
+          language="java"
+          since="2.0"
+          message="JUnit tests should include assert() or fail()"
+          class="net.sourceforge.pmd.lang.java.rule.bestpractices.JUnitTestsShouldIncludeAssertRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#junittestsshouldincludeassert">
+        <description>
+            JUnit tests should include at least one assertion.  This makes the tests more robust, and using assert
+            with messages provide the developer a clearer idea of what the test does.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class Foo extends TestCase {
+   public void testSomething() {
+      Bar b = findBar();
+   // This is better than having a NullPointerException
+   // assertNotNull("bar not found", b);
+   b.work();
+   }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="JUnitUseExpected"
+          language="java"
+          since="4.0"
+          message="In JUnit4, use the @Test(expected) annotation to denote tests that should throw exceptions"
+          class="net.sourceforge.pmd.lang.java.rule.bestpractices.JUnitUseExpectedRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#junituseexpected">
+        <description>
+            In JUnit4, use the @Test(expected) annotation to denote tests that should throw exceptions.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class MyTest {
+    @Test
+    public void testBad() {
+        try {
+            doSomething();
+            fail("should have thrown an exception");
+        } catch (Exception e) {
+        }
+    }
+    @Test(expected=Exception.class)
+    public void testGood() {
+        doSomething();
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="LiteralsFirstInComparisons"
+          language="java"
+          since="6.24.0"
+          message="Position literals first in String comparisons"
+          class="net.sourceforge.pmd.lang.java.rule.bestpractices.LiteralsFirstInComparisonsRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#literalsfirstincomparisons">
+        <description>
+            Position literals first in all String comparisons, if the second argument is null then NullPointerExceptions
+            can be avoided, they will just return false. Note that switching literal positions for compareTo and
+            compareToIgnoreCase may change the result, see examples.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+class Foo {
+    boolean bar(String x) {
+        return x.equals("2"); // should be "2".equals(x)
+    }
+    boolean bar(String x) {
+        return x.equalsIgnoreCase("2"); // should be "2".equalsIgnoreCase(x)
+    }
+    boolean bar(String x) {
+        return (x.compareTo("bar") > 0); // should be: "bar".compareTo(x) < 0
+    }
+    boolean bar(String x) {
+        return (x.compareToIgnoreCase("bar") > 0); // should be: "bar".compareToIgnoreCase(x) < 0
+    }
+    boolean bar(String x) {
+        return x.contentEquals("bar"); // should be "bar".contentEquals(x)
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="LooseCoupling"
+          language="java"
+          since="0.7"
+          message="Avoid using implementation types like ''{0}''; use the interface instead"
+          class="net.sourceforge.pmd.lang.java.rule.bestpractices.LooseCouplingRule"
+          typeResolution="true"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#loosecoupling">
+        <description>
+            The use of implementation types (i.e., HashSet) as object references limits your ability to use alternate
+            implementations in the future as requirements change. Whenever available, referencing objects
+            by their interface types (i.e, Set) provides much more flexibility.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+import java.util.ArrayList;
+import java.util.HashSet;
+public class Bar {
+    // sub-optimal approach
+    private ArrayList<SomeType> list = new ArrayList<>();
+    public HashSet<SomeType> getFoo() {
+        return new HashSet<SomeType>();
+    }
+    // preferred approach
+    private List<SomeType> list = new ArrayList<>();
+    public Set<SomeType> getFoo() {
+        return new HashSet<SomeType>();
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="MethodReturnsInternalArray"
+          language="java"
+          since="2.2"
+          message="Returning ''{0}'' may expose an internal array."
+          class="net.sourceforge.pmd.lang.java.rule.bestpractices.MethodReturnsInternalArrayRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#methodreturnsinternalarray">
+        <description>
+            Exposing internal arrays to the caller violates object encapsulation since elements can be
+            removed or replaced outside of the object that owns it. It is safer to return a copy of the array.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class SecureSystem {
+    UserData [] ud;
+    public UserData [] getUserData() {
+        // Don't return directly the internal array, return a copy
+        return ud;
+    }
+}
+]]>
+        </example>
+    </rule>
+
+
+    <rule name="MissingOverride"
+          language="java"
+          since="6.2.0"
+          minimumLanguageVersion="1.5"
+          message="The method ''{0}'' is missing an @Override annotation."
+          typeResolution="true"
+          class="net.sourceforge.pmd.lang.java.rule.bestpractices.MissingOverrideRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#missingoverride">
+        <description>
+            Annotating overridden methods with @Override ensures at compile time that
+            the method really overrides one, which helps refactoring and clarifies intent.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+            public class Foo implements Runnable {
+                // This method is overridden, and should have an @Override annotation
+                public void run() {
+                }
+            }
+            ]]>
+        </example>
+    </rule>
+
+    <rule name="OneDeclarationPerLine"
+          language="java"
+          since="5.0"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          message="Use one line for each declaration, it enhances code readability."
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#onedeclarationperline">
+        <description>
+            Java allows the use of several variables declaration of the same type on one line. However, it
+            can lead to quite messy code. This rule looks for several declarations on the same line.
+        </description>
+        <priority>4</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//LocalVariableDeclaration
+   [not(parent::ForInit)]
+   [count(VariableDeclarator) > 1]
+   [$strictMode or count(distinct-values(VariableDeclarator/@BeginLine)) != count(VariableDeclarator)]
+|
+//FieldDeclaration
+   [count(VariableDeclarator) > 1]
+   [$strictMode or count(distinct-values(VariableDeclarator/@BeginLine)) != count(VariableDeclarator)]
+]]>
+                </value>
+            </property>
+            <property name="version" value="2.0"/>
+            <property name="strictMode" type="Boolean" value="false"
+                      description="If true, mark combined declaration even if the declarations are on separate lines."/>
+        </properties>
+        <example>
+            <![CDATA[
+String name;            // separate declarations
+String lastname;
+String name, lastname;  // combined declaration, a violation
+String name,
+       lastname;        // combined declaration on multiple lines, no violation by default.
+                        // Set property strictMode to true to mark this as violation.
+]]>
+        </example>
+    </rule>
+
+    <rule name="PositionLiteralsFirstInCaseInsensitiveComparisons"
+          language="java"
+          since="5.1"
+          message="Position literals first in String comparisons for EqualsIgnoreCase"
+          class="net.sourceforge.pmd.lang.java.rule.bestpractices.PositionLiteralsFirstInCaseInsensitiveComparisonsRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#positionliteralsfirstincaseinsensitivecomparisons"
+          deprecated="true">
+        <description>
+            Position literals first in comparisons, if the second argument is null then NullPointerExceptions
+            can be avoided, they will just return false.
+
+            This rule is replaced by the more general rule {% rule "LiteralsFirstInComparisons" %}.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+class Foo {
+  boolean bar(String x) {
+    return x.equalsIgnoreCase("2"); // should be "2".equalsIgnoreCase(x)
+  }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="PositionLiteralsFirstInComparisons"
+          language="java"
+          since="3.3"
+          message="Position literals first in String comparisons"
+          class="net.sourceforge.pmd.lang.java.rule.bestpractices.PositionLiteralsFirstInComparisonsRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#positionliteralsfirstincomparisons"
+          deprecated="true">
+        <description>
+            Position literals first in comparisons, if the second argument is null then NullPointerExceptions
+            can be avoided, they will just return false.
+
+            This rule is replaced by the more general rule {% rule "LiteralsFirstInComparisons" %}.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+class Foo {
+  boolean bar(String x) {
+    return x.equals("2"); // should be "2".equals(x)
+  }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="PreserveStackTrace"
+          language="java"
+          since="3.7"
+          message="New exception is thrown in catch block, original stack trace may be lost"
+          class="net.sourceforge.pmd.lang.java.rule.bestpractices.PreserveStackTraceRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#preservestacktrace">
+        <description>
+            Throwing a new exception from a catch block without passing the original exception into the
+            new exception will cause the original stack trace to be lost making it difficult to debug
+            effectively.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class Foo {
+    void good() {
+        try{
+            Integer.parseInt("a");
+        } catch (Exception e) {
+            throw new Exception(e); // first possibility to create exception chain
+        }
+        try {
+            Integer.parseInt("a");
+        } catch (Exception e) {
+            throw (IllegalStateException)new IllegalStateException().initCause(e); // second possibility to create exception chain.
+        }
+    }
+    void bad() {
+        try{
+            Integer.parseInt("a");
+        } catch (Exception e) {
+            throw new Exception(e.getMessage());
+        }
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="PrimitiveWrapperInstantiation"
+          language="java"
+          since="6.37.0"
+          message="Do not use `new {0}(...)`, prefer `{0}.valueOf(...)`"
+          class="net.sourceforge.pmd.lang.java.rule.bestpractices.PrimitiveWrapperInstantiationRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#primitivewrapperinstantiation">
+        <description>
+            Reports usages of primitive wrapper constructors. They are deprecated
+            since Java 9 and should not be used. Even before Java 9, they can
+            be replaced with usage of the corresponding static `valueOf` factory method
+            (which may be automatically inserted by the compiler since Java 1.5).
+            This has the advantage that it may reuse common instances instead of creating
+            a new instance each time.
+
+            Note that for `Boolean`, the named constants `Boolean.TRUE` and `Boolean.FALSE`
+            are preferred instead of `Boolean.valueOf`.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+            public class Foo {
+                private Integer ZERO = new Integer(0);      // violation
+                private Integer ZERO1 = Integer.valueOf(0); // better
+                private Integer ZERO1 = 0;                  // even better
+            }
+            ]]>
+        </example>
+    </rule>
+
+
+    <rule name="ReplaceEnumerationWithIterator"
+          language="java"
+          since="3.4"
+          message="Consider replacing this Enumeration with the newer java.util.Iterator"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#replaceenumerationwithiterator">
+        <description>
+            Consider replacing Enumeration usages with the newer java.util.Iterator
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//ImplementsList/ClassOrInterfaceType[@Image='Enumeration']
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo implements Enumeration {
+    private int x = 42;
+    public boolean hasMoreElements() {
+        return true;
+    }
+    public Object nextElement() {
+        return String.valueOf(i++);
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="ReplaceHashtableWithMap"
+          language="java"
+          since="3.4"
+          message="Consider replacing this Hashtable with the newer java.util.Map"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#replacehashtablewithmap">
+        <description>
+            Consider replacing Hashtable usage with the newer java.util.Map if thread safety is not required.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>//Type/ReferenceType/ClassOrInterfaceType[@Image='Hashtable']</value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo {
+    void bar() {
+        Hashtable h = new Hashtable();
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="ReplaceVectorWithList"
+          language="java"
+          since="3.4"
+          message="Consider replacing this Vector with the newer java.util.List"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#replacevectorwithlist">
+        <description>
+            Consider replacing Vector usages with the newer java.util.ArrayList if expensive thread-safe operations are not required.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>//Type/ReferenceType/ClassOrInterfaceType[@Image='Vector']</value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo {
+    void bar() {
+        Vector v = new Vector();
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="SimplifiableTestAssertion"
+          language="java"
+          since="6.37.0"
+          message="Assertion may be simplified using {0}"
+          typeResolution="true"
+          class="net.sourceforge.pmd.lang.java.rule.bestpractices.SimplifiableTestAssertionRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#simplifiabletestassertion">
+        <description>
+            Reports test assertions that may be simplified using a more specific
+            assertion method. This enables better error messages, and makes the
+            assertions more readable.
+
+            The rule only applies within test classes for the moment. It replaces
+            the deprecated rules {% rule UseAssertEqualsInsteadOfAssertTrue %},
+            {% rule UseAssertNullInsteadOfAssertTrue %}, {% rule UseAssertSameInsteadOfAssertTrue %},
+            {% rule UseAssertTrueInsteadOfAssertEquals %}, and {% rule java/design/SimplifyBooleanAssertion %}.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+import org.junit.Test;
+import static org.junit.Assert.*;
+class SomeTestClass {
+    Object a,b;
+    @Test
+    void testMethod() {
+        assertTrue(a.equals(b)); // could be assertEquals(a, b);
+        assertTrue(!a.equals(b)); // could be assertNotEquals(a, b);
+        assertTrue(!something); // could be assertFalse(something);
+        assertFalse(!something); // could be assertTrue(something);
+        assertTrue(a == b); // could be assertSame(a, b);
+        assertTrue(a != b); // could be assertNotSame(a, b);
+        assertTrue(a == null); // could be assertNull(a);
+        assertTrue(a != null); // could be assertNotNull(a);
+    }
+}
+            ]]>
+        </example>
+    </rule>
+
+    <rule name="SwitchStmtsShouldHaveDefault"
+          language="java"
+          since="1.0"
+          message="Switch statements should be exhaustive, add a default case (or missing enum branches)"
+          typeResolution="true"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#switchstmtsshouldhavedefault">
+        <description>
+            Switch statements should be exhaustive, to make their control flow
+            easier to follow. This can be achieved by adding a `default` case, or,
+            if the switch is on an enum type, by ensuring there is one switch branch
+            for each enum constant.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value><![CDATA[
+                //SwitchStatement[@DefaultCase = false() and @ExhaustiveEnumSwitch = false()]
+            ]]></value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+class Foo {{
+    int x = 2;
+    switch (x) {
+      case 1: int j = 6;
+      case 2: int j = 8;
+      // missing default: here
+    }
+}}
+]]>
+        </example>
+    </rule>
+
+    <rule name="SystemPrintln"
+          language="java"
+          since="2.1"
+          message="{0} is used"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#systemprintln">
+        <description>
+            References to System.(out|err).print are usually intended for debugging purposes and can remain in
+            the codebase even in production code. By using a logger one can enable/disable this behaviour at
+            will (and by priority) and avoid clogging the Standard out log.
+        </description>
+        <priority>2</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//Name[
+    starts-with(@Image, 'System.out.print')
+    or
+    starts-with(@Image, 'System.err.print')
+    ]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+class Foo{
+    Logger log = Logger.getLogger(Foo.class.getName());
+    public void testA () {
+        System.out.println("Entering test");
+        // Better use this
+        log.fine("Entering test");
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="UnusedAssignment"
+          language="java"
+          since="6.26.0"
+          message="The value assigned to this variable is never used or always overwritten"
+          class="net.sourceforge.pmd.lang.java.rule.bestpractices.UnusedAssignmentRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#unusedassignment">
+        <description>
+            Reports assignments to variables that are never used before the variable is overwritten,
+            or goes out of scope. Unused assignments are those for which
+            1. The variable is never read after the assignment, or
+            2. The assigned value is always overwritten by other assignments before the next read of
+            the variable.
+
+            The rule doesn't consider assignments to fields except for those of `this` in a constructor,
+            or static fields of the current class in static initializers.
+
+            The rule may be suppressed with the standard `@SuppressWarnings("unused")` tag.
+
+            The rule subsumes {% rule "UnusedLocalVariable" %}, and {% rule "UnusedFormalParameter" %}.
+            Those violations are filtered
+            out by default, in case you already have enabled those rules, but may be enabled with the property
+            `reportUnusedVariables`. Variables whose name starts with `ignored` or `unused` are filtered out, as
+            is standard practice for exceptions.
+
+            Limitations:
+            * The rule currently cannot know which method calls throw exceptions, or which exceptions they throw.
+            In the body of a try block, every method or constructor call is assumed to throw.  This may cause false-negatives.
+            The only other language construct that is assumed to throw is the `throw` statement, in particular,
+            things like `assert` statements, or NullPointerExceptions on dereference are ignored.
+            * The rule cannot resolve assignments across constructors, when they're called with the special
+            `this(...)` syntax. This may cause false-negatives.
+
+            Both of those limitations may be partly relaxed in PMD 7.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+            class A {
+                // this field initializer is redundant,
+                // it is always overwritten in the constructor
+                int f = 1;
+                A(int f) {
+                    this.f = f;
+                }
+            }
+        ]]>
+        </example>
+        <example><![CDATA[
+class B {
+    int method(int i, int j) {
+        // this initializer is redundant,
+        // it is overwritten in all branches of the `if`
+        int k = 0;
+        // Both the assignments to k are unused, because k is
+        // not read after the if/else
+        // This may hide a bug: the programmer probably wanted to return k
+        if (i < j)
+            k = i;
+        else
+            k = j;
+        return j;
+    }
+}
+        ]]>
+
+        </example>
+        <example><![CDATA[
+class C {
+    int method() {
+        int i = 0;
+        checkSomething(++i);
+        checkSomething(++i);
+        checkSomething(++i);
+        checkSomething(++i);
+        // That last increment is not reported unless
+        // the property `checkUnusedPrefixIncrement` is
+        // set to `true`
+        // Technically it could be written (i+1), but it
+        // is not very important
+    }
+}
+        ]]>
+
+        </example>
+        <example><![CDATA[
+class C {
+    // variables that are truly unused (at most assigned to, but never accessed)
+    // are only reported if property `reportUnusedVariables` is true
+    void method(int param) { } // for example this method parameter
+    // even then, you can suppress the violation with an annotation:
+    void method(@SuppressWarning("unused") int param) { } // no violation, even if `reportUnusedVariables` is true
+    // For catch parameters, or for resources which don't need to be used explicitly,
+    // you can give a name that starts with "ignored" to ignore such warnings
+    {
+        try (Something ignored = Something.create()) {
+            // even if ignored is unused, it won't be flagged
+            // its purpose might be to side-effect in the create/close routines
+        } catch (Exception e) { // this is unused and will cause a warning if `reportUnusedVariables` is true
+            // you should choose a name that starts with "ignored"
+            return;
+        }
+    }
+}
+        ]]>
+
+        </example>
+    </rule>
+
+    <rule name="UnusedFormalParameter"
+          language="java"
+          since="0.8"
+          message="Avoid unused {0} parameters such as ''{1}''."
+          class="net.sourceforge.pmd.lang.java.rule.bestpractices.UnusedFormalParameterRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#unusedformalparameter">
+        <description>
+            Reports parameters of methods and constructors that are not referenced them in the method body.
+            Parameters whose name starts with `ignored` or `unused` are filtered out.
+
+            Removing unused formal parameters from public methods could cause a ripple effect through the code base.
+            Hence, by default, this rule only considers private methods. To include non-private methods, set the
+            `checkAll` property to `true`.
+
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class Foo {
+    private void bar(String howdy) {
+        // howdy is not used
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="UnusedImports"
+          language="java"
+          since="1.0"
+          message="Unused import ''{0}''"
+          class="net.sourceforge.pmd.lang.java.rule.bestpractices.UnusedImportsRule"
+          typeResolution="true"
+          deprecated="true"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#unusedimports">
+        <description>
+            Reports import statements that are not used within the file. This also reports
+            duplicate imports, and imports from the same package. The simplest fix is just
+            to delete those imports.
+
+            This rule is deprecated since PMD 6.34.0. Use the rule {% rule "java/codestyle/UnnecessaryImport" %}
+            from category codestyle instead.
+        </description>
+        <priority>4</priority>
+        <example>
+            <![CDATA[
+import java.io.File;  // not referenced or required
+import java.util.*;   // not referenced or required
+public class Foo {}
+]]>
+        </example>
+    </rule>
+
+    <rule name="UnusedLocalVariable"

Review comment:
       This rule is enabled in our repo




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite-3] zstan commented on a change in pull request #327: review pmd check rules

Posted by GitBox <gi...@apache.org>.
zstan commented on a change in pull request #327:
URL: https://github.com/apache/ignite-3/pull/327#discussion_r705920281



##########
File path: check-rules/errorprone.xml
##########
@@ -0,0 +1,3721 @@
+<?xml version="1.0"?>
+
+<ruleset name="Error Prone"
+         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 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">
+
+    <description>
+        Rules to detect constructs that are either broken, extremely confusing or prone to runtime errors.
+    </description>
+
+    <rule name="AssignmentInOperand"
+          language="java"
+          since="1.03"
+          message="Avoid assignments in operands"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AssignmentInOperandRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#assignmentinoperand">
+        <description>
+            Avoid assignments in operands; this can make code more complicated and harder to read.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public void bar() {
+    int x = 2;
+    if ((x = getX()) == 3) {
+      System.out.println("3!");
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AssignmentToNonFinalStatic"
+          language="java"
+          since="2.2"
+          message="Possible unsafe assignment to a non-final static field in a constructor."
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AssignmentToNonFinalStaticRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#assignmenttononfinalstatic">
+        <description>
+            Identifies a possible unsafe usage of a static field.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class StaticField {
+   static int x;
+   public FinalFields(int y) {
+    x = y; // unsafe
+   }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidAccessibilityAlteration"
+          language="java"
+          since="4.1"
+          message="You should not modify visibility of class or methods using getDeclaredConstructors(), getDeclaredConstructor(Class[]), setAccessible() or PrivilegedAction."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidaccessibilityalteration">
+        <description>
+            Methods such as getDeclaredConstructors(), getDeclaredConstructor(Class[]) and setAccessible(),
+            as the interface PrivilegedAction, allow for the runtime alteration of variable, class, or
+            method visibility, even if they are private. This violates the principle of encapsulation.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//PrimaryExpression[
+(
+(PrimarySuffix[
+        ends-with(@Image,'getDeclaredConstructors')
+                or
+        ends-with(@Image,'getDeclaredConstructor')
+                or
+        ends-with(@Image,'setAccessible')
+        ])
+or
+(PrimaryPrefix/Name[
+        ends-with(@Image,'getDeclaredConstructor')
+        or
+        ends-with(@Image,'getDeclaredConstructors')
+        or
+        starts-with(@Image,'AccessibleObject.setAccessible')
+        ])
+)
+and
+(//ImportDeclaration/Name[
+        contains(@Image,'java.security.PrivilegedAction')])
+]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Method;
+import java.security.PrivilegedAction;
+
+public class Violation {
+  public void invalidCallsInMethod() throws SecurityException, NoSuchMethodException {
+    // Possible call to forbidden getDeclaredConstructors
+    Class[] arrayOfClass = new Class[1];
+    this.getClass().getDeclaredConstructors();
+    this.getClass().getDeclaredConstructor(arrayOfClass);
+    Class clazz = this.getClass();
+    clazz.getDeclaredConstructor(arrayOfClass);
+    clazz.getDeclaredConstructors();
+      // Possible call to forbidden setAccessible
+    clazz.getMethod("", arrayOfClass).setAccessible(false);
+    AccessibleObject.setAccessible(null, false);
+    Method.setAccessible(null, false);
+    Method[] methodsArray = clazz.getMethods();
+    int nbMethod;
+    for ( nbMethod = 0; nbMethod < methodsArray.length; nbMethod++ ) {
+      methodsArray[nbMethod].setAccessible(false);
+    }
+
+      // Possible call to forbidden PrivilegedAction
+    PrivilegedAction priv = (PrivilegedAction) new Object(); priv.run();
+  }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidAssertAsIdentifier"
+          language="java"
+          since="3.4"
+          message="Avoid using assert as an identifier; it became a reserved word in JDK 1.4"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidassertasidentifier">
+        <description>
+            Use of the term 'assert' will conflict with newer versions of Java since it is a reserved word.
+        </description>
+        <priority>2</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>//VariableDeclaratorId[@Name='assert']</value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class A {
+    public class Foo {
+        String assert = "foo";
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidBranchingStatementAsLastInLoop"
+          language="java"
+          since="5.0"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AvoidBranchingStatementAsLastInLoopRule"
+          message="Avoid using a branching statement as the last in a loop."
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidbranchingstatementaslastinloop">
+        <description>
+            Using a branching statement as the last part of a loop may be a bug, and/or is confusing.
+            Ensure that the usage is not a bug, or consider using another approach.
+        </description>
+        <priority>2</priority>
+        <example>
+            <![CDATA[
+// unusual use of branching statement in a loop
+for (int i = 0; i < 10; i++) {
+    if (i*i <= 25) {
+        continue;
+    }
+    break;
+}
+
+// this makes more sense...
+for (int i = 0; i < 10; i++) {
+    if (i*i > 25) {
+        break;
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidCallingFinalize"
+          language="java"
+          since="3.0"
+          message="Avoid calling finalize() explicitly"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AvoidCallingFinalizeRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidcallingfinalize">
+        <description>
+            The method Object.finalize() is called by the garbage collector on an object when garbage collection determines
+            that there are no more references to the object. It should not be invoked by application logic.
+
+            Note that Oracle has declared Object.finalize() as deprecated since JDK 9.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+void foo() {
+    Bar b = new Bar();
+    b.finalize();
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidCatchingNPE"
+          language="java"
+          since="1.8"
+          message="Avoid catching NullPointerException; consider removing the cause of the NPE."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidcatchingnpe">
+        <description>
+            Code should never throw NullPointerExceptions under normal circumstances.  A catch block may hide the
+            original error, causing other, more subtle problems later on.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//CatchStatement/FormalParameter/Type
+ /ReferenceType/ClassOrInterfaceType[@Image='NullPointerException']
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class Foo {
+    void bar() {
+        try {
+            // do something
+        } catch (NullPointerException npe) {
+        }
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidCatchingThrowable"
+          language="java"
+          since="1.2"
+          message="A catch statement should never catch throwable since it includes errors."
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AvoidCatchingThrowableRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidcatchingthrowable">
+        <description>
+            Catching Throwable errors is not recommended since its scope is very broad. It includes runtime issues such as
+            OutOfMemoryError that should be exposed and managed separately.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public void bar() {
+    try {
+        // do something
+    } catch (Throwable th) {  // should not catch Throwable
+        th.printStackTrace();
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidDecimalLiteralsInBigDecimalConstructor"
+          language="java"
+          since="3.4"
+          message="Avoid creating BigDecimal with a decimal (float/double) literal. Use a String literal"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoiddecimalliteralsinbigdecimalconstructor">
+        <description>
+            One might assume that the result of "new BigDecimal(0.1)" is exactly equal to 0.1, but it is actually
+            equal to .1000000000000000055511151231257827021181583404541015625.
+            This is because 0.1 cannot be represented exactly as a double (or as a binary fraction of any finite
+            length). Thus, the long value that is being passed in to the constructor is not exactly equal to 0.1,
+            appearances notwithstanding.
+
+            The (String) constructor, on the other hand, is perfectly predictable: 'new BigDecimal("0.1")' is
+            exactly equal to 0.1, as one would expect.  Therefore, it is generally recommended that the
+            (String) constructor be used in preference to this one.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//AllocationExpression[pmd-java:typeIs('java.math.BigDecimal')]
+[Arguments/ArgumentList/Expression/PrimaryExpression
+    [
+        pmd-java:typeIs('float') or
+        pmd-java:typeIs('java.lang.Float') or
+        pmd-java:typeIs('double') or
+        pmd-java:typeIs('java.lang.Double')
+    ]
+]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+BigDecimal bd = new BigDecimal(1.123);       // loss of precision, this would trigger the rule
+
+BigDecimal bd = new BigDecimal("1.123");     // preferred approach
+
+BigDecimal bd = new BigDecimal(12);          // preferred approach, ok for integer values
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidDuplicateLiterals"
+          language="java"
+          since="1.0"
+          message="The String literal {0} appears {1} times in this file; the first occurrence is on line {2}"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AvoidDuplicateLiteralsRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidduplicateliterals">
+        <description>
+            Code containing duplicate String literals can usually be improved by declaring the String as a constant field.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+private void bar() {
+     buz("Howdy");
+     buz("Howdy");
+     buz("Howdy");
+     buz("Howdy");
+}
+private void buz(String x) {}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidEnumAsIdentifier"
+          language="java"
+          since="3.4"
+          message="Avoid using enum as an identifier; it's a reserved word in JDK 1.5"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidenumasidentifier">
+        <description>
+            Use of the term 'enum' will conflict with newer versions of Java since it is a reserved word.
+        </description>
+        <priority>2</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>//VariableDeclaratorId[@Name='enum']</value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class A {
+    public class Foo {
+        String enum = "foo";
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidFieldNameMatchingMethodName"
+          language="java"
+          since="3.0"
+          message="Field {0} has the same name as a method"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AvoidFieldNameMatchingMethodNameRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidfieldnamematchingmethodname">
+        <description>
+            It can be confusing to have a field name with the same name as a method. While this is permitted,
+            having information (field) and actions (method) is not clear naming. Developers versed in
+            Smalltalk often prefer this approach as the methods denote accessor methods.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class Foo {
+    Object bar;
+    // bar is data or an action or both?
+    void bar() {
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidFieldNameMatchingTypeName"
+          language="java"
+          since="3.0"
+          message="It is somewhat confusing to have a field name matching the declaring class name"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AvoidFieldNameMatchingTypeNameRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidfieldnamematchingtypename">
+        <description>
+            It is somewhat confusing to have a field name matching the declaring type name.
+            This probably means that type and/or field names should be chosen more carefully.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class Foo extends Bar {
+    int foo;    // There is probably a better name that can be used
+}
+public interface Operation {
+    int OPERATION = 1; // There is probably a better name that can be used
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidInstanceofChecksInCatchClause"
+          language="java"
+          since="3.0"
+          message="An instanceof check is being performed on the caught exception.  Create a separate catch clause for this exception type."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidinstanceofchecksincatchclause">
+        <description>
+            Each caught exception type should be handled in its own catch clause.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//CatchStatement/FormalParameter
+ /following-sibling::Block//InstanceOfExpression/PrimaryExpression/PrimaryPrefix
+  /Name[
+   @Image = ./ancestor::Block/preceding-sibling::FormalParameter
+    /VariableDeclaratorId/@Name
+  ]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+try { // Avoid this
+    // do something
+} catch (Exception ee) {
+    if (ee instanceof IOException) {
+        cleanup();
+    }
+}
+
+try {  // Prefer this:
+    // do something
+} catch (IOException ee) {
+    cleanup();
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidLiteralsInIfCondition"
+          language="java"
+          since="4.2.6"
+          message="Avoid using Literals in Conditional Statements"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidliteralsinifcondition">
+        <description>
+            Avoid using hard-coded literals in conditional statements. By declaring them as static variables
+            or private members with descriptive names maintainability is enhanced. By default, the literals "-1" and "0" are ignored.
+            More exceptions can be defined with the property "ignoreMagicNumbers".
+
+            The rule doesn't consider deeper expressions by default, but this can be enabled via the property `ignoreExpressions`.
+            With this property set to false, if-conditions like `i == 1 + 5` are reported as well. Note that in that case,
+            the property ignoreMagicNumbers is not taken into account, if there are multiple literals involved in such an expression.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="ignoreMagicNumbers"
+                      description="Comma-separated list of magic numbers, that should be ignored"
+                      type="String" value="-1,0"/>
+            <property name="ignoreExpressions"
+                      description="If true, only literals in simple if conditions are considered. Otherwise literals in expressions are checked, too."
+                      type="Boolean" value="true"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+(: simple case - no deep expressions :)
+//IfStatement[$ignoreExpressions = true()]/Expression/*/PrimaryExpression/PrimaryPrefix/Literal
+    [not(NullLiteral)]
+    [not(BooleanLiteral)]
+    [empty(index-of(tokenize($ignoreMagicNumbers, '\s*,\s*'), @Image))]
+|
+(: consider also deeper expressions :)
+//IfStatement[$ignoreExpressions = false()]/Expression//*[local-name() != 'UnaryExpression' or @Operator != '-']/PrimaryExpression/PrimaryPrefix/Literal
+    [not(NullLiteral)]
+    [not(BooleanLiteral)]
+    [empty(index-of(tokenize($ignoreMagicNumbers, '\s*,\s*'), @Image))]
+|
+(: consider negative literals :)
+//IfStatement[$ignoreExpressions = false()]/Expression//UnaryExpression[@Operator = '-']/PrimaryExpression/PrimaryPrefix/Literal
+    [not(NullLiteral)]
+    [not(BooleanLiteral)]
+    [empty(index-of(tokenize($ignoreMagicNumbers, '\s*,\s*'), concat('-', @Image)))]
+|
+(: consider multiple literals in expressions :)
+//IfStatement[$ignoreExpressions = false()]/Expression[count(*/PrimaryExpression/PrimaryPrefix/Literal
+    [not(NullLiteral)]
+    [not(BooleanLiteral)]) > 1]
+]]>
+                </value>
+            </property>
+            <property name="version" value="2.0"/>
+        </properties>
+        <example>
+            <![CDATA[
+private static final int MAX_NUMBER_OF_REQUESTS = 10;
+
+public void checkRequests() {
+
+    if (i == 10) {                        // magic number, buried in a method
+      doSomething();
+    }
+
+    if (i == MAX_NUMBER_OF_REQUESTS) {    // preferred approach
+      doSomething();
+    }
+
+    if (aString.indexOf('.') != -1) {}     // magic number -1, by default ignored
+    if (aString.indexOf('.') >= 0) { }     // alternative approach
+
+    if (aDouble > 0.0) {}                  // magic number 0.0
+    if (aDouble >= Double.MIN_VALUE) {}    // preferred approach
+
+    // with rule property "ignoreExpressions" set to "false"
+    if (i == pos + 5) {}  // violation: magic number 5 within an (additive) expression
+    if (i == pos + SUFFIX_LENGTH) {} // preferred approach
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidLosingExceptionInformation"
+          since="4.2.6"
+          language="java"
+          message="Avoid statements in a catch block that invoke accessors on the exception without using the information"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidlosingexceptioninformation">
+        <description>
+            Statements in a catch block that invoke accessors on the exception without using the information
+            only add to code size.  Either remove the invocation, or use the return result.
+        </description>
+        <priority>2</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//CatchStatement/Block/BlockStatement/Statement/StatementExpression/PrimaryExpression/PrimaryPrefix/Name
+[
+   @Image = concat(../../../../../../../FormalParameter/VariableDeclaratorId/@Name, '.getMessage')
+   or
+   @Image = concat(../../../../../../../FormalParameter/VariableDeclaratorId/@Name, '.getLocalizedMessage')
+   or
+   @Image = concat(../../../../../../../FormalParameter/VariableDeclaratorId/@Name, '.getCause')
+   or
+   @Image = concat(../../../../../../../FormalParameter/VariableDeclaratorId/@Name, '.getStackTrace')
+   or
+   @Image = concat(../../../../../../../FormalParameter/VariableDeclaratorId/@Name, '.toString')
+]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public void bar() {
+    try {
+        // do something
+    } catch (SomeException se) {
+        se.getMessage();
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidMultipleUnaryOperators"
+          language="java"
+          since="4.2"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AvoidMultipleUnaryOperatorsRule"
+          message="Using multiple unary operators may be a bug, and/or is confusing."
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidmultipleunaryoperators">
+        <description>
+            The use of multiple unary operators may be problematic, and/or confusing.
+            Ensure that the intended usage is not a bug, or consider simplifying the expression.
+        </description>
+        <priority>2</priority>
+        <example>
+            <![CDATA[
+// These are typo bugs, or at best needlessly complex and confusing:
+int i = - -1;
+int j = + - +1;
+int z = ~~2;
+boolean b = !!true;
+boolean c = !!!true;
+
+// These are better:
+int i = 1;
+int j = -1;
+int z = 2;
+boolean b = true;
+boolean c = false;
+
+// And these just make your brain hurt:
+int i = ~-2;
+int j = -~7;
+]]>
+        </example>
+    </rule>
+
+    <rule name="AvoidUsingOctalValues"
+          language="java"
+          since="3.9"
+          message="Do not start a literal by 0 unless it's an octal value"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.AvoidUsingOctalValuesRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#avoidusingoctalvalues">
+        <description>
+            Integer literals should not start with zero since this denotes that the rest of literal will be
+            interpreted as an octal value.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+int i = 012;    // set i with 10 not 12
+int j = 010;    // set j with 8 not 10
+k = i * j;      // set k with 80 not 120
+]]>
+        </example>
+    </rule>
+
+    <rule name="BadComparison" ref="ComparisonWithNaN" deprecated="true" />
+
+    <rule name="BeanMembersShouldSerialize"
+          language="java"
+          since="1.1"
+          message="Found non-transient, non-static member. Please mark as transient or provide accessors."
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.BeanMembersShouldSerializeRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#beanmembersshouldserialize">
+        <description>
+            If a class is a bean, or is referenced by a bean directly or indirectly it needs to be serializable.
+            Member variables need to be marked as transient, static, or have accessor methods in the class. Marking
+            variables as transient is the safest and easiest modification. Accessor methods should follow the Java
+            naming conventions, i.e. for a variable named foo, getFoo() and setFoo() accessor methods should be provided.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+private transient int someFoo;  // good, it's transient
+private static int otherFoo;    // also OK
+private int moreFoo;            // OK, has proper accessors, see below
+private int badFoo;             // bad, should be marked transient
+
+private void setMoreFoo(int moreFoo){
+      this.moreFoo = moreFoo;
+}
+
+private int getMoreFoo(){
+      return this.moreFoo;
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="BrokenNullCheck"
+          language="java"
+          since="3.8"
+          message="Method call on object which may be null"
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.BrokenNullCheckRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#brokennullcheck">
+        <description>
+            The null check is broken since it will throw a NullPointerException itself.
+            It is likely that you used || instead of &amp;&amp; or vice versa.
+        </description>
+        <priority>2</priority>
+        <example>
+            <![CDATA[
+public String bar(String string) {
+  // should be &&
+    if (string!=null || !string.equals(""))
+        return string;
+  // should be ||
+    if (string==null && string.equals(""))
+        return string;
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="CallSuperFirst"
+          since="4.2.5"
+          language="java"
+          message="super should be called at the start of the method"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#callsuperfirst">
+        <description>Super should be called at the start of the method</description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//MethodDeclaration[
+  @Name='onCreate' or
+  @Name='onConfigurationChanged' or
+  @Name='onPostCreate' or
+  @Name='onPostResume' or
+  @Name='onRestart' or
+  @Name='onRestoreInstanceState' or
+  @Name='onResume' or
+  @Name='onStart'
+  ]
+    /Block[not(
+      (BlockStatement[1]/Statement/StatementExpression/PrimaryExpression[./PrimaryPrefix[@SuperModifier= true()]]/PrimarySuffix[@Image= ancestor::MethodDeclaration/@Name]))]
+[ancestor::ClassOrInterfaceDeclaration[ExtendsList/ClassOrInterfaceType[
+  pmd-java:typeIs('android.app.Activity') or
+  pmd-java:typeIs('android.app.Application') or
+  pmd-java:typeIs('android.app.Service')
+]]]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class DummyActivity extends Activity {
+    public void onCreate(Bundle bundle) {
+        // missing call to super.onCreate(bundle)
+        foo();
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="CallSuperLast"
+          since="4.2.5"
+          language="java"
+          message="super should be called at the end of the method"
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#callsuperlast">
+        <description>
+            Super should be called at the end of the method
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//MethodDeclaration[
+  @Name='finish' or
+  @Name='onDestroy' or
+  @Name='onPause' or
+  @Name='onSaveInstanceState' or
+  @Name='onStop' or
+  @Name='onTerminate'
+  ]
+   /Block/BlockStatement[last()]
+    [not(Statement/StatementExpression/PrimaryExpression[./PrimaryPrefix[@SuperModifier= true()]]/PrimarySuffix[@Image= ancestor::MethodDeclaration/@Name])]
+[ancestor::ClassOrInterfaceDeclaration[ExtendsList/ClassOrInterfaceType[
+  pmd-java:typeIs('android.app.Activity') or
+  pmd-java:typeIs('android.app.Application') or
+  pmd-java:typeIs('android.app.Service')
+]]]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+public class DummyActivity extends Activity {
+    public void onPause() {
+        foo();
+        // missing call to super.onPause()
+    }
+}
+]]>
+        </example>
+    </rule>
+
+    <rule name="CheckSkipResult"
+          language="java"
+          since="5.0"
+          message="Check the value returned by the skip() method of an InputStream to see if the requested number of bytes has been skipped."
+          class="net.sourceforge.pmd.lang.java.rule.errorprone.CheckSkipResultRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#checkskipresult">
+        <description>
+            The skip() method may skip a smaller number of bytes than requested. Check the returned value to find out if it was the case or not.
+        </description>
+        <priority>3</priority>
+        <example>
+            <![CDATA[
+public class Foo {
+
+   private FileInputStream _s = new FileInputStream("file");
+
+   public void skip(int n) throws IOException {
+      _s.skip(n); // You are not sure that exactly n bytes are skipped
+   }
+
+   public void skipExactly(int n) throws IOException {
+      while (n != 0) {
+         long skipped = _s.skip(n);
+         if (skipped == 0)
+            throw new EOFException();
+         n -= skipped;
+      }
+   }
+]]>
+        </example>
+    </rule>
+
+    <rule name="ClassCastExceptionWithToArray"
+          language="java"
+          since="3.4"
+          message="This usage of the Collection.toArray() method will throw a ClassCastException."
+          class="net.sourceforge.pmd.lang.rule.XPathRule"
+          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#classcastexceptionwithtoarray">
+        <description>
+            When deriving an array of a specific class from your Collection, one should provide an array of
+            the same class as the parameter of the toArray() method. Doing otherwise you will will result
+            in a ClassCastException.
+        </description>
+        <priority>3</priority>
+        <properties>
+            <property name="version" value="2.0"/>
+            <property name="xpath">
+                <value>
+                    <![CDATA[
+//CastExpression[Type/ReferenceType/ClassOrInterfaceType[@Image != "Object"]]
+    /PrimaryExpression
+    [PrimaryPrefix/Name[ends-with(@Image, '.toArray')]]
+    [PrimarySuffix/Arguments[not(*)]]
+    [count(PrimarySuffix) = 1]
+]]>
+                </value>
+            </property>
+        </properties>
+        <example>
+            <![CDATA[
+Collection c = new ArrayList();
+Integer obj = new Integer(1);
+c.add(obj);
+
+    // this would trigger the rule (and throw a ClassCastException if executed)
+Integer[] a = (Integer [])c.toArray();
+
+   // this is fine and will not trigger the rule
+Integer[] b = (Integer [])c.toArray(new Integer[c.size()]);
+]]>
+        </example>
+    </rule>
+
+    <rule name="CloneMethodMustBePublic"

Review comment:
       I stopped here, seems all upper is appropriate and very helpful.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org