[java] Rename rule BeanMembersShouldSerialize to NonSerializableClass

This commit is contained in:
Andreas Dangel committed 2022-11-04 18:43:01 +01:00
1 parent 1a07963ea7
commit 9b53bf444e
4 files changed
+35 -33

No files matched your search

@@ -30,13 +30,13 @@ import net.sourceforge.pmd.lang.java.symboltable.VariableNameDeclaration;
import net.sourceforge.pmd.lang.symboltable.NameOccurrence;
import net.sourceforge.pmd.properties.PropertyDescriptor;
public class BeanMembersShouldSerializeRule extends AbstractLombokAwareRule {
public class NonSerializableClassRule extends AbstractLombokAwareRule {
private String prefixProperty;
private static final PropertyDescriptor<String> PREFIX_DESCRIPTOR = stringProperty("prefix").desc("A variable prefix to skip, i.e., m_").defaultValue("").build();
public BeanMembersShouldSerializeRule() {
public NonSerializableClassRule() {
definePropertyDescriptor(PREFIX_DESCRIPTOR);
}
@@ -639,36 +639,7 @@ k = i * j; // set k with 80 not 120
<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="BeanMembersShouldSerialize" ref="NonSerializableClass" deprecated="true" />
<rule name="BrokenNullCheck"
language="java"
@@ -2708,6 +2679,37 @@ public class Foo {
</example>
</rule>
<rule name="NonSerializableClass"
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.NonSerializableClassRule"
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#nonserializableclass">
<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="NonStaticInitializer"
language="java"
since="1.5"
@@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.java.rule.errorprone;
import net.sourceforge.pmd.testframework.PmdRuleTst;
public class BeanMembersShouldSerializeTest extends PmdRuleTst {
public class NonSerializableClassTest extends PmdRuleTst {
// no additional unit tests
}