Skip to content

Commit

Permalink
[apex] MethodNamingConventions: Remove prop skipTestMethodUnderscores
Browse files Browse the repository at this point in the history
This property was deprecated since PMD 6.15.0.
  • Loading branch information
adangel committed Feb 26, 2024
1 parent ce347bd commit 53323de
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 49 deletions.
9 changes: 9 additions & 0 deletions docs/pages/release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ 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.

**Removed Rules**

Expand Down Expand Up @@ -1083,6 +1086,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
Expand Down
6 changes: 6 additions & 0 deletions docs/pages/release_notes_pmd7.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -65,11 +56,7 @@ public Object visit(ASTMethod node, Object data) {
}

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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit 53323de

Please sign in to comment.