diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/UnusedAssignmentRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/UnusedAssignmentRule.java similarity index 99% rename from pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/UnusedAssignmentRule.java rename to pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/UnusedAssignmentRule.java index 3822ce73f7..536d7d2816 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/errorprone/UnusedAssignmentRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/UnusedAssignmentRule.java @@ -2,7 +2,7 @@ * BSD-style license; for more info see http://pmd.sourceforge.net/license.html */ -package net.sourceforge.pmd.lang.java.rule.errorprone; +package net.sourceforge.pmd.lang.java.rule.bestpractices; import static net.sourceforge.pmd.lang.java.rule.codestyle.ConfusingTernaryRule.unwrapParentheses; diff --git a/pmd-java/src/main/resources/category/java/bestpractices.xml b/pmd-java/src/main/resources/category/java/bestpractices.xml index 9c2dbf7138..a295c1b48b 100644 --- a/pmd-java/src/main/resources/category/java/bestpractices.xml +++ b/pmd-java/src/main/resources/category/java/bestpractices.xml @@ -1298,6 +1298,120 @@ class Foo{ + + + 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 UnusedLocalVariable, and UnusedFormalParameter. Those violations are filtered + out by default, in case you already have enabled those rules, but may be enabled with the property + `reportUnusedVariable`. Variables whose name starts with `ignored` are filtered out, as + is standard practice for exceptions. + + 3 + + + + + + + + + + + + + + - - - - 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 UnusedLocalVariable, and UnusedFormalParameter. Those violations are filtered - out by default, in case you already have enabled those rules, but may be enabled with the property - `reportUnusedVariable`. Variables whose name starts with `ignored` are filtered out, as - is standard practice for exceptions. - - 3 - - - - - - - - - - - - - - -