Merge pull request #4836 from adangel/remove-deprecated-rule-props

Remove deprecated rule props
This commit is contained in:
Juan Martín Sotuyo Dodero
2024-02-29 09:00:16 -05:00
committed by GitHub
8 changed files with 33 additions and 91 deletions

View File

@ -138,6 +138,13 @@ Experimental Kotlin support has been promoted as stable API now.
* {% rule java/codestyle/EmptyControlStatement %}: The rule has a new property to allow empty blocks when
they contain a comment (`allowCommentedBlocks`).
* {% rule apex/codestyle/MethodNamingConventions %}: The deprecated rule property `skipTestMethodUnderscores` has
been removed. It was actually deprecated since PMD 6.15.0, but was not mentioned in the release notes
back then. Use the property `testPattern` instead to configure valid names for test methods.
* {% rule java/documentation/CommentRequired %}: The deprecated property `headerCommentRequirement` has been removed.
Use the property `classCommentRequirement` instead.
* {% rule java/errorprone/NonSerializableClass %}: The deprecated property `prefix` has been removed
without replacement. In a serializable class all fields have to be serializable regardless of the name.
**Removed Rules**
@ -1089,6 +1096,12 @@ Contributors: [Aaron Hurst](https://github.com/aaronhurst-google) (@aaronhurst-g
from all rules. These properties have been deprecated since PMD 6.13.0.
See [issue #1648](https://github.com/pmd/pmd/issues/1648) for more details.
**Apex Codestyle**
* {% rule apex/codestyle/MethodNamingConventions %}: The deprecated rule property `skipTestMethodUnderscores` has
been removed. It was actually deprecated since PMD 6.15.0, but was not mentioned in the release notes
back then. Use the property `testPattern` instead to configure valid names for test methods.
**Java General changes**
* Violations reported on methods or classes previously reported the line range of the entire method
@ -1159,6 +1172,8 @@ Contributors: [Aaron Hurst](https://github.com/aaronhurst-google) (@aaronhurst-g
See also [pull request #3757](https://github.com/pmd/pmd/pull/3757).
* Elements in annotation types are now detected as well. This might lead to an increased number of violations
for missing public method comments.
* The deprecated property `headerCommentRequirement` has been removed. Use the property `classCommentRequirement`
instead.
* {% rule java/documentation/CommentSize %}: When determining the line-length of a comment, the leading comment
prefix markers (e.g. `*` or `//`) are ignored and don't add up to the line-length.
See also [pull request #4369](https://github.com/pmd/pmd/pull/4369).
@ -1172,6 +1187,8 @@ Contributors: [Aaron Hurst](https://github.com/aaronhurst-google) (@aaronhurst-g
special-cased anymore. Rename the exception parameter to `ignored` to ignore them.
* {% rule java/errorprone/ImplicitSwitchFallThrough %}: Violations are now reported on the case statements
rather than on the switch statements. This is more accurate but might result in more violations now.
* {% rule java/errorprone/NonSerializableClass %}: The deprecated property `prefix` has been removed
without replacement. In a serializable class all fields have to be serializable regardless of the name.
#### Removed Rules

View File

@ -343,6 +343,12 @@ can be parsed now. PMD should now be able to parse Apex code up to version 59.0
from all rules. These properties have been deprecated since PMD 6.13.0.
See [issue #1648](https://github.com/pmd/pmd/issues/1648) for more details.
**Apex Codestyle**
* {% rule apex/codestyle/MethodNamingConventions %}: The deprecated rule property `skipTestMethodUnderscores` has
been removed. It was actually deprecated since PMD 6.15.0, but was not mentioned in the release notes
back then. Use the property `testPattern` instead to configure valid names for test methods.
**Java General changes**
* Violations reported on methods or classes previously reported the line range of the entire method
@ -384,6 +390,8 @@ can be parsed now. PMD should now be able to parse Apex code up to version 59.0
not necessary are allowed, if they separate expressions of different precedence.
The other property `ignoreBalancing` (default: true) is similar, in that it allows parentheses that help
reading and understanding the expressions.
* {% rule java/codestyle/EmptyControlStatement %}: The rule has a new property to allow empty blocks when
they contain a comment (`allowCommentedBlocks`).
**Java Design**
@ -411,6 +419,8 @@ can be parsed now. PMD should now be able to parse Apex code up to version 59.0
See also [pull request #3757](https://github.com/pmd/pmd/pull/3757).
* Elements in annotation types are now detected as well. This might lead to an increased number of violations
for missing public method comments.
* The deprecated property `headerCommentRequirement` has been removed. Use the property `classCommentRequirement`
instead.
* {% rule java/documentation/CommentSize %}: When determining the line-length of a comment, the leading comment
prefix markers (e.g. `*` or `//`) are ignored and don't add up to the line-length.
See also [pull request #4369](https://github.com/pmd/pmd/pull/4369).
@ -424,6 +434,8 @@ can be parsed now. PMD should now be able to parse Apex code up to version 59.0
special-cased anymore. Rename the exception parameter to `ignored` to ignore them.
* {% rule java/errorprone/ImplicitSwitchFallThrough %}: Violations are now reported on the case statements
rather than on the switch statements. This is more accurate but might result in more violations now.
* {% rule java/errorprone/NonSerializableClass %}: The deprecated property `prefix` has been removed
without replacement. In a serializable class all fields have to be serializable regardless of the name.
### Deprecated Rules

View File

@ -4,8 +4,6 @@
package net.sourceforge.pmd.lang.apex.rule.codestyle;
import static net.sourceforge.pmd.properties.PropertyFactory.booleanProperty;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Pattern;
@ -30,14 +28,7 @@ public class MethodNamingConventionsRule extends AbstractNamingConventionsRule {
private static final PropertyDescriptor<Pattern> INSTANCE_REGEX = prop("instancePattern", "instance method",
DESCRIPTOR_TO_DISPLAY_NAME).defaultValue(CAMEL_CASE).build();
private static final PropertyDescriptor<Boolean> SKIP_TEST_METHOD_UNDERSCORES_DESCRIPTOR
= booleanProperty("skipTestMethodUnderscores")
.desc("deprecated! Skip underscores in test methods")
.defaultValue(false)
.build();
public MethodNamingConventionsRule() {
definePropertyDescriptor(SKIP_TEST_METHOD_UNDERSCORES_DESCRIPTOR);
definePropertyDescriptor(TEST_REGEX);
definePropertyDescriptor(STATIC_REGEX);
definePropertyDescriptor(INSTANCE_REGEX);
@ -65,11 +56,7 @@ public class MethodNamingConventionsRule extends AbstractNamingConventionsRule {
}
if (node.getModifiers().isTest()) {
if (getProperty(SKIP_TEST_METHOD_UNDERSCORES_DESCRIPTOR)) {
checkMatches(TEST_REGEX, CAMEL_CASE_WITH_UNDERSCORES, node, data);
} else {
checkMatches(TEST_REGEX, node, data);
}
checkMatches(TEST_REGEX, node, data);
} else if (node.getModifiers().isStatic()) {
checkMatches(STATIC_REGEX, node, data);
} else {

View File

@ -64,41 +64,6 @@ public class Foo {
]]></code>
</test-code>
<test-code>
<description>#1573 method names should not contain underscores, but skip test methods 1</description>
<rule-property name="skipTestMethodUnderscores">true</rule-property>
<expected-problems>0</expected-problems>
<code><![CDATA[
public class Foo {
@isTest
void test_barFoo() {}
}
]]></code>
</test-code>
<test-code>
<description>#1573 method names should not contain underscores, but skip test methods 2</description>
<rule-property name="skipTestMethodUnderscores">true</rule-property>
<expected-problems>0</expected-problems>
<code><![CDATA[
public class Foo {
testmethod void test_barFoo() {}
}
]]></code>
</test-code>
<test-code>
<description>#1573 method names should not contain underscores, but skip test methods 3</description>
<rule-property name="skipTestMethodUnderscores">false</rule-property>
<expected-problems>1</expected-problems>
<code><![CDATA[
public class Foo {
@isTest
void test_barFoo() {}
}
]]></code>
</test-code>
<test-code>
<description>all is well</description>
<expected-problems>0</expected-problems>

View File

@ -9,9 +9,6 @@ import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import net.sourceforge.pmd.lang.java.ast.ASTBodyDeclaration;
import net.sourceforge.pmd.lang.java.ast.ASTClassDeclaration;
import net.sourceforge.pmd.lang.java.ast.ASTConstructorDeclaration;
@ -35,8 +32,6 @@ import net.sourceforge.pmd.util.CollectionUtil;
* @author Brian Remedios
*/
public class CommentRequiredRule extends AbstractJavaRulechainRule {
private static final Logger LOG = LoggerFactory.getLogger(CommentRequiredRule.class);
// Used to pretty print a message
private static final Map<String, String> DESCRIPTOR_NAME_TO_COMMENT_TYPE = new HashMap<>();
@ -46,8 +41,6 @@ public class CommentRequiredRule extends AbstractJavaRulechainRule {
private static final PropertyDescriptor<CommentRequirement> OVERRIDE_CMT_DESCRIPTOR
= requirementPropertyBuilder("methodWithOverrideCommentRequirement", "Comments on @Override methods")
.defaultValue(CommentRequirement.Ignored).build();
private static final PropertyDescriptor<CommentRequirement> HEADER_CMT_REQUIREMENT_DESCRIPTOR
= requirementPropertyBuilder("headerCommentRequirement", "Deprecated! Header comments. Please use the property \"classCommentRequired\" instead.").build();
private static final PropertyDescriptor<CommentRequirement> CLASS_CMT_REQUIREMENT_DESCRIPTOR
= requirementPropertyBuilder("classCommentRequirement", "Class comments").build();
private static final PropertyDescriptor<CommentRequirement> FIELD_CMT_REQUIREMENT_DESCRIPTOR
@ -73,7 +66,6 @@ public class CommentRequiredRule extends AbstractJavaRulechainRule {
definePropertyDescriptor(OVERRIDE_CMT_DESCRIPTOR);
definePropertyDescriptor(ACCESSOR_CMT_DESCRIPTOR);
definePropertyDescriptor(CLASS_CMT_REQUIREMENT_DESCRIPTOR);
definePropertyDescriptor(HEADER_CMT_REQUIREMENT_DESCRIPTOR);
definePropertyDescriptor(FIELD_CMT_REQUIREMENT_DESCRIPTOR);
definePropertyDescriptor(PUB_METHOD_CMT_REQUIREMENT_DESCRIPTOR);
definePropertyDescriptor(PROT_METHOD_CMT_REQUIREMENT_DESCRIPTOR);
@ -94,20 +86,7 @@ public class CommentRequiredRule extends AbstractJavaRulechainRule {
getProperty(SERIAL_VERSION_UID_CMT_REQUIREMENT_DESCRIPTOR));
propertyValues.put(SERIAL_PERSISTENT_FIELDS_CMT_REQUIREMENT_DESCRIPTOR,
getProperty(SERIAL_PERSISTENT_FIELDS_CMT_REQUIREMENT_DESCRIPTOR));
CommentRequirement headerCommentRequirementValue = getProperty(HEADER_CMT_REQUIREMENT_DESCRIPTOR);
boolean headerCommentRequirementValueOverridden = headerCommentRequirementValue != CommentRequirement.Required;
CommentRequirement classCommentRequirementValue = getProperty(CLASS_CMT_REQUIREMENT_DESCRIPTOR);
boolean classCommentRequirementValueOverridden = classCommentRequirementValue != CommentRequirement.Required;
if (headerCommentRequirementValueOverridden && !classCommentRequirementValueOverridden) {
LOG.warn("Rule CommentRequired uses deprecated property 'headerCommentRequirement'. "
+ "Future versions of PMD will remove support for this property. "
+ "Please use 'classCommentRequirement' instead!");
propertyValues.put(CLASS_CMT_REQUIREMENT_DESCRIPTOR, headerCommentRequirementValue);
} else {
propertyValues.put(CLASS_CMT_REQUIREMENT_DESCRIPTOR, classCommentRequirementValue);
}
propertyValues.put(CLASS_CMT_REQUIREMENT_DESCRIPTOR, getProperty(CLASS_CMT_REQUIREMENT_DESCRIPTOR));
}
private void checkCommentMeetsRequirement(Object data, JavadocCommentOwner node,
@ -203,8 +182,7 @@ public class CommentRequiredRule extends AbstractJavaRulechainRule {
return getProperty(OVERRIDE_CMT_DESCRIPTOR) == CommentRequirement.Ignored
&& getProperty(ACCESSOR_CMT_DESCRIPTOR) == CommentRequirement.Ignored
&& (getProperty(CLASS_CMT_REQUIREMENT_DESCRIPTOR) == CommentRequirement.Ignored
|| getProperty(HEADER_CMT_REQUIREMENT_DESCRIPTOR) == CommentRequirement.Ignored)
&& getProperty(CLASS_CMT_REQUIREMENT_DESCRIPTOR) == CommentRequirement.Ignored
&& getProperty(FIELD_CMT_REQUIREMENT_DESCRIPTOR) == CommentRequirement.Ignored
&& getProperty(PUB_METHOD_CMT_REQUIREMENT_DESCRIPTOR) == CommentRequirement.Ignored
&& getProperty(PROT_METHOD_CMT_REQUIREMENT_DESCRIPTOR) == CommentRequirement.Ignored

View File

@ -5,7 +5,6 @@
package net.sourceforge.pmd.lang.java.rule.errorprone;
import static net.sourceforge.pmd.properties.PropertyFactory.booleanProperty;
import static net.sourceforge.pmd.properties.PropertyFactory.stringProperty;
import java.io.Externalizable;
import java.io.ObjectInputStream;
@ -45,8 +44,6 @@ import net.sourceforge.pmd.reporting.RuleContext;
// Note: This rule has been formerly known as "BeanMembersShouldSerialize".
public class NonSerializableClassRule extends AbstractJavaRulechainRule {
private static final PropertyDescriptor<String> PREFIX_DESCRIPTOR = stringProperty("prefix")
.desc("deprecated! A variable prefix to skip, i.e., m_").defaultValue("").build();
private static final PropertyDescriptor<Boolean> CHECK_ABSTRACT_TYPES = booleanProperty("checkAbstractTypes")
.desc("Enable to verify fields with abstract types like abstract classes, interfaces, generic types "
+ "or java.lang.Object. Enabling this might lead to more false positives, since the concrete "
@ -62,7 +59,6 @@ public class NonSerializableClassRule extends AbstractJavaRulechainRule {
public NonSerializableClassRule() {
super(ASTVariableId.class, ASTClassDeclaration.class, ASTEnumDeclaration.class,
ASTRecordDeclaration.class);
definePropertyDescriptor(PREFIX_DESCRIPTOR);
definePropertyDescriptor(CHECK_ABSTRACT_TYPES);
}

View File

@ -23,9 +23,6 @@ class CommentRequiredTest extends PmdRuleTst {
assertNull(rule.dysfunctionReason(), "By default, the rule should be functional");
List<PropertyDescriptor<?>> propertyDescriptors = getProperties(rule);
// remove deprecated properties
propertyDescriptors.removeIf(property -> property.description().startsWith("Deprecated!"));
for (PropertyDescriptor<?> property : propertyDescriptors) {
setPropertyValue(rule, property, "Ignored");
}

View File

@ -514,17 +514,7 @@ public class CommentRequired {
</test-code>
<test-code>
<description>#1683 [java] CommentRequired property names are inconsistent - use deprecated property</description>
<rule-property name="headerCommentRequirement">Unwanted</rule-property>
<expected-problems>1</expected-problems>
<code><![CDATA[
/** Unwanted class comment */
public class CommentRequirement {}
]]></code>
</test-code>
<test-code>
<description>#1683 [java] CommentRequired property names are inconsistent - use new property</description>
<description>#1683 [java] CommentRequired property names are inconsistent</description>
<rule-property name="classCommentRequirement">Unwanted</rule-property>
<expected-problems>1</expected-problems>
<code><![CDATA[