[java] Renamed rule TooFewBranchesForSwitch
as it consider Switch Expressions now additionally to Switch Statements.
This commit is contained in:
parent
b87944a565
commit
855e5175d4
@ -17,15 +17,16 @@ This is a {{ site.pmd.release_type }} release.
|
||||
### 🌟 Rule Changes
|
||||
|
||||
#### Renamed Rules
|
||||
Several rules for unit testing have been renamed to better reflect their actual scope. Lots of them were called
|
||||
after JUnit / JUnit 4, even when they applied to JUnit 5 and / or TestNG.
|
||||
|
||||
* {% rule java/bestpractices/UnitTestAssertionsShouldIncludeMessage %} (Java Best Practices) has been renamed from `JUnitAssertionsShouldIncludeMessage`.
|
||||
* {% rule java/bestpractices/UnitTestContainsTooManyAsserts %} (Java Best Practices) has been renamed from `JUnitTestContainsTooManyAsserts`.
|
||||
* {% rule java/bestpractices/UnitTestShouldIncludeAssert %} (Java Best Practices) has been renamed from `JUnitTestsShouldIncludeAssert`.
|
||||
* {% rule java/bestpractices/UnitTestShouldUseAfterAnnotation %} (Java Best Practices) has been renamed from `JUnit4TestShouldUseAfterAnnotation`.
|
||||
* {% rule java/bestpractices/UnitTestShouldUseBeforeAnnotation %} (Java Best Practices) has been renamed from `JUnit4TestShouldUseBeforeAnnotation`.
|
||||
* {% rule java/bestpractices/UnitTestShouldUseTestAnnotation %} (Java Best Practices) has been renamed from `JUnit4TestShouldUseTestAnnotation`.
|
||||
* Several rules for unit testing have been renamed to better reflect their actual scope. Lots of them were called
|
||||
after JUnit / JUnit 4, even when they applied to JUnit 5 and / or TestNG.
|
||||
* {% rule java/bestpractices/UnitTestAssertionsShouldIncludeMessage %} (Java Best Practices) has been renamed from `JUnitAssertionsShouldIncludeMessage`.
|
||||
* {% rule java/bestpractices/UnitTestContainsTooManyAsserts %} (Java Best Practices) has been renamed from `JUnitTestContainsTooManyAsserts`.
|
||||
* {% rule java/bestpractices/UnitTestShouldIncludeAssert %} (Java Best Practices) has been renamed from `JUnitTestsShouldIncludeAssert`.
|
||||
* {% rule java/bestpractices/UnitTestShouldUseAfterAnnotation %} (Java Best Practices) has been renamed from `JUnit4TestShouldUseAfterAnnotation`.
|
||||
* {% rule java/bestpractices/UnitTestShouldUseBeforeAnnotation %} (Java Best Practices) has been renamed from `JUnit4TestShouldUseBeforeAnnotation`.
|
||||
* {% rule java/bestpractices/UnitTestShouldUseTestAnnotation %} (Java Best Practices) has been renamed from `JUnit4TestShouldUseTestAnnotation`.
|
||||
* {% rule java/performance/TooFewBranchesForSwitch %} (Java Performance) has been renamed from `TooFewBranchesForASwitchStatement`,
|
||||
as it now applies to Switch Expressions as well.
|
||||
|
||||
The old rule names still work but are deprecated.
|
||||
|
||||
@ -46,6 +47,8 @@ The old rule names still work but are deprecated.
|
||||
* The old rule name `JUnitAssertionsShouldIncludeMessage` has been deprecated. Use the new name {% rule java/bestpractices/UnitTestAssertionsShouldIncludeMessage %} instead.
|
||||
* The old rule name `JUnitTestContainsTooManyAsserts` has been deprecated. Use the new name {% rule java/bestpractices/UnitTestContainsTooManyAsserts %} instead.
|
||||
* The old rule name `JUnitTestsShouldIncludeAssert` has been deprecated. Use the new name {% rule java/bestpractices/UnitTestShouldIncludeAssert %} instead.
|
||||
* java-performance
|
||||
* The old rule name `TooFewBranchesForASwitchStatement` has been deprecated. Use the new name {% rule java/performance/TooFewBranchesForSwitch %} instead.
|
||||
|
||||
|
||||
### ✨ Merged pull requests
|
||||
|
@ -607,16 +607,20 @@ private String baz() {
|
||||
</example>
|
||||
</rule>
|
||||
|
||||
<rule name="TooFewBranchesForASwitchStatement"
|
||||
<rule name="TooFewBranchesForASwitchStatement" deprecated="true" ref="TooFewBranchesForSwitch"/>
|
||||
|
||||
<rule name="TooFewBranchesForSwitch"
|
||||
language="java"
|
||||
since="4.2"
|
||||
class="net.sourceforge.pmd.lang.rule.xpath.XPathRule"
|
||||
message="A switch with less than three branches is inefficient, use a 'if statement' instead."
|
||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_performance.html#toofewbranchesforaswitchstatement">
|
||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_performance.html#toofewbranchesforswitch">
|
||||
<description>
|
||||
Switch statements are intended to be used to support complex branching behaviour. Using a switch for only a few
|
||||
cases is ill-advised, since switches are not as easy to understand as if-else statements. In these cases use the
|
||||
if-else statement to increase code readability.
|
||||
|
||||
Note: This rule was named TooFewBranchesForASwitchStatement before PMD 7.7.0.
|
||||
</description>
|
||||
<priority>3</priority>
|
||||
<properties>
|
||||
|
@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.java.rule.performance;
|
||||
|
||||
import net.sourceforge.pmd.test.PmdRuleTst;
|
||||
|
||||
class TooFewBranchesForASwitchStatementTest extends PmdRuleTst {
|
||||
class TooFewBranchesForSwitchTest extends PmdRuleTst {
|
||||
// no additional unit tests
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user