diff --git a/pmd/rulesets/java/basic.xml b/pmd/rulesets/java/basic.xml
index c541a73764..c20b6dc407 100644
--- a/pmd/rulesets/java/basic.xml
+++ b/pmd/rulesets/java/basic.xml
@@ -8,13 +8,13 @@
The Basic ruleset contains a collection of good practices which should be followed.
-
+
+ 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="http://pmd.sourceforge.net/rules/java/basic.html#JumbledIncrementer">
Avoid jumbled loop incrementers - its usually a mistake, and is confusing even if intentional.
@@ -49,8 +49,8 @@ public class JumbledIncrementerRule1 {
@@ -83,8 +83,8 @@ public class Foo {
@@ -119,15 +119,15 @@ public class Foo { // perfect, both methods provided
Partially created objects can be returned by the Double Checked Locking pattern when used in Java.
An optimizing JRE may assign a reference to the baz variable before it creates the object the
-reference is intended to point to.
+reference is intended to point to.
For more details refer to: http://www.javaworld.com/javaworld/jw-02-2001/jw-0209-double.html
@@ -152,8 +152,8 @@ public class Foo {
@@ -188,9 +188,9 @@ public class Bar {
@@ -222,10 +222,10 @@ public class Foo {
+ since="1.2"
+ message="Avoid instantiating Boolean objects; reference Boolean.TRUE or Boolean.FALSE or call Boolean.valueOf() instead."
+ class="net.sourceforge.pmd.lang.java.rule.basic.BooleanInstantiationRule"
+ externalInfoUrl="http://pmd.sourceforge.net/rules/java/basic.html#BooleanInstantiation">
Avoid instantiating Boolean objects; you can reference Boolean.TRUE, Boolean.FALSE, or call Boolean.valueOf() instead.
@@ -237,10 +237,10 @@ Boolean buz = Boolean.valueOf(false); // ...., just reference Boolean.FALSE;
]]>
-
+
@@ -281,14 +281,14 @@ void bar() {
+ 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="http://pmd.sourceforge.net/rules/java/basic.html#ClassCastExceptionWithToArray">
-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
+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.
3
@@ -326,20 +326,20 @@ Integer[] b = (Integer [])c.toArray(new Integer[c.size()]);
-One might assume that the result of "new BigDecimal(0.1)" is exactly equal to 0.1, but it is actually
+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,
+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
+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.
3
@@ -370,7 +370,7 @@ BigDecimal bd = new BigDecimal(12); // preferred approach, ok for integer v
+ language="java"
+ since="3.6"
+ message="Avoid using java.lang.ThreadGroup; it is not thread safe"
+ class="net.sourceforge.pmd.lang.rule.XPathRule"
+ externalInfoUrl="http://pmd.sourceforge.net/rules/java/basic.html#AvoidThreadGroup"
+ typeResolution="true">
Avoid using java.lang.ThreadGroup; although it is intended to be used in a threaded environment
it contains methods that are not thread-safe.
@@ -476,11 +476,11 @@ public String bar(String string) {
-
+
Don't create instances of already existing BigInteger (BigInteger.ZERO, BigInteger.ONE) and
for Java 1.5 onwards, BigInteger.TEN and BigDecimal (BigDecimal.ZERO, BigDecimal.ONE, BigDecimal.TEN)
@@ -504,7 +504,7 @@ bi4 = new BigInteger(0); // reference BigInteger.ZERO instead
externalInfoUrl="http://pmd.sourceforge.net/rules/java/basic.html#AvoidUsingOctalValues">
@@ -525,7 +525,7 @@ k = i * j; // set k with 80 not 120
externalInfoUrl="http://pmd.sourceforge.net/rules/java/basic.html#AvoidUsingHardCodedIP">
@@ -542,8 +542,7 @@ public class Foo {
-
+ since="4.2"
+ class="net.sourceforge.pmd.lang.java.rule.basic.AvoidMultipleUnaryOperatorsRule"
+ message="Using multiple unary operators may be a bug, and/or is confusing."
+ externalInfoUrl="http://pmd.sourceforge.net/rules/java/basic.html#AvoidMultipleUnaryOperators">
-
+
-
+
+ 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.basic.CheckSkipResultRule"
+ externalInfoUrl="http://pmd.sourceforge.net/rules/java/basic.html#CheckSkipResult">
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.
3
@@ -706,10 +705,10 @@ public class Foo {
+ since="5.0"
+ class="net.sourceforge.pmd.lang.java.rule.basic.AvoidBranchingStatementAsLastInLoopRule"
+ message="Avoid using a branching statement as the last in a loop."
+ externalInfoUrl="http://pmd.sourceforge.net/rules/java/basic.html#AvoidBranchingStatementAsLastInLoop">