[java] SwitchStmtsShouldHaveDefault.xml: don't report empty switch

Empty switch statements are already reported
by EmptyControlStatement
This commit is contained in:
Andreas Dangel 2024-10-24 12:47:44 +02:00
parent 6c35c73919
commit 662759755d
No known key found for this signature in database
GPG Key ID: 93450DF2DF9A3FA3
2 changed files with 15 additions and 0 deletions

View File

@ -24,6 +24,8 @@ See [PR #5040](https://github.com/pmd/pmd/pull/5040) for details.
### 🌟 Rule Changes
#### Changed Rules
* {% rule java/bestpractices/SwitchStmtsShouldHaveDefault %} (Java Best Practices) doesn't report empty switch statements anymore.
To detect these, use {% rule java/codestyle/EmptyControlStatement %}.
* {% rule java/bestpractices/UnitTestShouldUseAfterAnnotation %} (Java Best Practices) now also considers JUnit 5 and TestNG tests.
* {% rule java/bestpractices/UnitTestShouldUseBeforeAnnotation %} (Java Best Practices) now also considers JUnit 5 and TestNG tests.

View File

@ -19,6 +19,19 @@ public class Foo {
]]></code>
</test-code>
<test-code>
<description>empty switch is ok</description>
<expected-problems>0</expected-problems>
<code><![CDATA[
public class Foo {
void bar() {
int x = 2;
switch (x) { } // this is ok. The empty switch is detected by EmptyControlStatement
}
}
]]></code>
</test-code>
<test-code>
<description>simple ok case</description>
<expected-problems>0</expected-problems>