diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/security/StaticFieldMustBeFinal.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/security/StaticFieldMustBeFinal.java deleted file mode 100644 index 3d1cca190a..0000000000 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/security/StaticFieldMustBeFinal.java +++ /dev/null @@ -1,11 +0,0 @@ -/** - * BSD-style license; for more info see http://pmd.sourceforge.net/license.html - */ - -package net.sourceforge.pmd.lang.java.rule.security; - -import net.sourceforge.pmd.lang.java.rule.AbstractJavaRule; - -public class StaticFieldMustBeFinal extends AbstractJavaRule { - // no additional unit tests -} diff --git a/pmd-java/src/main/resources/category/java/design.xml b/pmd-java/src/main/resources/category/java/design.xml index de6b56cedb..58bfe97398 100644 --- a/pmd-java/src/main/resources/category/java/design.xml +++ b/pmd-java/src/main/resources/category/java/design.xml @@ -1727,6 +1727,38 @@ public class MaybeAUtility { public static void foo() {} public static void bar() {} } +]]> + + + + + +Non-private static fields must be made constants (or immutable references) by +declaring them final. + +If you are using this rule, then you don't need this +rule {% rule java/errorprone/AssignmentToNonFinalStatic %}. + + 3 + + + + + + + + + + diff --git a/pmd-java/src/main/resources/category/java/security.xml b/pmd-java/src/main/resources/category/java/security.xml index 3442b0210d..b6927e2b08 100644 --- a/pmd-java/src/main/resources/category/java/security.xml +++ b/pmd-java/src/main/resources/category/java/security.xml @@ -60,34 +60,6 @@ public class Foo { byte[] iv = "secret iv in here".getBytes(); } } -]]> - - - - - - Visible static fields must be made constants (or immutable - references) by declaring them final. - - 3 - - - - - - - - - - diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/design/MutableStaticState.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/design/MutableStaticState.java new file mode 100644 index 0000000000..0a80bb6c64 --- /dev/null +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/design/MutableStaticState.java @@ -0,0 +1,11 @@ +/** + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ + +package net.sourceforge.pmd.lang.java.rule.design; + +import net.sourceforge.pmd.testframework.PmdRuleTst; + +public class MutableStaticState extends PmdRuleTst { + // no additional unit tests +} diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/security/xml/StaticFieldMustBeFinal.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/design/xml/MutableStaticState.xml similarity index 100% rename from pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/security/xml/StaticFieldMustBeFinal.xml rename to pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/design/xml/MutableStaticState.xml